You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by pr...@apache.org on 2012/08/01 23:56:07 UTC

svn commit: r1368289 - /incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToIntegerOperation.java

Author: prestonc
Date: Wed Aug  1 21:56:07 2012
New Revision: 1368289

URL: http://svn.apache.org/viewvc?rev=1368289&view=rev
Log:
Added an exception for INF, -INF and NaN values.

Modified:
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToIntegerOperation.java

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToIntegerOperation.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToIntegerOperation.java?rev=1368289&r1=1368288&r2=1368289&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToIntegerOperation.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/cast/CastToIntegerOperation.java Wed Aug  1 21:56:07 2012
@@ -32,7 +32,11 @@ public class CastToIntegerOperation exte
 
     @Override
     public void convertDouble(DoublePointable doublep, DataOutput dOut) throws SystemException, IOException {
-        if (doublep.getDouble() > Long.MAX_VALUE || doublep.getDouble() < Long.MIN_VALUE) {
+        double doubleValue = doublep.getDouble();
+        if (Double.isInfinite(doubleValue) || Double.isNaN(doubleValue)) {
+            throw new SystemException(ErrorCode.FOCA0002);
+        }
+        if (doubleValue > Long.MAX_VALUE || doubleValue < Long.MIN_VALUE) {
             throw new SystemException(ErrorCode.FOCA0003);
         }
         dOut.write(ValueTag.XS_INTEGER_TAG);
@@ -41,7 +45,11 @@ public class CastToIntegerOperation exte
 
     @Override
     public void convertFloat(FloatPointable floatp, DataOutput dOut) throws SystemException, IOException {
-        if (floatp.getFloat() > Long.MAX_VALUE || floatp.getFloat() < Long.MIN_VALUE) {
+        float floatValue = floatp.getFloat();
+        if (Float.isInfinite(floatValue) || Float.isNaN(floatValue)) {
+            throw new SystemException(ErrorCode.FOCA0002);
+        }
+        if (floatValue > Long.MAX_VALUE || floatValue < Long.MIN_VALUE) {
             throw new SystemException(ErrorCode.FOCA0003);
         }
         dOut.write(ValueTag.XS_INTEGER_TAG);