Messaging: Use try-with-resource
Change-Id: I6649517cbd990502dfcb54f078764cf05f210268
This commit is contained in:
@@ -270,23 +270,18 @@ public class WidgetConversationProvider extends BaseWidgetProvider {
|
||||
return null;
|
||||
}
|
||||
final Uri uri = MessagingContentProvider.buildConversationMetadataUri(conversationId);
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = context.getContentResolver().query(uri,
|
||||
ConversationListItemData.PROJECTION,
|
||||
null, // selection
|
||||
null, // selection args
|
||||
null); // sort order
|
||||
try (Cursor cursor = context.getContentResolver().query(uri,
|
||||
ConversationListItemData.PROJECTION,
|
||||
null, // selection
|
||||
null, // selection args
|
||||
null // sort order
|
||||
)) {
|
||||
if (cursor != null && cursor.getCount() > 0) {
|
||||
final ConversationListItemData conv = new ConversationListItemData();
|
||||
cursor.moveToFirst();
|
||||
conv.bind(cursor);
|
||||
return conv;
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user