aboutsummaryrefslogtreecommitdiffstats
path: root/poi-examples
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-12-30 20:02:03 +0000
committerPJ Fanning <fanningpj@apache.org>2021-12-30 20:02:03 +0000
commit9a5dec078ba1f6ccc89452a072446940ce3754c3 (patch)
tree1f6830759792c6f5d4dd6174ccab9ecf3440c73c /poi-examples
parent32311e42c2fb1403b165fdda5cbd46d9869f561e (diff)
downloadpoi-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-examples')
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java b/poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java
index d933b23e22..8a9e0e2f0e 100644
--- a/poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java
+++ b/poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java
@@ -62,9 +62,8 @@ import org.apache.poi.util.TempFile;
*/
@SuppressWarnings({"java:S106","java:S4823"})
public final class CopyCompare {
- private CopyCompare() {}
- private static final ThreadLocal<PrintStream> out = ThreadLocal.withInitial(() -> System.out);
+ private PrintStream out = System.out;
/**
* Runs the example program. The application expects one or two arguments:
@@ -83,6 +82,10 @@ public final class CopyCompare {
* supported.
*/
public static void main(final String[] args) throws IOException {
+ new CopyCompare().run(args);
+ }
+
+ public void run(String[] args) throws IOException {
String originalFileName = null;
String copyFileName = null;
@@ -120,12 +123,12 @@ public final class CopyCompare {
POIFSFileSystem cpfs = new POIFSFileSystem(new File(copyFileName))) {
final DirectoryEntry oRoot = opfs.getRoot();
final DirectoryEntry cRoot = cpfs.getRoot();
- out.get().println(EntryUtils.areDirectoriesIdentical(oRoot, cRoot) ? "Equal" : "Not equal");
+ out.println(EntryUtils.areDirectoriesIdentical(oRoot, cRoot) ? "Equal" : "Not equal");
}
}
- public static void setOut(PrintStream ps) {
- out.set(ps);
+ public void setOut(PrintStream ps) {
+ out = ps;
}
private interface InputStreamSupplier {