mbeckerle commented on a change in pull request #92: Update dependencies to 
their latest versions
URL: https://github.com/apache/incubator-daffodil/pull/92#discussion_r209274912
 
 

 ##########
 File path: 
daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/ConvertTextNumberUnparser.scala
 ##########
 @@ -69,22 +72,36 @@ case class ConvertTextNumberUnparser[S](
     // difficult to assert. Could probably check this with TypeTags or Manifest
     // if we find this is not the case. Want something akin to:
     // Assert.invariant(value.isInstanceOf[S])
-
-    val strRep =
-      if (value == 0 && zeroRep.isDefined) {
-        zeroRep.get
-      } else {
-        // Needed because the DecimalFormat class of ICU will call
-        // doubleValue on scala's BigInt and BigDecimal because it
-        // doesn't recognize it as Java's BigInteger and BigDecimal.
-        // This caused large numbers to be truncated silently.
-        value match {
-          case bd: scala.math.BigDecimal => Assert.usageError("Received 
scala.math.BigDecimal, expected java.math.BigDecimal.")
-          case bi: scala.math.BigInt => Assert.usageError("Received 
scala.math.BigInt, expected java.math.BigInteger.")
-          case _ => // OK
+        
+    val df = nff.getNumFormat(state).get
+    val dfs = df.getDecimalFormatSymbols
+
+    val strRep = value match {
+      case n: Number if n == 0 && zeroRep.isDefined => zeroRep.get
+      // We need to special case infinity and NaN because ICU4J has a bug and
+      // will add an exponent to inf/nan (e.g. INFx10^0) if defined in the
+      // pattern, which we don't want. We need to manually output the inf/nan
+      // rep plus the prefix and suffix
+      case f: JFloat if f.isInfinite =>
 
 Review comment:
   In the past when we've had workarounds of bugs in 3rd party libraries I've 
created a unit test that will fail if the bug is fixed, so that we know we can 
take out the workaround. Anytime we're working around or depending on a strange 
behavior, a specific unit test is useful to detect if the behavior changes. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to