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 1fd58db
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions packages/jsii-pacmak/lib/targets/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1603,29 +1603,29 @@ 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(
this,
value,
descr,
collectionType.collection.elementtype,
parameterName,
isRawArray,
);
} else if (collectionType.collection.kind === spec.CollectionKind.Map) {
validateMap.call(
this,
value,
descr,
collectionType.collection.elementtype,
parameterName,
);
} else {
throw new Error(
`Unhandled collection kind: ${spec.describeTypeReference(type)}`,
);
} else if (spec.isCollectionTypeReference(type)) {
switch (type.collection.kind) {
case spec.CollectionKind.Array:
return validateArray.call(
this,
value,
descr,
type.collection.elementtype,
parameterName,
isRawArray,
);
case spec.CollectionKind.Map:
return validateMap.call(
this,
value,
descr,
type.collection.elementtype,
parameterName,
);
default:
throw new Error(
`Unhandled collection kind: ${spec.describeTypeReference(type)}`,
);
}
}
}
Expand Down

0 comments on commit 1fd58db

Please sign in to comment.