Clean up remaining CodeQL deprecated-call alerts - #308
Open
vharseko wants to merge 1 commit into
Open
Conversation
All three open CodeQL alerts on master are java/deprecated-call in maven-external-dependency-plugin: - ArtifactItem.toString(): use Objects.toString(version, "?") instead of the deprecated plexus-utils StringUtils.defaultString(version, "?") — identical semantics for a String field. - AbstractExternalDependencyMojo.generatePomFile(): use try-with-resources instead of the deprecated IOUtil.close(writer) in a finally block. Side effect: a failure while flushing or closing the temporary POM writer now surfaces as MojoExecutionException instead of being swallowed. No other behaviour changes; the module compiles.
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.
Clears the last three open CodeQL alerts on
master. All of them arejava/deprecated-call(severitynote, no security severity) inmaven-external-dependency-plugin:ArtifactItem.java:365StringUtils.defaultStringArtifactItem.java:360StringUtils.defaultStringAbstractExternalDependencyMojo.java:176IOUtil.closeChanges
ArtifactItem.toString()— replace the deprecated plexus-utilsStringUtils.defaultString(version, "?")withObjects.toString(version, "?").versionis aStringfield, so the semantics are identical (null->"?", otherwise the value itself).AbstractExternalDependencyMojo.generatePomFile()— replace the deprecatedIOUtil.close(writer)in thefinallyblock with try-with-resources aroundWriterFactory.newXmlWriter(pomFile).One behaviour change worth noting
IOUtil.close()swallowed anyIOExceptionthrown while closing. With try-with-resources, a failure while flushing or closing the temporary POM writer now propagates into the existingcatch (IOException)and surfaces asMojoExecutionException, instead of leaving a silently truncated POM behind. That is the intended improvement, not a regression.Verification
mvn --batch-mode -pl maven-external-dependency-plugin/maven-external-dependency-plugin clean compilepasses. The files use CRLF line endings; the diff preserves them, so it stays at 7 insertions / 11 deletions.After this merges, the repository has 0 open code scanning alerts.