File tree Expand file tree Collapse file tree
framework/src/test/java/org/tron/core/db Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,6 +68,24 @@ public void testCloseReleasesAllResources() throws Exception {
6868 }
6969 }
7070
71+ @ Test
72+ public void testCloseWhenDbSourceThrows () throws Exception {
73+ CheckPointV2Store store = new CheckPointV2Store ("test-close-dbsource-throws" );
74+
75+ Field dbSourceField = TronDatabase .class .getDeclaredField ("dbSource" );
76+ dbSourceField .setAccessible (true );
77+ DbSourceInter <byte []> originalDbSource = (DbSourceInter <byte []>) dbSourceField .get (store );
78+ DbSourceInter <byte []> mockDbSource = mock (DbSourceInter .class );
79+ doThrow (new RuntimeException ("simulated dbSource failure" )).when (mockDbSource ).closeDB ();
80+ dbSourceField .set (store , mockDbSource );
81+
82+ try {
83+ store .close ();
84+ } finally {
85+ originalDbSource .closeDB ();
86+ }
87+ }
88+
7189 @ Test
7290 public void testCloseDbSourceWhenWriteOptionsThrows () throws Exception {
7391 CheckPointV2Store store = new CheckPointV2Store ("test-close-exception" );
You can’t perform that action at this time.
0 commit comments