Skip to content

Commit ee24a84

Browse files
Tests: use try with resources.
1 parent 5775414 commit ee24a84

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

tests/objectbox-java-test/src/test/java/io/objectbox/CursorBytesTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ public void testFirstLastNextPrev() {
6161

6262
@Test
6363
public void testRemove() {
64-
Transaction transaction = store.beginTx();
65-
try {
64+
try (Transaction transaction = store.beginTx()) {
6665
KeyValueCursor cursor = transaction.createKeyValueCursor();
6766

6867
cursor.put(1, new byte[]{1, 1, 0, 0});
@@ -76,8 +75,6 @@ public void testRemove() {
7675
byte[] next = cursor.getNext();
7776
assertNotNull(next);
7877
assertTrue(Arrays.equals(new byte[]{4, 1, 0, 0}, next));
79-
} finally {
80-
transaction.close();
8178
}
8279
}
8380

tests/objectbox-java-test/src/test/java/io/objectbox/CursorTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,14 @@ public void testLookupKeyUsingIndex_samePrefix() {
203203

204204
@Test
205205
public void testClose() {
206-
Transaction tx = store.beginReadTx();
207-
try {
206+
try (Transaction tx = store.beginReadTx()) {
208207
Cursor<TestEntity> cursor = tx.createCursor(TestEntity.class);
209208
assertFalse(cursor.isClosed());
210209
cursor.close();
211210
assertTrue(cursor.isClosed());
212211

213212
// Double close should be fine
214213
cursor.close();
215-
} finally {
216-
tx.close();
217214
}
218215
}
219216

0 commit comments

Comments
 (0)