Skip to content

Commit 888cb65

Browse files
authored
Remove deprecated code (#1243)
1 parent 7c680d1 commit 888cb65

File tree

5 files changed

+12
-80
lines changed

5 files changed

+12
-80
lines changed

play-json/jvm/src/main/scala/play/api/libs/json/EnvReads.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,10 +724,10 @@ trait EnvReads {
724724
}
725725

726726
protected def parseBigDecimal(input: String): JsResult[java.math.BigDecimal] =
727-
BigDecimalParser.parse(input, JsonParserSettings.settings)
727+
BigDecimalParser.parse(input, JsonConfig.settings)
728728

729729
protected def parseBigInteger(input: String): JsResult[java.math.BigInteger] = {
730-
if (input.length > JsonParserSettings.settings.bigDecimalParseSettings.digitsLimit) {
730+
if (input.length > JsonConfig.settings.bigDecimalParseConfig.digitsLimit) {
731731
JsError("error.expected.numberdigitlimit")
732732
} else {
733733
try {

play-json/jvm/src/main/scala/play/api/libs/json/JsonConfig.scala

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -259,63 +259,3 @@ private final case class JsonConfigImpl(
259259
bigDecimalSerializerConfig: BigDecimalSerializerConfig,
260260
streamReadConstraints: StreamReadConstraints
261261
) extends JsonConfig
262-
263-
@deprecated("Use BigDecimalParseConfig instead", "2.9.4")
264-
final case class BigDecimalParseSettings(
265-
mathContext: MathContext = MathContext.DECIMAL128,
266-
scaleLimit: Int,
267-
digitsLimit: Int
268-
) extends BigDecimalParseConfig
269-
270-
@deprecated("Use BigDecimalSerializerConfig instead", "2.9.4")
271-
final case class BigDecimalSerializerSettings(
272-
minPlain: BigDecimal,
273-
maxPlain: BigDecimal
274-
) extends BigDecimalSerializerConfig {
275-
override def preserveZeroDecimal: Boolean = defaultPreserveZeroDecimal
276-
}
277-
278-
@deprecated("Use JsonConfig instead", "2.9.4")
279-
final case class JsonParserSettings(
280-
bigDecimalParseSettings: BigDecimalParseSettings,
281-
bigDecimalSerializerSettings: BigDecimalSerializerSettings,
282-
streamReadConstraints: StreamReadConstraints = JsonConfig.defaultStreamReadConstraints
283-
) extends JsonConfig {
284-
override def bigDecimalParseConfig: BigDecimalParseConfig = bigDecimalParseSettings
285-
286-
override def bigDecimalSerializerConfig: BigDecimalSerializerConfig = bigDecimalSerializerSettings
287-
}
288-
289-
object JsonParserSettings {
290-
val defaultMathContext: MathContext = JsonConfig.defaultMathContext
291-
292-
// Limit for the scale considering the MathContext of 128
293-
// limit for scale for decimal128: BigDecimal("0." + "0" * 33 + "1e-6143", java.math.MathContext.DECIMAL128).scale + 1
294-
val defaultScaleLimit: Int = JsonConfig.defaultScaleLimit
295-
296-
// 307 digits should be the correct value for 128 bytes. But we are using 310
297-
// because Play JSON uses BigDecimal to parse any number including Doubles and
298-
// Doubles max value has 309 digits, so we are using 310 here
299-
val defaultDigitsLimit: Int = JsonConfig.defaultDigitsLimit
300-
301-
// Maximum magnitude of BigDecimal to write out as a plain string
302-
val MaxPlain: BigDecimal = JsonConfig.defaultMaxPlain
303-
304-
// Minimum magnitude of BigDecimal to write out as a plain string
305-
val MinPlain: BigDecimal = JsonConfig.defaultMinPlain
306-
307-
def apply(): JsonParserSettings = JsonParserSettings(
308-
BigDecimalParseSettings(defaultMathContext, defaultScaleLimit, defaultDigitsLimit),
309-
BigDecimalSerializerSettings(minPlain = MinPlain, maxPlain = MaxPlain)
310-
)
311-
312-
/**
313-
* Return the default settings configured from System properties.
314-
*/
315-
val settings: JsonParserSettings = {
316-
JsonParserSettings(
317-
BigDecimalParseSettings(loadMathContext, loadScaleLimit, loadDigitsLimit),
318-
BigDecimalSerializerSettings(loadMinPlain, loadMaxPlain)
319-
)
320-
}
321-
}

play-json/jvm/src/main/scala/play/api/libs/json/jackson/JacksonJson.scala

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,15 @@ import play.api.libs.json._
4242
* import com.fasterxml.jackson.databind.ObjectMapper
4343
*
4444
* import play.api.libs.json.JsValue
45-
* import play.api.libs.json.jackson.PlayJsonModule
46-
* import play.api.libs.json.JsonParserSettings
45+
* import play.api.libs.json.jackson.PlayJsonMapperModule
46+
* import play.api.libs.json.JsonConfig
4747
*
48-
* val jsonSettings = JsonSettings.settings
48+
* val jsonSettings = JsonConfig.settings
4949
* val mapper = new ObjectMapper().registerModule(
5050
* new PlayJsonMapperModule(jsonSettings))
5151
* val jsValue = mapper.readValue("""{"foo":"bar"}""", classOf[JsValue])
5252
* }}}
5353
*/
54-
@deprecated("Use PlayJsonMapperModule class instead", "2.9.4")
55-
sealed class PlayJsonModule(parserSettings: JsonParserSettings) extends PlayJsonMapperModule(parserSettings) {
56-
override def setupModule(context: SetupContext): Unit = super.setupModule(context)
57-
}
58-
59-
@deprecated("Use PlayJsonModule class instead", "2.6.11")
60-
object PlayJsonModule extends PlayJsonModule(JsonParserSettings())
61-
6254
sealed class PlayJsonMapperModule(jsonConfig: JsonConfig) extends SimpleModule("PlayJson", Version.unknownVersion()) {
6355
override def setupModule(context: SetupContext): Unit = {
6456
context.addDeserializers(new PlayDeserializers(jsonConfig))

play-json/jvm/src/test/scala/play/api/libs/json/JsonSpec.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class JsonSpec extends org.specs2.mutable.Specification {
289289
}
290290

291291
"for BigDecimals" should {
292-
val parserSettings = JsonParserSettings.settings
292+
val parserSettings = JsonConfig.settings
293293

294294
// note: precision refers to `JacksonJson.BigDecimalLimits.DefaultMathContext.getPrecision`
295295
"maintain precision when parsing BigDecimals within precision limit" in {
@@ -379,7 +379,7 @@ class JsonSpec extends org.specs2.mutable.Specification {
379379
}
380380

381381
"success when not exceeding the scale limit for positive numbers" in {
382-
val withinScaleLimit = BigDecimal(2, parserSettings.bigDecimalParseSettings.scaleLimit - 1)
382+
val withinScaleLimit = BigDecimal(2, parserSettings.bigDecimalParseConfig.scaleLimit - 1)
383383
Json
384384
.parse(bigNumbersJson(bigDec = withinScaleLimit.toString))
385385
.as[BigNumbers]
@@ -388,7 +388,7 @@ class JsonSpec extends org.specs2.mutable.Specification {
388388
}
389389

390390
"success when not exceeding the scale limit for negative numbers" in {
391-
val withinScaleLimitNegative = BigDecimal(2, parserSettings.bigDecimalParseSettings.scaleLimit - 1).unary_-
391+
val withinScaleLimitNegative = BigDecimal(2, parserSettings.bigDecimalParseConfig.scaleLimit - 1).unary_-
392392
Json.parse(bigNumbersJson(bigDec = withinScaleLimitNegative.toString)).as[BigNumbers].bigDec.mustEqual {
393393
withinScaleLimitNegative
394394
}
@@ -413,15 +413,15 @@ class JsonSpec extends org.specs2.mutable.Specification {
413413
}
414414

415415
"fail when exceeding the scale limit for positive numbers" in {
416-
val exceedsScaleLimit = BigDecimal(2, parserSettings.bigDecimalParseSettings.scaleLimit + 1)
416+
val exceedsScaleLimit = BigDecimal(2, parserSettings.bigDecimalParseConfig.scaleLimit + 1)
417417
Json
418418
.parse(bigNumbersJson(bigDec = exceedsScaleLimit.toString))
419419
.as[BigNumbers]
420420
.must(throwA[IllegalArgumentException])
421421
}
422422

423423
"fail when exceeding the scale limit for negative numbers" in {
424-
val exceedsScaleLimit = BigDecimal(2, parserSettings.bigDecimalParseSettings.scaleLimit + 1).unary_-
424+
val exceedsScaleLimit = BigDecimal(2, parserSettings.bigDecimalParseConfig.scaleLimit + 1).unary_-
425425
Json
426426
.parse(bigNumbersJson(bigDec = exceedsScaleLimit.toString))
427427
.as[BigNumbers]

play-json/jvm/src/test/scala/play/api/libs/json/ReadsSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ class ReadsSpec extends org.specs2.mutable.Specification {
706706
val DefaultReads = implicitly[Reads[BigDecimal]]
707707
import DefaultReads.reads
708708

709-
val settings = JsonParserSettings.settings.bigDecimalParseSettings
709+
val settings = JsonConfig.settings.bigDecimalParseConfig
710710

711711
val longNumberString =
712712
Iterator
@@ -738,7 +738,7 @@ class ReadsSpec extends org.specs2.mutable.Specification {
738738
val DefaultReads = implicitly[Reads[BigInt]]
739739
import DefaultReads.reads
740740

741-
val settings = JsonParserSettings.settings.bigDecimalParseSettings
741+
val settings = JsonConfig.settings.bigDecimalParseConfig
742742

743743
val longNumberString =
744744
Iterator

0 commit comments

Comments
 (0)