File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
main/scala/play/api/libs/json
test/scala/play/api/libs/json Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ object JsonConfig {
216216 .builder()
217217 .maxNestingDepth(loadMaxNestingDepth)
218218 .maxStringLength(loadMaxStringLength)
219- .maxNumberLength(Int . MaxValue ) // play-json has its own support for limiting number length
219+ .maxNumberLength(loadDigitsLimit ) // play-json has its own support for limiting number length
220220 .build()
221221
222222 private [json] val defaultStreamWriteConstraints : StreamWriteConstraints =
Original file line number Diff line number Diff line change @@ -429,11 +429,29 @@ class JsonSpec extends org.specs2.mutable.Specification {
429429 }
430430
431431 " fail when exceeding the number of digits limit for positive numbers" in {
432- Json .parse(invalidJsonExceedingNumberOfDigits).as[BigNumbers ].must(throwA[IllegalArgumentException ])
432+ Json
433+ .parse(invalidJsonExceedingNumberOfDigits)
434+ .as[BigNumbers ]
435+ .must(throwA[StreamConstraintsException ].like { case e : StreamConstraintsException =>
436+ e.getMessage.must(
437+ equalTo(
438+ " Number value length (1000000) exceeds the maximum allowed (310, from `StreamReadConstraints.getMaxNumberLength()`)"
439+ )
440+ )
441+ })
433442 }
434443
435444 " fail when exceeding the number of digits limit for negative numbers" in {
436- Json .parse(invalidJsonExceedingNumberOfDigitsNegative).as[BigNumbers ].must(throwA[IllegalArgumentException ])
445+ Json
446+ .parse(invalidJsonExceedingNumberOfDigitsNegative)
447+ .as[BigNumbers ]
448+ .must(throwA[StreamConstraintsException ].like { case e : StreamConstraintsException =>
449+ e.getMessage.must(
450+ equalTo(
451+ " Number value length (1000000) exceeds the maximum allowed (310, from `StreamReadConstraints.getMaxNumberLength()`)"
452+ )
453+ )
454+ })
437455 }
438456 }
439457 }
You can’t perform that action at this time.
0 commit comments