@@ -33,6 +33,9 @@ public abstract class Cursor<T> implements Closeable {
33
33
@ Internal
34
34
static boolean TRACK_CREATION_STACK ;
35
35
36
+ @ Internal
37
+ static boolean LOG_READ_NOT_CLOSED ;
38
+
36
39
protected static final int PUT_FLAG_FIRST = 1 ;
37
40
protected static final int PUT_FLAG_COMPLETE = 1 << 1 ;
38
41
@@ -118,6 +121,7 @@ protected static native long collect004000(long cursor, long keyIfComplete, int
118
121
protected final EntityInfo entityInfo ;
119
122
protected final BoxStore boxStoreForEntities ;
120
123
124
+ protected final boolean readOnly ;
121
125
protected boolean closed ;
122
126
123
127
private final Throwable creationThrowable ;
@@ -127,6 +131,7 @@ protected Cursor(Transaction tx, long cursor, EntityInfo entityInfo, BoxStore bo
127
131
throw new IllegalArgumentException ("Transaction is null" );
128
132
}
129
133
this .tx = tx ;
134
+ readOnly = tx .isReadOnly ();
130
135
this .cursor = cursor ;
131
136
this .entityInfo = entityInfo ;
132
137
this .boxStoreForEntities = boxStore ;
@@ -146,12 +151,15 @@ protected Cursor(Transaction tx, long cursor, EntityInfo entityInfo, BoxStore bo
146
151
@ Override
147
152
protected void finalize () throws Throwable {
148
153
if (!closed ) {
149
- System .err .println ("Cursor was not closed." );
150
- if (creationThrowable != null ) {
151
- System .err .println ("Cursor was initially created here:" );
152
- creationThrowable .printStackTrace ();
154
+ // By default only complain about write cursors
155
+ if (!readOnly || LOG_READ_NOT_CLOSED ) {
156
+ System .err .println ("Cursor was not closed." );
157
+ if (creationThrowable != null ) {
158
+ System .err .println ("Cursor was initially created here:" );
159
+ creationThrowable .printStackTrace ();
160
+ }
161
+ System .err .flush ();
153
162
}
154
- System .err .flush ();
155
163
close ();
156
164
super .finalize ();
157
165
}
0 commit comments