diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-12-30 20:02:03 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-12-30 20:02:03 +0000 |
commit | 9a5dec078ba1f6ccc89452a072446940ce3754c3 (patch) | |
tree | 1f6830759792c6f5d4dd6174ccab9ecf3440c73c /poi-integration/src | |
parent | 32311e42c2fb1403b165fdda5cbd46d9869f561e (diff) | |
download | poi-9a5dec078ba1f6ccc89452a072446940ce3754c3.tar.gz poi-9a5dec078ba1f6ccc89452a072446940ce3754c3.zip |
rewrite CopyCompare to remove its ThreadLocal which causes a sonar code smell
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1896536 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-integration/src')
-rw-r--r-- | poi-integration/src/test/java/org/apache/poi/stress/HPSFFileHandler.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/poi-integration/src/test/java/org/apache/poi/stress/HPSFFileHandler.java b/poi-integration/src/test/java/org/apache/poi/stress/HPSFFileHandler.java index 4b8d0016e2..9809a7a11f 100644 --- a/poi-integration/src/test/java/org/apache/poi/stress/HPSFFileHandler.java +++ b/poi-integration/src/test/java/org/apache/poi/stress/HPSFFileHandler.java @@ -33,7 +33,6 @@ import java.util.Set; import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream; import org.apache.poi.examples.hpsf.CopyCompare; -import org.apache.poi.extractor.POITextExtractor; import org.apache.poi.hpsf.DocumentSummaryInformation; import org.apache.poi.hpsf.HPSFPropertiesOnlyDocument; import org.apache.poi.hpsf.PropertySet; @@ -129,11 +128,13 @@ public class HPSFFileHandler extends POIFSFileHandler { public void handleAdditional(File file) throws Exception { assumeFalse(EXCLUDES_HANDLE_ADD.contains(file.getParentFile().getName()+"/"+file.getName())); - UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream(); - PrintStream psNew = new PrintStream(bos, true, "ISO-8859-1"); - CopyCompare.setOut(psNew); - CopyCompare.main(new String[]{file.getAbsolutePath(), copyOutput.get().getAbsolutePath()}); - assertEquals("Equal" + NL, bos.toString(StandardCharsets.UTF_8)); + try (UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()) { + PrintStream psNew = new PrintStream(bos, true, "ISO-8859-1"); + CopyCompare copyCompare = new CopyCompare(); + copyCompare.setOut(psNew); + CopyCompare.main(new String[]{file.getAbsolutePath(), copyOutput.get().getAbsolutePath()}); + assertEquals("Equal" + NL, bos.toString(StandardCharsets.UTF_8)); + } } |