Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for SQLException when getting object from SQLite storage #248

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading