Messaging: Use try-with-resource
Change-Id: I6649517cbd990502dfcb54f078764cf05f210268
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
* Copyright (C) 2024 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -445,17 +446,11 @@ public class ContactUtil {
|
||||
return null;
|
||||
}
|
||||
String firstName = null;
|
||||
Cursor nameCursor = null;
|
||||
try {
|
||||
nameCursor = ContactUtil.lookupStructuredName(context, contactId, true)
|
||||
.performSynchronousQuery();
|
||||
try (Cursor nameCursor = ContactUtil.lookupStructuredName(context, contactId, true)
|
||||
.performSynchronousQuery()) {
|
||||
if (nameCursor != null && nameCursor.moveToFirst()) {
|
||||
firstName = nameCursor.getString(ContactUtil.INDEX_STRUCTURED_NAME_GIVEN_NAME);
|
||||
}
|
||||
} finally {
|
||||
if (nameCursor != null) {
|
||||
nameCursor.close();
|
||||
}
|
||||
}
|
||||
return firstName;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user