Skip to content

Commit

Permalink
Blacklist: avoid NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
courville committed May 24, 2024
1 parent 136f98a commit a58bbe1
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/com/archos/mediaprovider/video/Blacklist.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,30 @@ public boolean isFilenameBlacklisted(String fileName) { // check if fileName con
private static ArrayList<String> getBlacklisteds() {
ArrayList<String> blacklisteds = new ArrayList<>();
Cursor c = BlacklistedDbAdapter.VIDEO.queryAllBlacklisteds(mContext);
final int pathColumn = c.getColumnIndexOrThrow(BlacklistedDbAdapter.KEY_PATH);
try {
if (c.moveToFirst()) {
while (!c.isAfterLast()) {
String blacklistedPath = c.getString(pathColumn);
if (blacklistedPath != null) {
blacklistedPath = Uri.parse(blacklistedPath).getPath();
if (!blacklistedPath.endsWith("/"))
blacklistedPath += "/";
blacklisteds.add(blacklistedPath);
if (c != null) {
final int pathColumn = c.getColumnIndexOrThrow(BlacklistedDbAdapter.KEY_PATH);
try {
if (c.moveToFirst()) {
while (!c.isAfterLast()) {
String blacklistedPath = c.getString(pathColumn);
if (blacklistedPath != null) {
blacklistedPath = Uri.parse(blacklistedPath).getPath();
if (!blacklistedPath.endsWith("/"))
blacklistedPath += "/";
blacklisteds.add(blacklistedPath);
}
c.moveToNext();
}
c.moveToNext();
}
} catch (Exception e) {
// with c.close() we get with c.moveToFirst() IllegalStateException: Cannot perform this operation because the connection pool has been closed
// without c.close() we get with c.moveToFirst() CursorWindowAllocationException
Log.e(TAG, "getBlacklisteds: caught Exception", e);
} finally {
c.close();
}
} catch (Exception e) {
// with c.close() we get with c.moveToFirst() IllegalStateException: Cannot perform this operation because the connection pool has been closed
// without c.close() we get with c.moveToFirst() CursorWindowAllocationException
Log.e(TAG, "getBlacklisteds: caught Exception", e);
} finally {
c.close();
} else {
Log.e(TAG, "getBlacklisteds: cursor is null!");
}
return blacklisteds;
}
Expand Down

0 comments on commit a58bbe1

Please sign in to comment.