We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Move cursor declaration outside try block and close it when not null when exception is trown.
try
private int getExifOrientation(String sourceUri) { int exifOrientation = ORIENTATION_0; if (sourceUri.startsWith(ContentResolver.SCHEME_CONTENT)) { final String[] columns = { MediaStore.Images.Media.ORIENTATION }; Cursor cursor = null; try { cursor = getContext().getContentResolver().query(Uri.parse(sourceUri), columns, null, null, null); // if (cursor != null) { if (cursor.moveToFirst()) { int orientation = cursor.getInt(0); if (VALID_ORIENTATIONS.contains(orientation) && orientation != ORIENTATION_USE_EXIF) { exifOrientation = orientation; } else { Log.w(TAG, "Unsupported orientation: " + orientation); } } cursor.close(); // } } catch (Exception e) { Log.w(TAG, "Could not get orientation of image from media store"); if (cursor != null) cursor.close(); } } else if (sourceUri.startsWith(ImageSource.FILE_SCHEME) && !sourceUri.startsWith(ImageSource.ASSET_SCHEME)) { // ... } return exifOrientation; }
The text was updated successfully, but these errors were encountered:
#216 Ensure cursor is closed after exception
aa406e9
Thanks, that'll be fixed in the next release.
Sorry, something went wrong.
No branches or pull requests
Move cursor declaration outside
try
block and close it when not null when exception is trown.The text was updated successfully, but these errors were encountered: