The GitHub Actions job "Validate and test" on pekko-http.git/main has succeeded.
Run started by GitHub user pjfanning (triggered by pjfanning).

Head commit for run:
0d8bed1ad2f6a58da342ada14ce85171ba160883 / PJ Fanning 
<[email protected]>
chore: replace deprecated String constructor in StringTools (#1230)

Motivation:
StringTools.asciiStringFromBytes used the deprecated `new String(byte[], int)`
behind a @nowarn, justified by a comment saying it was "the fastest way to
convert a ASCII encoded byte array into a String without extra copying". That
was true on Java 8, where the alternative expanded the bytes into a char array.
Since JDK 9 and compact strings it is not, and this branch requires JDK 17.

The method is on the HTTP/2 HPACK decode path, so it is worth being sure the
replacement is neither a behaviour nor a performance change.

Modification:
Decode with ISO-8859-1, which maps every byte to the character of the same
value, exactly as the deprecated constructor did with hibyte 0. Not US-ASCII,
which would turn bytes above 0x7F into replacement characters; HPACK string
literals are opaque octets. Drops the @nowarn and the scala.annotation.nowarn
import, and reuses the ISO88591 constant already in this package.

Result:
No deprecated JDK API and no misleading comment, with identical behaviour.

Tests:
- New StringToolsSpec pins the byte to character mapping across the whole
  0x00 to 0xFF range, which is what would break if the charset were changed to
  US-ASCII later. It is a regression guard, not a failing-before test: this
  change is deliberately behaviour preserving
- Verified in jshell that the two forms produce equal Strings for all 256 byte
  values
- JMH, average time over sizes 12, 64 and 4096 bytes: 25.3 / 30.2 / 1260.2 ns
  for the deprecated form against 28.2 / 43.1 / 952.7 ns for ISO-8859-1, error
  bars overlapping at every size, so no measurable difference either way
- sbt "http-core / Test / testOnly 
org.apache.pekko.http.impl.util.StringToolsSpec" - 4 passed
- sbt http-core/mimaReportBinaryIssues - clean
- scalafmt --mode diff-ref=upstream/main - clean

References:
None - found while reviewing the code base against the JDK 17 baseline

Report URL: https://github.com/apache/pekko-http/actions/runs/33306440827

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to