[ 
https://issues.apache.org/jira/browse/OLINGO-788?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alexandre Boudnik updated OLINGO-788:
-------------------------------------
    Comment: was deleted

(was: I would like to provide a patch for this:
{code}
Index: 
lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDoubleTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- 
lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDoubleTest.java
  (date 1443555739000)
+++ 
lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDoubleTest.java
  (revision )
@@ -93,6 +93,12 @@
     assertEquals(Long.valueOf(1234567890), 
instance.valueOfString("1234567890E-00", null, null, null, null, null,
         Long.class));
 
+    assertEquals(Double.valueOf(0.012345678901234567), 
instance.valueOfString("0.012345678901234567",
+            null, null, null, null, null, Double.class));
+
+    assertEquals(Double.valueOf(123456789012345600.0), 
instance.valueOfString("123456789012345600.0",
+            null, null, null, null, null, Double.class));
+
     assertEquals(Double.valueOf(Double.NaN), instance.valueOfString("NaN", 
null, null, null, null, null,
         Double.class));
     assertEquals(Double.valueOf(Double.NEGATIVE_INFINITY), 
instance.valueOfString("-INF", null, null, null, null,
Index: 
lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDouble.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- 
lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDouble.java
      (date 1443555739000)
+++ 
lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDouble.java
      (revision )
@@ -36,7 +36,8 @@
   protected static final String NaN = "NaN";
 
   private static final Pattern PATTERN = Pattern.compile(
-      
"(?:\\+|-)?\\p{Digit}{1,17}(?:\\.\\p{Digit}{1,17})?(?:(?:E|e)(?:\\+|-)?\\p{Digit}{1,3})?");
+  
"(?:\\+|-)?\\p{Digit}{1,}(?:\\.\\p{Digit}{1,})?(?:(?:E|e)(?:\\+|-)?\\p{Digit}{1,3})?");
+
 
   private static final EdmDouble INSTANCE = new EdmDouble();
 
{code}
)

> Numbers having more than 17 digits in mantissa can't be parsed
> --------------------------------------------------------------
>
>                 Key: OLINGO-788
>                 URL: https://issues.apache.org/jira/browse/OLINGO-788
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata4-commons
>    Affects Versions: (Java) V4 4.0.0-beta-03, (Java) V4 4.0.0
>         Environment: any OS
>            Reporter: Alexandre Boudnik
>            Assignee: Alexandre Boudnik
>            Priority: Critical
>              Labels: easyfix
>             Fix For: (Java) V4 4.1.0
>
>         Attachments: OLINGO-788.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> regexp in 
> {{lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDouble.java}}
>  is too strict and thus it prevents parsing numbers having move than 17 
> digits before or after decimal point even they are just denormalized and have 
> less then 17 meaningful digits, like 0.000001234567890123456 or 
> 1234567890123456000000.0
> As I understand, regex in {{EdmDouble}} is used to prevent exception when the 
> literal get parsed by {{new BigDecimal(String)}}. In not normalized literal 
> zeroes may surround the significant digits. The maximum number of those can’t 
> exceed 17, and decimal point symbol could be either within the sequence of 
> them or not. It makes impossible to perform format check using one regex.
> Also 
> http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/abnf/odata-abnf-construction-rules.txt
>  contains the following definitions:
> {code}
> decimalValue = [SIGN] 1*DIGIT ["." 1*DIGIT]
> doubleValue = decimalValue [ "e" [SIGN] 1*DIGIT ] / nanInfinity ; IEEE 754 
> binary64 floating-point number (15-17 decimal digits)
> singleValue = doubleValue                                       ; IEEE 754 
> binary32 floating-point number (6-9 decimal digits)
> nanInfinity = 'NaN' / '-INF' / 'INF'
> {code}
> If number of significant digits in literal will exceed the capacity of 
> {{double}} or {{float}} it would be checked by comparing 
> BigDecimal.doubleValue
> For formal point of view we do not have need to restrict literals by 
> normalized decimal values, and thus regex for {{EdmDouble}} and {{EdmSingle}} 
> should be relaxed.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to