Close slice cursor when done using.

Change-Id: I22f2d5fe990fb43e1694879f27d7c0be26675d2b
Fixes: 123878106
Test: manual
This commit is contained in:
Fan Zhang
2019-02-05 12:43:51 -08:00
parent 4c49ae1f7f
commit b7f5bcb238

View File

@@ -75,8 +75,9 @@ public class SlicesDatabaseAccessor {
if (pathData == null) {
throw new IllegalStateException("Invalid Slices uri: " + uri);
}
Cursor cursor = getIndexedSliceData(pathData.second /* key */);
return buildSliceData(cursor, uri, pathData.first /* isIntentOnly */);
try (Cursor cursor = getIndexedSliceData(pathData.second /* key */)) {
return buildSliceData(cursor, uri, pathData.first /* isIntentOnly */);
}
}
/**
@@ -85,8 +86,9 @@ public class SlicesDatabaseAccessor {
* Used when handling the action of the {@link Slice}.
*/
public SliceData getSliceDataFromKey(String key) {
Cursor cursor = getIndexedSliceData(key);
return buildSliceData(cursor, null /* uri */, false /* isIntentOnly */);
try (Cursor cursor = getIndexedSliceData(key)) {
return buildSliceData(cursor, null /* uri */, false /* isIntentOnly */);
}
}
/**