Repository navigation
Fix CodeQL warning-severity alerts: process stream ownership and two leaks - #799
Merged
vharseko merged 1 commit intoJul 31, 2026
Conversation
…leaks Move the wrapping of process streams into the consuming thread of OutputReader, StopReader and StartReader, so that each reader is the sole owner of the whole chain and java/input-resource-leak no longer loses track of it across the thread handoff. InstallerHelper no longer closes the error stream owned by its reader, and closes the standard input of the process instead of mislabelling it as its output. Build the entry input stream chain of ID2Entry in a dedicated method so that it is passed directly to try-with-resources, and close the input stream of Utils.copyFile even when creating the destination file fails. Guard against a null backend in ImportTask.initializeTask() the way runTask() already does.
maximthomas
approved these changes
Jul 31, 2026
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.
Closes the remaining nine warning-severity Code Scanning alerts on
master(there are no error-severity ones left).Process stream readers — alerts #713–#718 (
java/input-resource-leak)OutputReader,StopReaderandStartReaderalready closed the reader handed to them, but they did so on their own background thread, whichjava/input-resource-leakcannot follow. The readers now take the rawInputStreamand build theInputStreamReader/BufferedReaderinside thetry-with-resources of the consuming thread, so a single owner creates and closes the whole chain.While there,
InstallerHelper.invokeImportLDIF()no longer closesprocess.getErrorStream()in itsfinallyblock — that stream belongs to the reader started just above, and closing it from another thread could cut the tail of the error log short. What is left to close isprocess.getOutputStream(), which is the standard input of the process and was mislabelled as its output.ID2Entry— alert #1237 (java/input-resource-leak)The stream chain was assembled through repeated assignments to one variable before being handed to
try-with-resources, which the query loses track of. It is now built bynewEntryInputStream()and passed straight into the resource specification. This also closes the theoretical window where the cipher stream would be left open if theInflaterInputStreamconstructor failed.Utils.copyFile— alert #708 (java/input-resource-leak)The only genuine leak of the batch:
copyInputStreamToFile()closes its argument in afinallyblock that starts aftercreateFile(copy), so a failure there left theFileInputStreamopened bycopyFile()behind.copyFile()now owns its stream throughtry-with-resources, andcreateFile()moved inside the guarded region.ImportTask.initializeTask— alert #769 (java/dereferenced-value-may-be-null)Not reachable in practice: a null backend ID implies at least one include branch, and every include branch either resolves to a backend or is rejected. The guard mirrors the one
runTask()already has, documents why the path is dead and keeps the dereference below safe.Testing
mvn compileonopendj-doc-maven-pluginandopendj-server-legacyopendj-server-legacypackaging (jars, assemblies, server archive)mvn verify -Pprecommit -pl opendj-server-legacy -Dit.test=JETestCase— 33 tests, 0 failures; covers theID2Entryentry decoding path