Skip to content

Commit

Permalink
Check for SQLException when getting object from SQLite storage
Browse files Browse the repository at this point in the history
  • Loading branch information
danilo04 committed Oct 10, 2023
1 parent 8eecca0 commit 1f0e420
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Simperium/src/main/java/com/simperium/client/Bucket.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import android.database.Cursor;
import android.database.CursorWrapper;
import android.database.SQLException;

import androidx.core.util.Consumer;

Expand Down Expand Up @@ -513,7 +514,15 @@ public T get(String key) throws BucketObjectMissingException {
} catch (GhostMissingException e) {
throw(new BucketObjectMissingException(String.format("Bucket %s does not have object %s", getName(), key)));
}
T object = mStorage.get(key);

// Check if there isn't an SQLException (e.g. SQLiteBlobTooBigException) to avoid propageting an unchecked
// exception.
T object;
try {
object = mStorage.get(key);
} catch (SQLException e) {
throw(new BucketObjectMissingException(String.format("Bucket %s does not have object %s", getName(), key), e));
}
if (object == null) {
throw(new BucketObjectMissingException(String.format("Storage provider for bucket:%s did not have object %s", getName(), key)));
}
Expand Down

0 comments on commit 1f0e420

Please sign in to comment.