Skip to content

Commit

Permalink
Merge pull request #714 from hazendaz/master
Browse files Browse the repository at this point in the history
[cleanup] Use buffered output writer and charset instead of static st…
  • Loading branch information
hazendaz authored Dec 24, 2023
2 parents 5116a3f + b5543ff commit 016919a
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver
import org.codehaus.plexus.resource.ResourceManager
import org.codehaus.plexus.resource.loader.FileResourceLoader

import java.nio.charset.Charset
import java.nio.file.Files
import java.nio.file.Paths
import java.util.stream.Collectors
Expand Down Expand Up @@ -774,7 +775,7 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
}

XDocsReporter xDocsReporter = new XDocsReporter(getBundle(locale), log, threshold, effort, outputEncoding)
xDocsReporter.setOutputWriter(new OutputStreamWriter(new FileOutputStream(new File("${xmlOutputDirectory}/spotbugs.xml")), outputEncoding))
xDocsReporter.setOutputWriter(Files.newBufferedWriter(Paths.get("${xmlOutputDirectory}/spotbugs.xml"), Charset.forName(outputEncoding)))
xDocsReporter.setSpotbugsResults(new XmlSlurper().parse(outputSpotbugsFile))
xDocsReporter.setCompileSourceRoots(this.compileSourceRoots)
xDocsReporter.setTestSourceRoots(this.testSourceRoots)
Expand Down Expand Up @@ -1240,7 +1241,7 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
outputFile.getParentFile().mkdirs()
outputFile.createNewFile()

def writer = outputFile.newWriter(effectiveEncoding)
BufferedWriter writer = Files.newBufferedWriter(outputFile.toPath(), Charset.forName(effectiveEncoding))

if (effectiveEncoding.equalsIgnoreCase("Cp1252")) {
writer.write "<?xml version=\"1.0\" encoding=\"windows-1252\"?>"
Expand Down

0 comments on commit 016919a

Please sign in to comment.