You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@johnzon.apache.org by "jeanouii (via GitHub)" <gi...@apache.org> on 2023/05/10 21:20:54 UTC

[GitHub] [johnzon] jeanouii opened a new pull request, #105: WIP fix(JOHNZON-397): protection against very slow BigDecimal to BigInteger conversion at large scale

jeanouii opened a new pull request, #105:
URL: https://github.com/apache/johnzon/pull/105

   Requires maybe an option to configure the limit. Not sure if anyone needs something bigger than 1k digits.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@johnzon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [johnzon] jeanouii merged pull request #105: fix(JOHNZON-397): protection against very slow BigDecimal to BigInteger conversion at large scale

Posted by "jeanouii (via GitHub)" <gi...@apache.org>.
jeanouii merged PR #105:
URL: https://github.com/apache/johnzon/pull/105


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@johnzon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [johnzon] rmannibucau commented on a diff in pull request #105: WIP fix(JOHNZON-397): protection against very slow BigDecimal to BigInteger conversion at large scale

Posted by "rmannibucau (via GitHub)" <gi...@apache.org>.
rmannibucau commented on code in PR #105:
URL: https://github.com/apache/johnzon/pull/105#discussion_r1190695589


##########
johnzon-core/src/main/java/org/apache/johnzon/core/JsonNumberImpl.java:
##########
@@ -117,4 +119,17 @@ private void checkFractionalPart() {
             throw new ArithmeticException("Not an int/long, use other value readers");
         }
     }
+
+    private void checkBigIntegerScale() {

Review Comment:
   guess we need a toggle in the `Map` + `JsonbConfig` + `MapperBuilder` to disable it for backward compat - it stays legal?



##########
johnzon-core/src/test/java/org/apache/johnzon/core/JsonNumberTest.java:
##########
@@ -62,20 +64,62 @@ public void equals() {
     
     @Test(expected=ArithmeticException.class)
     public void testBigIntegerExact() {
-       
         JsonArray array = Json.createArrayBuilder().add(100.0200).build();
         array.getJsonNumber(0).bigIntegerValueExact();
-
-       
     }
-    
+
     @Test
     public void testBigInteger() {
-       
         JsonArray array = Json.createArrayBuilder().add(100.0200).build();
         Assert.assertEquals(new BigInteger("100"), array.getJsonNumber(0).bigIntegerValue());
+    }
+
+    @Test
+    public void testSlowBigIntegerConversion() {

Review Comment:
   maybe test failing cases?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@johnzon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [johnzon] jeanouii commented on a diff in pull request #105: WIP fix(JOHNZON-397): protection against very slow BigDecimal to BigInteger conversion at large scale

Posted by "jeanouii (via GitHub)" <gi...@apache.org>.
jeanouii commented on code in PR #105:
URL: https://github.com/apache/johnzon/pull/105#discussion_r1190836441


##########
johnzon-core/src/test/java/org/apache/johnzon/core/JsonNumberTest.java:
##########
@@ -62,20 +64,62 @@ public void equals() {
     
     @Test(expected=ArithmeticException.class)
     public void testBigIntegerExact() {
-       
         JsonArray array = Json.createArrayBuilder().add(100.0200).build();
         array.getJsonNumber(0).bigIntegerValueExact();
-
-       
     }
-    
+
     @Test
     public void testBigInteger() {
-       
         JsonArray array = Json.createArrayBuilder().add(100.0200).build();
         Assert.assertEquals(new BigInteger("100"), array.getJsonNumber(0).bigIntegerValue());
+    }
+
+    @Test
+    public void testSlowBigIntegerConversion() {

Review Comment:
   It's right bellow



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@johnzon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org