Skip to content

Commit 5d2e8fd

Browse files
add a sanity check while getting key from contextmap
Signed-off-by: Vedant Mahabaleshwarkar <[email protected]>
1 parent 9a24b4d commit 5d2e8fd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/java/com/ibm/watson/modelmesh/ModelMesh.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4430,7 +4430,16 @@ private Object invokeLocalModel(CacheEntry<?> ce, Method method, Object[] args)
44304430
ce.upgradePriority(now + 3600_000L, now + 7200_000L); // (2 hours in future)
44314431
}
44324432
Map<String, String> contextMap = ThreadContext.getCurrentContext();
4433-
String vModelId = contextMap.getOrDefault(VMODELID, "");
4433+
String vModelId = null;
4434+
// We might arrive here from a path where the original call was with a modelid.
4435+
// Hence, it is possible to arrive here with a null contextMap because the vModelId was never set
4436+
// To avoid catching a null pointer exception we just sanity check instead.
4437+
if (contextMap == null) {
4438+
vModelId = "";
4439+
} else {
4440+
vModelId = contextMap.get(VMODELID);
4441+
}
4442+
44344443
// The future-waiting timeouts should not be needed, request threads are interrupted when their
44354444
// timeouts/deadlines expire, and the model loading thread that it waits for has its own timeout.
44364445
// But we still set a large one as a safeguard (there can be pathalogical cases where model-loading

0 commit comments

Comments
 (0)