Messaging: Use try-with-resource

Change-Id: I6649517cbd990502dfcb54f078764cf05f210268
This commit is contained in:
Michael W
2024-12-26 15:54:37 +01:00
parent 2a09fa3cb9
commit 9538179c75
24 changed files with 199 additions and 455 deletions
@@ -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.
@@ -265,19 +266,14 @@ public class VCardRequest implements MediaRequest<VCardResource> {
for (final VCardEntry.PhotoData photo : photos) {
final byte[] photoBytes = photo.getBytes();
if (photoBytes != null) {
final InputStream inputStream = new ByteArrayInputStream(photoBytes);
try {
try (InputStream inputStream = new ByteArrayInputStream(photoBytes)) {
avatarUri = UriUtil.persistContentToScratchSpace(inputStream);
if (avatarUri != null) {
// Just load the first avatar and be done. Want more? wait for V2.
break;
}
} finally {
try {
inputStream.close();
} catch (final IOException e) {
// Do nothing.
}
} catch (IOException e) {
// Do nothing.
}
}
}