]> nmode's Git Repositories - signal-cli/blobdiff - lib/src/main/java/org/asamk/signal/manager/helper/ProfileHelper.java
Fix inspections
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / helper / ProfileHelper.java
index 6d5f2aa180c9e97c32cfbd032ce2a466657b662e..1631ad9d37323045bb7159177012f25d49b5ac85 100644 (file)
@@ -212,10 +212,11 @@ public final class ProfileHelper {
 
         if (avatar != null) {
             if (avatar.isPresent()) {
-                final var streamDetails = Utils.createStreamDetails(avatar.get()).first();
-                context.getAvatarStore()
-                        .storeProfileAvatar(account.getSelfRecipientAddress(),
-                                outputStream -> IOUtils.copyStream(streamDetails.getStream(), outputStream));
+                try (final var streamDetails = Utils.createStreamDetails(avatar.get()).first()) {
+                    context.getAvatarStore()
+                            .storeProfileAvatar(account.getSelfRecipientAddress(),
+                                    outputStream -> IOUtils.copyStream(streamDetails.getStream(), outputStream));
+                }
             } else {
                 context.getAvatarStore().deleteProfileAvatar(account.getSelfRecipientAddress());
             }