Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix StrictMode crashes by calling close on our DexFiles #314

Merged
merged 1 commit into from
Jul 1, 2015

Conversation

abscondment
Copy link
Contributor

When we enable StictMode, sugar occasionally throws the following sort of error:

java.lang.Throwable: Explicit termination method 'close' not called
    at dalvik.system.CloseGuard.open(CloseGuard.java:184)
    at dalvik.system.DexFile.<init>(DexFile.java:82)
    at com.orm.util.ReflectionUtil.getAllClasses(ReflectionUtil.java:295)
    at com.orm.util.ReflectionUtil.getDomainClasses(ReflectionUtil.java:253)
    at com.orm.SchemaGenerator.createDatabase(SchemaGenerator.java:37)
    at com.orm.SugarDb.onCreate(SugarDb.java:26)
    at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251)
    at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
    at com.orm.SugarDb.getDB(SugarDb.java:36)
    at com.orm.SugarRecord.find(SugarRecord.java:189)
    [snip]

This is because instances of DexFile need to be closed when they're no longer needed. This patch cleans up resources to fix the crashing case.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.12%) to 71.01% when pulling ff29934 on madrona-labs:fix-strictmode into a45dd1a on satyan:master.

@black-snow
Copy link

@satyan @whoshuu please merge this

satyan added a commit that referenced this pull request Jul 1, 2015
Fix StrictMode crashes by calling `close` on our DexFiles
@satyan satyan merged commit ebdcb3c into chennaione:master Jul 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants