Skip to content

Commit 9de1b5a

Browse files
committed
Add Scala 2.13.0-M4 to the CI.
Doing so prompts replacing the use a Scala `StringBuilder` by a `java.lang.StringBuilder`, because the Scala `StringBuilder` does not have a `.toInt` method anymore.
1 parent 6ec8ff6 commit 9de1b5a

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ scala:
1111
- 2.11.12
1212
- 2.12.6
1313
- 2.13.0-M3
14+
- 2.13.0-M4
1415
jdk:
1516
- oraclejdk8
1617
env:
@@ -20,6 +21,8 @@ matrix:
2021
exclude:
2122
- scala: 2.10.7
2223
env: SCALAJS_VERSION=1.0.0-M3
24+
- scala: 2.13.0-M4
25+
env: SCALAJS_VERSION=1.0.0-M3
2326

2427
cache:
2528
directories:

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sbtcrossproject.crossProject
22

3-
crossScalaVersions in ThisBuild := Seq("2.12.6", "2.11.12", "2.10.7", "2.13.0-M3")
3+
crossScalaVersions in ThisBuild := Seq("2.12.6", "2.11.12", "2.10.7", "2.13.0-M3", "2.13.0-M4")
44
scalaVersion in ThisBuild := (crossScalaVersions in ThisBuild).value.head
55

66
val commonSettings: Seq[Setting[_]] = Seq(

src/main/scala/java/util/logging/Formatter.scala

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package java.util.logging
22

3+
import java.lang.StringBuilder
4+
35
abstract class Formatter protected () {
46

57
def format(record: LogRecord): String
@@ -17,7 +19,7 @@ abstract class Formatter protected () {
1719
// Instead we'll do simple text replacement, very imperative
1820
var msgAccumulator = new StringBuilder()
1921
var inParam = false
20-
var paramInFlight:StringBuilder = null
22+
var paramInFlight: StringBuilder = null
2123
var substitutionFailure = false // track failure to break the loop
2224
var i = 0
2325

@@ -31,13 +33,13 @@ abstract class Formatter protected () {
3133
paramInFlight = new StringBuilder()
3234
} else if (inParam && currentChar != '}') {
3335
// accumulate the param
34-
paramInFlight += currentChar
36+
paramInFlight.append(currentChar)
3537
} else if (currentChar == '}') {
3638
// end of param, replace placeholder by value if possible
3739
inParam = false
3840
val (failed, replacement) = {
3941
try {
40-
val index = paramInFlight.toInt
42+
val index = paramInFlight.toString().toInt
4143
if (index >= 0 && index < params.length) {
4244
(false, params(index).toString)
4345
} else if (index > 0) {
@@ -55,15 +57,17 @@ abstract class Formatter protected () {
5557

5658
// The JVM will fail if e.g. there are bogus params and would not replace
5759
// any parameter
58-
if (failed) substitutionFailure = failed
59-
else msgAccumulator ++= replacement
60+
if (failed)
61+
substitutionFailure = failed
62+
else
63+
msgAccumulator.append(replacement)
6064
} else {
61-
msgAccumulator += currentChar
65+
msgAccumulator.append(currentChar)
6266
}
6367
}
6468

6569
if (substitutionFailure || inParam) msg
66-
else msgAccumulator.result()
70+
else msgAccumulator.toString()
6771
} else {
6872
msg
6973
}

0 commit comments

Comments
 (0)