Skip to content

Conversation

@adamjohnwright
Copy link

Fixed 5 instances of improper stream management that could cause CLOSE_WAIT connections in Apache when exceptions occur during file export operations.

Changes:

  • PptxExporterController: Wrapped FileInputStream in try-with-resources for both diagramPPTX() and reactionPPTX() methods
  • SbxxExporterController: Wrapped InputStream in try-with-resources for both eventSBGN() and eventSBML() methods
  • CitationController: Wrapped InputStream in try-with-resources for exportCitation() method

Previously, if IOUtils.copy() or flush() threw an exception, streams would not be closed, leaving file descriptors and HTTP connections in CLOSE_WAIT state. The try-with-resources pattern ensures proper cleanup even when exceptions occur.

Note: HttpServletResponse.getOutputStream() is intentionally not closed as the servlet container manages its lifecycle.

🤖 Generated with Claude Code (https://claude.com/claude-code)

@jweiser and I created this and compiled it, but did not run it. We are trying to fix the open Apache2 connections. We know you are on vacation. If you are not able to take a look, could you at least let us know if what is on prod is from the latest commit on the Master branch? And would it be safe to make this change inside and test it first, making sure it still runs?

Fixed 5 instances of improper stream management that could cause
CLOSE_WAIT connections in Apache when exceptions occur during file
export operations.

Changes:
- PptxExporterController: Wrapped FileInputStream in try-with-resources
  for both diagramPPTX() and reactionPPTX() methods
- SbxxExporterController: Wrapped InputStream in try-with-resources
  for both eventSBGN() and eventSBML() methods
- CitationController: Wrapped InputStream in try-with-resources
  for exportCitation() method

Previously, if IOUtils.copy() or flush() threw an exception, streams
would not be closed, leaving file descriptors and HTTP connections
in CLOSE_WAIT state. The try-with-resources pattern ensures proper
cleanup even when exceptions occur.

Note: HttpServletResponse.getOutputStream() is intentionally not closed
as the servlet container manages its lifecycle.

🤖 Generated with Claude Code (https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants