{"record":{"id":"3a6b8912992eee3b","repo":"apache/iceberg","slug":"an-error-occurred-while-aborting-the-stream","errorCode":null,"errorMessage":"An error occurred while aborting the stream","messagePattern":"An error occurred while aborting the stream","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"aws/src/main/java/org/apache/iceberg/aws/s3/S3InputStream.java","lineNumber":302,"sourceCode":"        }\n\n        // the Apache HTTP client will throw a ConnectionClosedException\n        // when closing an aborted stream, which is expected\n        if (!e.getClass().getSimpleName().equals(\"ConnectionClosedException\")) {\n          throw e;\n        }\n      }\n      stream = null;\n    }\n  }\n\n  private void abortStream() {\n    try {\n      if (stream instanceof Abortable && stream.read() != -1) {\n        ((Abortable) stream).abort();\n      }\n    } catch (Exception e) {\n      LOG.warn(\"An error occurred while aborting the stream\", e);\n    }\n  }\n\n  public void setSkipSize(int skipSize) {\n    this.skipSize = skipSize;\n  }\n\n  @SuppressWarnings({\"checkstyle:NoFinalizer\", \"Finalize\", \"deprecation\"})\n  @Override\n  protected void finalize() throws Throwable {\n    super.finalize();\n    if (!closed) {\n      close(); // releasing resources is more important than printing the warning\n      String trace = Joiner.on(\"\\n\\t\").join(Arrays.copyOfRange(createStack, 1, createStack.length));\n      LOG.warn(\"Unclosed input stream created by:\\n\\t{}\", trace);\n    }\n  }\n}","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aws/src/main/java/org/apache/iceberg/aws/s3/S3InputStream.java#L284-L320","documentation":"S3InputStream.abortStream() logs this warning when calling Abortable.abort() on the underlying S3 stream (or reading it to check for remaining data) throws. It is a best-effort cleanup path during close(); the original stream is still closed and the abort failure is not propagated.","triggerScenarios":"Calling close() on an S3InputStream whose underlying stream still has unread data, and either stream.read() in the abort check throws or the Abortable.abort() call fails (e.g. connection already broken, S3 client shutdown, network reset).","commonSituations":"Partially reading a large S3 file then closing (random-read/row-group skipping patterns), closing streams during task cancellation or executor shutdown, transient network errors to S3, or the AWS client being closed before the stream.","solutions":["Ensure the AWS S3 client / FileIO outlives all streams derived from it; close streams before closing the client.","Check network connectivity and S3 endpoint health if this appears during normal partial reads.","Read the full stream when practical, or rely on abort() so incomplete reads are cleaned up; treat this warn as non-fatal.","Upgrade Iceberg/AWS SDK versions to pick up stream-abort robustness fixes."],"exampleFix":"// before\nstream.close(); s3Client.close(); // client closed while streams still aborting\n// after\ntry (S3InputStream in = (S3InputStream) fileIO.newInputFile(file).newStream()) {\n  // read data\n}\n// then close the client after all streams are closed\ns3Client.close();","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try (inputStream) { ... } catch (Exception e) { LOG.debug(\"stream abort/close issue suppressed\", e); } // the abort warning is non-fatal; ensure client outlives streams","preventionTips":["Close streams before closing the FileIO/AWS client","Prefer full reads or rely on abort to clean partial reads","Monitor for repeated warnings indicating network or client-lifecycle problems"],"tags":["aws","s3","io","cleanup"],"backgroundTag":"stream-abort-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}