sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1804004 - /sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
Date Thu, 03 Aug 2017 14:23:00 GMT
Author: desruisseaux
Date: Thu Aug  3 14:22:59 2017
New Revision: 1804004

URL: http://svn.apache.org/viewvc?rev=1804004&view=rev
Log:
Avoid flooding the logs with messages for the same unsupported NaN value.

Modified:
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java?rev=1804004&r1=1804003&r2=1804004&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
[UTF-8] Thu Aug  3 14:22:59 2017
@@ -124,6 +124,12 @@ public class FeatureFormat extends Tabul
     private static final int MAXIMAL_VALUE_LENGTH = 40;
 
     /**
+     * The bit patterns of the last {@link Float#NaN} value for which {@link MathFunctions#toNanOrdinal(float)}
could
+     * not get the ordinal value. We use this information for avoiding flooding the logger
with the same message.
+     */
+    private transient int illegalNaN;
+
+    /**
      * Creates a new formatter for the default locale and timezone.
      */
     public FeatureFormat() {
@@ -532,7 +538,11 @@ public class FeatureFormat extends Tabul
                                                 if (n > 0) buffer.append(" #").append(n);
                                             } catch (IllegalArgumentException e) {
                                                 // May happen if the NaN is a signaling NaN
instead than a quiet NaN.
-                                                Logging.recoverableException(Logging.getLogger(Modules.FEATURE),
FeatureFormat.class, "format", e);
+                                                final int bits = Float.floatToRawIntBits(f);
+                                                if (bits != illegalNaN) {
+                                                    illegalNaN = bits;
+                                                    Logging.recoverableException(Logging.getLogger(Modules.FEATURE),
FeatureFormat.class, "format", e);
+                                                }
                                             }
                                         }
                                     }



Mime
View raw message