diff --git a/js/react_native/android/src/androidTest/java/ai/onnxruntime/reactnative/OnnxruntimeModuleTest.java b/js/react_native/android/src/androidTest/java/ai/onnxruntime/reactnative/OnnxruntimeModuleTest.java index 824b814da3e6c..92f6b19301a59 100644 --- a/js/react_native/android/src/androidTest/java/ai/onnxruntime/reactnative/OnnxruntimeModuleTest.java +++ b/js/react_native/android/src/androidTest/java/ai/onnxruntime/reactnative/OnnxruntimeModuleTest.java @@ -254,9 +254,10 @@ public void throwWrongSizeInput() { Assert.fail("Should have thrown exception"); } catch (Exception e) { Assert.assertTrue(e.getMessage().contains("Got invalid dimensions for input")); + } finally { + ortModule.dispose(sessionKey); } } finally { - ortModule.dispose(sessionKey); mockSession.finishMocking(); } } @@ -313,9 +314,10 @@ public void throwWrongRankInput() { Assert.fail("Should have thrown exception"); } catch (Exception e) { Assert.assertTrue(e.getMessage().contains("Invalid rank for input")); + } finally { + ortModule.dispose(sessionKey); } } finally { - ortModule.dispose(sessionKey); mockSession.finishMocking(); } }