Skip to content

Commit 3e345d9

Browse files
Use try-with-resources (Java 7 or Android Gradle Plugin 3.x).
1 parent 2ca2e81 commit 3e345d9

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

objectbox-java/src/main/java/io/objectbox/Cursor.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,8 @@ protected <TARGET> void checkApplyToManyToDb(List<TARGET> orders, Class<TARGET>
324324
if (orders instanceof ToMany) {
325325
ToMany<TARGET> toMany = (ToMany<TARGET>) orders;
326326
if (toMany.internalCheckApplyToDbRequired()) {
327-
Cursor<TARGET> targetCursor = getRelationTargetCursor(targetClass);
328-
try {
327+
try (Cursor<TARGET> targetCursor = getRelationTargetCursor(targetClass)) {
329328
toMany.internalApplyToDb(this, targetCursor);
330-
} finally {
331-
targetCursor.close();
332329
}
333330
}
334331
}

0 commit comments

Comments
 (0)