forked from codinguser/gnucash-android
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Roboelectric complaining about not closing resources. (#42)
Co-authored-by: Kaligula <[email protected]>
- Loading branch information
1 parent
310a299
commit 1b2294e
Showing
9 changed files
with
146 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,8 @@ | |
import org.gnucash.android.model.BaseModel; | ||
import org.gnucash.android.util.TimestampHelper; | ||
|
||
import java.io.Closeable; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
|
@@ -44,7 +46,7 @@ | |
* | ||
* @author Ngewi Fet <[email protected]> | ||
*/ | ||
public abstract class DatabaseAdapter<Model extends BaseModel> { | ||
public abstract class DatabaseAdapter<Model extends BaseModel> implements Closeable { | ||
/** | ||
* Tag for logging | ||
*/ | ||
|
@@ -833,4 +835,23 @@ public void enableForeignKey(boolean enable) { | |
public void endTransaction() { | ||
mDb.endTransaction(); | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
if (mInsertStatement != null) { | ||
mInsertStatement.close(); | ||
mInsertStatement = null; | ||
} | ||
if (mReplaceStatement != null) { | ||
mReplaceStatement.close(); | ||
mReplaceStatement = null; | ||
} | ||
if (mUpdateStatement != null) { | ||
mUpdateStatement.close(); | ||
mUpdateStatement = null; | ||
} | ||
if (mDb.isOpen()) { | ||
mDb.close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters