Skip to content

Commit

Permalink
Merge pull request #248 from Simperium/issue/sqlblobtoobig
Browse files Browse the repository at this point in the history
Check for SQLException when getting object from SQLite storage
  • Loading branch information
AliSoftware authored Oct 11, 2023
2 parents 8eecca0 + 45b683b commit 11e14c0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 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,18 @@ 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 propagating an unchecked
// exception.
// Note: this check should be at the storage level since at the Bucket level we don't know that we are dealing
// with a SQLite storage. However, at this point we have more information about what is happening, thus, it can
// be better reported.
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 11e14c0

Please sign in to comment.