Fixes #27091: Close SAML FileInputStream and HttpURLConnection resources#27532
Open
hyspacex wants to merge 2 commits intoopen-metadata:mainfrom
Open
Fixes #27091: Close SAML FileInputStream and HttpURLConnection resources#27532hyspacex wants to merge 2 commits intoopen-metadata:mainfrom
hyspacex wants to merge 2 commits intoopen-metadata:mainfrom
Conversation
Replace mockConstruction(FileInputStream.class) + delegateToKeyStoreBytes stubbing with a real JKS keystore written to @tempdir. The try-with-resources close is guaranteed by Java; the test now asserts behavior (KeyStore loaded into samlData) rather than verifying internal mock plumbing.
Contributor
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
Code Review ✅ ApprovedExplicitly closes SAML FileInputStream and HttpURLConnection resources to prevent potential memory leaks. No issues found. OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes:
Fixes #27091
Addresses two of the three resource leaks reported in the issue:
Bug 1 —
SamlSettingsHolder.initDefaultSettingsleaked aFileInputStream.The keystore stream was created inline in
keyStore.load(new FileInputStream(path), password)and the reference was lost immediately, so it could never be closed. Wrapped it in try-with-resources.Bug 2 —
SamlValidator.validateIdpConnectivityleaked anHttpURLConnection, andreadResponseSnippetleaked the responseInputStream.Lifted
connabove the try block and added afinally { if (conn != null) conn.disconnect(); }. Wrapped the response stream inreadResponseSnippetin try-with-resources.Bug 3 —
IndexResourcewas already fixed in #27269 (CSP nonce handling) — the currentIndexResource.javanow reads/assets/index.htmlonce into astatic finalfield inside a try-with-resources block with a null check. Nothing to do here.Tests
SamlValidatorTest: addedreadResponseSnippetClosesReadableStreamsandvalidateIdpConnectivityDisconnectsConnections, plus a mockURLStreamHandlerfor themock://protocol so we can inject a trackingHttpURLConnectionwithout real network I/O.SamlSettingsHolderTest(new): writes a real empty JKS to@TempDirand asserts the keystore loads intosamlData[KEYSTORE_KEY]. Proves the fix end-to-end without mockingFileInputStreamconstruction.SamlValidatorTest+SamlSettingsHolderTest.mvn spotless:applyreports no changes needed.Type of change:
Checklist:
Fixes <issue-number>: <short explanation>