You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2018/02/28 17:37:02 UTC

svn commit: r1825590 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java

Author: tilman
Date: Wed Feb 28 17:37:02 2018
New Revision: 1825590

URL: http://svn.apache.org/viewvc?rev=1825590&view=rev
Log:
PDFBOX-4055: Sonar fix, change static variable in synchronized method

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java?rev=1825590&r1=1825589&r2=1825590&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java Wed Feb 28 17:37:02 2018
@@ -47,22 +47,27 @@ final class JBIG2Filter extends Filter
 {
     private static final Log LOG = LogFactory.getLog(JBIG2Filter.class);
 
-    private static boolean newPluginChecked = false;
+    private static boolean levigoLogged = false;
+
+    private static synchronized void logLevigoDonated()
+    {
+        if (!levigoLogged)
+        {
+            LOG.info("The Levigo JBIG2 plugin has been donated to the Apache Foundation");
+            LOG.info("and an improved version is available for download at "
+                    + "https://pdfbox.apache.org/download.cgi");
+            levigoLogged = true;
+        }
+    }
 
     @Override
     public DecodeResult decode(InputStream encoded, OutputStream decoded,
                                          COSDictionary parameters, int index) throws IOException
     {
         ImageReader reader = findImageReader("JBIG2", "jbig2-imageio is not installed");
-        if (!newPluginChecked)
+        if (reader.getClass().getName().contains("levigo"))
         {
-            if (reader.getClass().getName().contains("levigo"))
-            {
-                LOG.info("The Levigo JBIG2 plugin has been donated to the Apache Foundation");
-                LOG.info("and an improved version is available for download at "
-                        + "https://pdfbox.apache.org/download.cgi");
-            }
-            newPluginChecked = true;
+            logLevigoDonated();
         }
         DecodeResult result = new DecodeResult(new COSDictionary());
         result.getParameters().addAll(parameters);