diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/types/semtype/Core.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/types/semtype/Core.java index 38e07db2e83e..370d01c3f66c 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/types/semtype/Core.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/types/semtype/Core.java @@ -297,12 +297,12 @@ public static boolean isNever(SemType t) { public static boolean isSubType(Context cx, SemType t1, SemType t2) { try { cx.enterTypeCheckingPhase(t1, t2); - return isEmpty(cx, diff(t1, t2)); + boolean res = isEmpty(cx, diff(t1, t2)); + cx.exitTypeCheckingPhase(); + return res; } catch (Exception e) { cx.registerAbruptTypeCheckEnd(e); throw e; - } finally { - cx.exitTypeCheckingPhase(); } } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/types/semtype/Env.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/types/semtype/Env.java index 544341aff3e0..9ad83c218ae1 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/types/semtype/Env.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/types/semtype/Env.java @@ -329,12 +329,16 @@ void enterTypeResolutionPhase(Context cx, MutableSemType t) throws InterruptedEx } void exitTypeResolutionPhaseAbruptly(Context cx, Exception ex) { - typeResolutionSemaphore.release(); - typeResolutionPhaser.arriveAndDeregister(); - releaseLock((ReentrantReadWriteLock) atomLock); - releaseLock((ReentrantReadWriteLock) recListLock); - releaseLock((ReentrantReadWriteLock) recMapLock); - releaseLock((ReentrantReadWriteLock) recFunctionLock); + try { + typeResolutionSemaphore.release(); + typeResolutionPhaser.arriveAndDeregister(); + releaseLock((ReentrantReadWriteLock) atomLock); + releaseLock((ReentrantReadWriteLock) recListLock); + releaseLock((ReentrantReadWriteLock) recMapLock); + releaseLock((ReentrantReadWriteLock) recFunctionLock); + } catch (Exception ignored) { + + } this.selfDiagnosticsRunner.registerAbruptTypeResolutionEnd(cx, ex); }