j256 / ormlite-android

ORMLite Android functionality used in conjunction with ormlite-core
http://ormlite.com/
ISC License
1.59k stars 367 forks source link

Fix of trying to close Cursor twice #33

Closed dant3 closed 9 years ago

dant3 commented 9 years ago

The warning Android prints in logcat is: Close cursor android.database.sqlite.SQLiteCursor on null twice or more

SA: http://stackoverflow.com/questions/25245249/ormlite-sqlitecursor-close-cursor-on-null-twice-or-more

neteinstein commented 9 years ago

+1

djrsousa commented 9 years ago

+1

jiongxuan commented 9 years ago

+1 too

tiper commented 9 years ago

+1

jcaseiro commented 9 years ago

+1

tprochazka commented 9 years ago

I agree, it should be merged. It is the fasteest way how to fix it.

But it doesn't fix real issue of this problem. Why is close() called twice? Also is interesting that it happen only on some device for me (like HTC).

dant3 commented 9 years ago

Why is close() called twice?

It looks like a bug in ormlite-core actually.

BryceCicada commented 9 years ago

Looks like StatementExecutor.queryForFirst() closes both the query result and the prepared statement. The latter closes the former in both JDBC and Android implementations.

Is it feasible to remove one of these, probably the former?

https://github.com/j256/ormlite-core/blob/master/src/main/java/com/j256/ormlite/stmt/StatementExecutor.java

j256 commented 9 years ago

I'm going to take this merge request as opposed to changing StatementExecutor. There are a number of places where it closes both the statement and the result. Can anyone find docs that this is not the right thing to do?