Skip to content

Commit 8ea5d75

Browse files
committed
RSMR: add defensive exception guard
IllegalStateException can come back from isAssignable when there's an unmatched type param in the base type (at least). We don't need to stop the op search in this case, just move on from that particular candidate. Other solutions would be to return false instead of throwing that exception, in Types.isAssignable. We could also catch any exception and not just IllegalState. But this seemed like the most minimal change that would not affect any other code path that might rely on exceptions being thrown.
1 parent dcd0f69 commit 8ea5d75

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

‎scijava/scijava-ops-engine/src/main/java/org/scijava/ops/engine/matcher/impl/RuntimeSafeMatchingRoutine.java‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -302,17 +302,19 @@ private boolean typesMatch(final Type opType, final Type reqType,
302302
final Map<TypeVariable<?>, Type> typeVarAssigns)
303303
{
304304
if (reqType == null) return true;
305-
if (reqType instanceof ParameterizedType) {
306-
if (!GenericAssignability.checkGenericAssignability(opType,
307-
(ParameterizedType) reqType, typeVarAssigns, true))
308-
{
309-
return false;
305+
try {
306+
if (reqType instanceof ParameterizedType) {
307+
if (!GenericAssignability.checkGenericAssignability(opType, (ParameterizedType) reqType, typeVarAssigns, true)) {
308+
return false;
309+
}
310310
}
311-
}
312-
else {
313-
if (!Types.isAssignable(opType, reqType)) {
314-
return false;
311+
else {
312+
if (!Types.isAssignable(opType, reqType)) {
313+
return false;
314+
}
315315
}
316+
} catch (IllegalStateException e) {
317+
return false;
316318
}
317319
return true;
318320
}

0 commit comments

Comments
 (0)