From a181ed04202fe14dd780b23e0fa2e243b3a584d8 Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Tue, 17 May 2022 11:00:54 -0400 Subject: [PATCH] Revert "Always try to close the PartProvider open file pipe." This reverts commit d97184ef6083466f88280d25f9c5839dbd24887c. --- .../securesms/providers/PartProvider.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/providers/PartProvider.java b/app/src/main/java/org/thoughtcrime/securesms/providers/PartProvider.java index 86c043e26..716b0af51 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/providers/PartProvider.java +++ b/app/src/main/java/org/thoughtcrime/securesms/providers/PartProvider.java @@ -157,27 +157,19 @@ public final class PartProvider extends BaseContentProvider { ParcelFileDescriptor[] reliablePipe = ParcelFileDescriptor.createReliablePipe(); SignalExecutors.BOUNDED_IO.execute(() -> { - Throwable error = null; try (OutputStream out = new FileOutputStream(reliablePipe[1].getFileDescriptor())) { - try (InputStream in = SignalDatabase.attachments().getAttachmentStream(attachmentId, 0)) { + try(InputStream in = SignalDatabase.attachments().getAttachmentStream(attachmentId, 0)) { StreamUtil.copy(in, out); } catch (IOException e) { Log.w(TAG, "Error providing file", e); - error = e; + try { + reliablePipe[1].closeWithError(e.getMessage()); + } catch (IOException e2) { + Log.w(TAG, "Error closing pipe with error", e2); + } } } catch (IOException e) { Log.w(TAG, "Error opening pipe for writing", e); - error = e; - } finally { - try { - if (error != null) { - reliablePipe[1].closeWithError("Error writing file: " + error.getMessage()); - } else { - reliablePipe[1].close(); - } - } catch (IOException e2) { - Log.w(TAG, "Error closing pipe", e2); - } } });