olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rare...@apache.org
Subject olingo-odata4 git commit: OLINGO-1150: The precision and scale checks are being made on exponential form than the denormalized form
Date Thu, 21 Jun 2018 18:56:43 GMT
Repository: olingo-odata4
Updated Branches:
  refs/heads/master 03a02d2d6 -> f0188a6ec


OLINGO-1150: The precision and scale checks are being made on exponential form than the denormalized
form


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/f0188a6e
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/f0188a6e
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/f0188a6e

Branch: refs/heads/master
Commit: f0188a6ecb4092049691201224d17b8f3b4bf713
Parents: 03a02d2
Author: Ramesh Reddy <rareddy@jboss.org>
Authored: Thu Jun 21 13:56:19 2018 -0500
Committer: Ramesh Reddy <rareddy@jboss.org>
Committed: Thu Jun 21 13:56:19 2018 -0500

----------------------------------------------------------------------
 .../olingo/commons/core/edm/primitivetype/EdmDecimal.java     | 7 ++++++-
 .../olingo/commons/core/edm/primitivetype/EdmDecimalTest.java | 2 ++
 2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f0188a6e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimal.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimal.java
b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimal.java
index de0277a..8b9f8f9 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimal.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimal.java
@@ -74,8 +74,13 @@ public final class EdmDecimal extends SingletonPrimitiveType {
   private static boolean validatePrecisionAndScale(final String value, final Integer precision,
       final Integer scale) {
 
-    final Matcher matcher = PATTERN.matcher(value);
+    Matcher matcher = PATTERN.matcher(value);
     matcher.matches();
+	if (matcher.group(3) != null) {
+		String plainValue = new BigDecimal(value).toPlainString();
+		matcher = PATTERN.matcher(plainValue);
+		matcher.matches();
+	}
     final int significantIntegerDigits = "0".equals(matcher.group(1)) ? 0 : matcher.group(1).length();
     final int decimals = matcher.group(2) == null ? 0 : matcher.group(2).length();
     return (precision == null || precision >= significantIntegerDigits + decimals)

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f0188a6e/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimalTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimalTest.java
b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimalTest.java
index 4587680..3fb1c34 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimalTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimalTest.java
@@ -99,6 +99,8 @@ public class EdmDecimalTest extends PrimitiveTypeBaseTest {
     assertEquals(new BigDecimal("12.3"), instance.valueOfString("12.3", null, null, 3, 1,
null, BigDecimal.class));
     assertEquals(new BigDecimal("31991163"), instance.valueOfString("3.1991163E7", null,
null, 8, 7, 
         null, BigDecimal.class));
+    assertEquals(new BigDecimal("31991163.34"),
+        instance.valueOfString("3.199116334E7", null, null, 10, 2, null, BigDecimal.class));
     
     expectFacetsErrorInValueOfString(instance, "0.5", null, null, null, null, null);
     expectFacetsErrorInValueOfString(instance, "-1234", null, null, 2, null, null);


Mime
View raw message