Skip to content

fix(backend): close FileInputStream in SvmConnector to prevent resour…#3764

Open
melbiialy wants to merge 1 commit intoeclipse-sw360:mainfrom
melbiialy:fix/svmconnector-resource-leak
Open

fix(backend): close FileInputStream in SvmConnector to prevent resour…#3764
melbiialy wants to merge 1 commit intoeclipse-sw360:mainfrom
melbiialy:fix/svmconnector-resource-leak

Conversation

@melbiialy
Copy link

@melbiialy melbiialy commented Feb 26, 2026

Description

Fixed a resource leak in SvmConnector.createSslSocketFactoryForSVM() where a FileInputStream was not being properly closed. The KeyStore.load() method does not close the provided InputStream according to Java API documentation, causing file handle leaks when loading SSL certificates for SVM connections.

Changed line 88 in backend/common/src/main/java/org/eclipse/sw360/datahandler/db/SvmConnector.java to use try-with-resources pattern:

Before:

trustStore.load(new FileInputStream(javaKeystoreFilename), JAVA_KEYSTORE_PASSWORD);

After:

try (FileInputStream fis = new FileInputStream(javaKeystoreFilename)) {
    trustStore.load(fis, JAVA_KEYSTORE_PASSWORD);
}

This ensures the FileInputStream is properly closed even when exceptions occur, preventing:

  • File handle exhaustion in long-running applications
  • Memory leaks from unclosed stream buffers
  • File locking issues on Windows systems

Fixes #3763

Suggested Reviewers

@GMishx

…ce leak

The keyStore.load() method doesn't close the inputstream. This caused file handle leaks when loading SSL certificates for SVM connections.

Changed line 88 in createSslSocketFactoryForSVM() to use try-with-resources pattern to ensure the FileInputStream is properly closed even when exceptions occur.

Signed-off-by: Elbialy0 <mahmoudelbialy109@gmail.com>
@GMishx GMishx added needs code review needs general test This is general testing, meaning that there is no org specific issue to check for labels Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs code review needs general test This is general testing, meaning that there is no org specific issue to check for

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resource leak in SvmConnector: FileInputStream not closed

2 participants