Skip to content

Commit

Permalink
fix(pacmak): crash when generating java code
Browse files Browse the repository at this point in the history
A missing condition in the code generator could have resulted
in attempting to read a property on undefined, resulting in
a crash.
  • Loading branch information
RomainMuller committed Aug 30, 2022
1 parent c482bcd commit 6d61c11
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/jsii-pacmak/lib/targets/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1603,26 +1603,26 @@ class JavaGenerator extends Generator {
) {
if (spec.isUnionTypeReference(type)) {
validateTypeUnion.call(this, value, descr, type, parameterName);
} else {
const collectionType = type as spec.CollectionTypeReference;
if (collectionType.collection.kind === spec.CollectionKind.Array) {
validateArray.call(
} else if (spec.isCollectionTypeReference(type)) {
switch (type.collection.kind) {
case spec.CollectionKind.Array:
return validateArray.call(
this,
value,
descr,
collectionType.collection.elementtype,
type.collection.elementtype,
parameterName,
isRawArray,
);
} else if (collectionType.collection.kind === spec.CollectionKind.Map) {
validateMap.call(
case spec.CollectionKind.Map:
return validateMap.call(
this,
value,
descr,
collectionType.collection.elementtype,
type.collection.elementtype,
parameterName,
);
} else {
default:
throw new Error(
`Unhandled collection kind: ${spec.describeTypeReference(type)}`,
);
Expand Down

0 comments on commit 6d61c11

Please sign in to comment.