Skip to content

Commit cef8ce6

Browse files
QueryBuilder: do not implement Closeable, avoid confusing IDE hints.
Follow-up from Query(Builder): implement Closeable. Document finalize methods.
1 parent 8731809 commit cef8ce6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

objectbox-java/src/main/java/io/objectbox/query/QueryBuilder.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
* @param <T> Entity class for which the Query is built.
5959
*/
6060
@SuppressWarnings({"WeakerAccess", "UnusedReturnValue", "unused"})
61-
public class QueryBuilder<T> implements Closeable {
61+
public class QueryBuilder<T> {
6262

6363
public enum StringOrder {
6464
/**
@@ -229,7 +229,9 @@ private QueryBuilder(long storeHandle, long subQueryBuilderHandle) {
229229
}
230230

231231
/**
232-
* Explicitly call {@link #close()} instead to avoid expensive finalization.
232+
* Typically {@link #build()} is called on this which calls {@link #close()} and avoids expensive finalization here.
233+
* <p>
234+
* If {@link #build()} is not called, make sure to explicitly call {@link #close()}.
233235
*/
234236
@SuppressWarnings("deprecation") // finalize()
235237
@Override
@@ -238,6 +240,12 @@ protected void finalize() throws Throwable {
238240
super.finalize();
239241
}
240242

243+
/**
244+
* Close this query builder and free used resources.
245+
* <p>
246+
* This is not required when calling {@link #build()}.
247+
*/
248+
// Not implementing (Auto)Closeable as QueryBuilder is typically closed due to build() getting called.
241249
public synchronized void close() {
242250
if (handle != 0) {
243251
// Closeable recommendation: mark as "closed" before nativeDestroy could throw.

0 commit comments

Comments
 (0)