This is an automated email from the ASF dual-hosted git repository.
fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-http.git
The following commit(s) were added to refs/heads/main by this push:
new 4fdee6713 build with java 17 (#730)
4fdee6713 is described below
commit 4fdee6713a37bdd32938f37dd4e1ea849a0e2eec
Author: PJ Fanning <[email protected]>
AuthorDate: Tue Sep 9 10:15:04 2025 +0100
build with java 17 (#730)
* Update validate-and-test.yml
* updates
* more changes
* remove Java 8 specific code
* Update StringTools.scala
* use Java 17 in build
---
.github/workflows/headers.yml | 2 +-
.github/workflows/link-validator.yml | 4 ++--
.github/workflows/nightly.yml | 4 ++--
.github/workflows/publish.yml | 8 +++----
.github/workflows/validate-and-test.yml | 6 +++---
.scala-steward.conf | 3 ---
docs/src/main/paradox/client-side/http2.md | 3 +--
docs/src/main/paradox/server-side/http2.md | 3 +--
.../troubleshooting/unsupported-http-method-pri.md | 1 -
.../docs/http/javadsl/JacksonXmlExampleTest.java | 2 +-
.../src/test/java/docs/http/javadsl/JobRoutes.java | 8 +++----
.../test/java/docs/http/javadsl/ModelDocTest.java | 4 ++--
.../server/RejectionHandlerExamplesTest.java | 4 ++--
.../directives/BasicDirectivesExamplesTest.java | 14 ++++++------
.../directives/HeaderDirectivesExamplesTest.java | 16 +++++++-------
.../WebSocketDirectivesExamplesTest.java | 12 ++++-------
.../pekko/http/javadsl/model/HttpHeader.java | 4 ++--
.../http/shaded/com/twitter/hpack/HeaderField.java | 7 +++---
.../http/impl/engine/http2/Http2AlpnSupport.scala | 25 ++--------------------
.../apache/pekko/http/impl/util/StringTools.scala | 15 +++----------
.../server/directives/ExecutionDirectivesTest.java | 4 ++--
project/Common.scala | 16 +++-----------
project/Doc.scala | 6 ++----
project/plugins.sbt | 2 ++
24 files changed, 60 insertions(+), 113 deletions(-)
diff --git a/.github/workflows/headers.yml b/.github/workflows/headers.yml
index 97e84e03a..ac0659fad 100644
--- a/.github/workflows/headers.yml
+++ b/.github/workflows/headers.yml
@@ -34,7 +34,7 @@ jobs:
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 #
v4.7.1
with:
distribution: temurin
- java-version: 8
+ java-version: 17
- name: Install sbt
uses: sbt/setup-sbt@6c68d2fe8dfbc0a0534d70101baa2e0420e1a506 # v1.1.9
diff --git a/.github/workflows/link-validator.yml
b/.github/workflows/link-validator.yml
index 2e739649f..f6e7ab441 100644
--- a/.github/workflows/link-validator.yml
+++ b/.github/workflows/link-validator.yml
@@ -31,11 +31,11 @@ jobs:
git checkout scratch
# needs Java 8, see
https://github.com/apache/pekko-http/pull/204#discussion_r1265279415
- - name: Setup Java 8
+ - name: Setup Java 17
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 #
v4.7.1
with:
distribution: temurin
- java-version: 8
+ java-version: 17
- name: Install sbt
uses: sbt/setup-sbt@6c68d2fe8dfbc0a0534d70101baa2e0420e1a506 # v1.1.9
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 8f2789746..55c94aa06 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -22,8 +22,8 @@ jobs:
fail-fast: false
matrix:
SCALA_VERSION: [2.12, 2.13, 3]
- JDK: [8, 11, 17, 21]
- PEKKO_VERSION: ['1.0.x', '1.1.x', '1.2.x']
+ JDK: [17, 21]
+ PEKKO_VERSION: ['default']
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #
v4.2.2
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 92bd88601..84a011d1a 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -34,11 +34,11 @@ jobs:
fetch-depth: 0
fetch-tags: true
- - name: Set up JDK 8
+ - name: Set up JDK 17
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 #
v4.7.1
with:
distribution: temurin
- java-version: 8
+ java-version: 17
- name: Install sbt
uses: sbt/setup-sbt@6c68d2fe8dfbc0a0534d70101baa2e0420e1a506 # v1.1.9
@@ -67,11 +67,11 @@ jobs:
fetch-depth: 0
fetch-tags: true
- - name: Set up JDK 8
+ - name: Set up JDK 17
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 #
v4.7.1
with:
distribution: temurin
- java-version: 8
+ java-version: 17
- name: Install sbt
uses: sbt/setup-sbt@6c68d2fe8dfbc0a0534d70101baa2e0420e1a506 # v1.1.9
diff --git a/.github/workflows/validate-and-test.yml
b/.github/workflows/validate-and-test.yml
index b222b5cd8..05b1fe2bf 100644
--- a/.github/workflows/validate-and-test.yml
+++ b/.github/workflows/validate-and-test.yml
@@ -31,11 +31,11 @@ jobs:
fetch-depth: 0
fetch-tags: true
- - name: Set up Scala on JDK 8
+ - name: Set up Scala on JDK 17
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 #
v4.7.1
with:
distribution: temurin
- java-version: 8
+ java-version: 17
- name: Install sbt
uses: sbt/setup-sbt@6c68d2fe8dfbc0a0534d70101baa2e0420e1a506 # v1.1.9
@@ -71,7 +71,7 @@ jobs:
fail-fast: false
matrix:
SCALA_VERSION: [2.12, 2.13, 3.3]
- JDK: [8, 11]
+ JDK: [17]
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #
v4.2.2
diff --git a/.scala-steward.conf b/.scala-steward.conf
index ed54511c6..36539f4d4 100644
--- a/.scala-steward.conf
+++ b/.scala-steward.conf
@@ -15,9 +15,6 @@ updates.pin = [
{ groupId = "org.specs2", artifactId = "specs2-core", version = "4." },
# https://github.com/akka/akka-http/pull/4080#issuecomment-1074853622
{ groupId = "com.github.ben-manes.caffeine", artifactId = "caffeine",
version = "2.9." },
- # Pin sbt-paradox to v0.9.x because 0.10.x needs JDK 11
- { groupId = "com.lightbend.paradox", artifactId =
"sbt-paradox-project-info", version = "0.9." },
- { groupId = "com.lightbend.paradox", artifactId = "sbt-paradox", version =
"0.9." }
# Scala 3.3 is a LTS
{ groupId = "org.scala-lang", artifactId = "scala3-library", version =
"3.3." }
]
diff --git a/docs/src/main/paradox/client-side/http2.md
b/docs/src/main/paradox/client-side/http2.md
index f14f384e2..59490bca0 100644
--- a/docs/src/main/paradox/client-side/http2.md
+++ b/docs/src/main/paradox/client-side/http2.md
@@ -34,8 +34,7 @@ Java
:
@@snip[Http2Test.java](/docs/src/test/java/docs/http/javadsl/Http2Test.java) {
#http2Client }
HTTP/2 over TLS needs [Application-Layer Protocol Negotiation
(ALPN)](https://en.wikipedia.org/wiki/Application-Layer_Protocol_Negotiation)
-to negotiate whether both client and server support HTTP/2. The JVM provides
ALPN support starting from JDK 8u252.
-Make sure to use at least that version.
+to negotiate whether both client and server support HTTP/2.
Apache Pekko HTTP does not currently support protocol negotiation to fall back
to HTTP/1.1 for this API. When the server does not support HTTP/2, the stream
will fail.
### h2c with prior knowledge
diff --git a/docs/src/main/paradox/server-side/http2.md
b/docs/src/main/paradox/server-side/http2.md
index b80894bc0..28d904982 100644
--- a/docs/src/main/paradox/server-side/http2.md
+++ b/docs/src/main/paradox/server-side/http2.md
@@ -32,8 +32,7 @@ Note that currently only `newServerAt(...).bind` and
`newServerAt(...).bindSync`
support HTTP/2 but not `bindFlow` or `connectionSource(): Source`.
HTTP/2 over TLS needs [Application-Layer Protocol Negotiation
(ALPN)](https://en.wikipedia.org/wiki/Application-Layer_Protocol_Negotiation)
-to negotiate whether both client and server support HTTP/2. The JVM provides
ALPN support starting from JDK 8u252.
-Make sure to use at least that version.
+to negotiate whether both client and server support HTTP/2.
### HTTP/2 without HTTPS
diff --git
a/docs/src/main/paradox/troubleshooting/unsupported-http-method-pri.md
b/docs/src/main/paradox/troubleshooting/unsupported-http-method-pri.md
index e96764f67..6afb97467 100644
--- a/docs/src/main/paradox/troubleshooting/unsupported-http-method-pri.md
+++ b/docs/src/main/paradox/troubleshooting/unsupported-http-method-pri.md
@@ -8,5 +8,4 @@ This indicates that an HTTP/2 request was received, but the
server was not
correctly set up to handle those. You may have to:
* Make sure the @ref[`pekko.http.server.preview.enable-http2`
option](../server-side/http2.md#enable-http-2-support) is enabled
-* Make sure you are running @ref[at least JDK version
8u252](../server-side/http2.md)
* Make sure you are not using @apidoc[Http().bindAndHandle()](Http$) or
@apidoc[Http().newServerAt().bindFlow()](ServerBuilder), but
@apidoc[Http().newServerAt().bind()](ServerBuilder).
diff --git a/docs/src/test/java/docs/http/javadsl/JacksonXmlExampleTest.java
b/docs/src/test/java/docs/http/javadsl/JacksonXmlExampleTest.java
index 0a0285061..b7e5a8f70 100644
--- a/docs/src/test/java/docs/http/javadsl/JacksonXmlExampleTest.java
+++ b/docs/src/test/java/docs/http/javadsl/JacksonXmlExampleTest.java
@@ -114,7 +114,7 @@ public class JacksonXmlExampleTest extends JUnitRouteTest {
}
public boolean equals(Object other) {
- Point that = other instanceof Point ? (Point) other : null;
+ Point that = other instanceof Point point ? point : null;
return that != null && that.x == this.x && that.y == this.y;
}
}
diff --git a/docs/src/test/java/docs/http/javadsl/JobRoutes.java
b/docs/src/test/java/docs/http/javadsl/JobRoutes.java
index e8ce24311..0ee6f1e25 100644
--- a/docs/src/test/java/docs/http/javadsl/JobRoutes.java
+++ b/docs/src/test/java/docs/http/javadsl/JobRoutes.java
@@ -104,10 +104,10 @@ public class JobRoutes {
CompletionStage<JobRepository.Response> stage) {
return stage.thenApply(
response -> {
- if (response instanceof JobRepository.OK) {
- return (JobRepository.OK) response;
- } else if (response instanceof JobRepository.KO) {
- throw new IllegalStateException(((JobRepository.KO)
response).reason);
+ if (response instanceof JobRepository.OK ok) {
+ return ok;
+ } else if (response instanceof JobRepository.KO ko) {
+ throw new IllegalStateException(ko.reason);
} else {
throw new IllegalStateException("Invalid response");
}
diff --git a/docs/src/test/java/docs/http/javadsl/ModelDocTest.java
b/docs/src/test/java/docs/http/javadsl/ModelDocTest.java
index fad7b24da..e9a9d6f9b 100644
--- a/docs/src/test/java/docs/http/javadsl/ModelDocTest.java
+++ b/docs/src/test/java/docs/http/javadsl/ModelDocTest.java
@@ -91,8 +91,8 @@ public class ModelDocTest {
// a method that extracts basic HTTP credentials from a request
private Optional<BasicHttpCredentials> getCredentialsOfRequest(HttpRequest
request) {
Optional<Authorization> auth = request.getHeader(Authorization.class);
- if (auth.isPresent() && auth.get().credentials() instanceof
BasicHttpCredentials)
- return Optional.of((BasicHttpCredentials) auth.get().credentials());
+ if (auth.isPresent() && auth.get().credentials() instanceof
BasicHttpCredentials basicHttpCredentials)
+ return Optional.of(basicHttpCredentials);
else return Optional.empty();
}
// #headers
diff --git
a/docs/src/test/java/docs/http/javadsl/server/RejectionHandlerExamplesTest.java
b/docs/src/test/java/docs/http/javadsl/server/RejectionHandlerExamplesTest.java
index 4e1b1696e..9b9df8022 100644
---
a/docs/src/test/java/docs/http/javadsl/server/RejectionHandlerExamplesTest.java
+++
b/docs/src/test/java/docs/http/javadsl/server/RejectionHandlerExamplesTest.java
@@ -117,11 +117,11 @@ public class RejectionHandlerExamplesTest extends
JUnitRouteTest {
RejectionHandler.defaultHandler()
.mapRejectionResponse(
response -> {
- if (response.entity() instanceof HttpEntity.Strict) {
+ if (response.entity() instanceof HttpEntity.Strict entity) {
// since all Pekko default rejection responses are Strict
this will handle all
// rejections
String message =
- ((HttpEntity.Strict) response.entity())
+ entity
.getData()
.utf8String()
.replaceAll("\"", "\\\"");
diff --git
a/docs/src/test/java/docs/http/javadsl/server/directives/BasicDirectivesExamplesTest.java
b/docs/src/test/java/docs/http/javadsl/server/directives/BasicDirectivesExamplesTest.java
index 01d6b2c3c..5b8656a14 100644
---
a/docs/src/test/java/docs/http/javadsl/server/directives/BasicDirectivesExamplesTest.java
+++
b/docs/src/test/java/docs/http/javadsl/server/directives/BasicDirectivesExamplesTest.java
@@ -531,8 +531,8 @@ public class BasicDirectivesExamplesTest extends
JUnitRouteTest {
final Route route =
mapRouteResult(
r -> {
- if (r instanceof Complete) {
- final HttpResponse response = ((Complete) r).getResponse();
+ if (r instanceof Complete complete) {
+ final HttpResponse response = complete.getResponse();
return RouteResults.complete(response.withStatus(200));
} else {
return r;
@@ -563,8 +563,8 @@ public class BasicDirectivesExamplesTest extends
JUnitRouteTest {
})
.thenApply(
rr -> {
- if (rr instanceof Complete) {
- final HttpResponse res = ((Complete)
rr).getResponse();
+ if (rr instanceof Complete complete) {
+ final HttpResponse res = complete.getResponse();
return RouteResults.complete(
res.addHeader(
Server.create(ProductVersion.create("MyServer", "1.0"))));
@@ -587,8 +587,7 @@ public class BasicDirectivesExamplesTest extends
JUnitRouteTest {
// #mapResponseEntity
final Function<ResponseEntity, ResponseEntity> prefixEntity =
entity -> {
- if (entity instanceof HttpEntity.Strict) {
- final HttpEntity.Strict strict = (HttpEntity.Strict) entity;
+ if (entity instanceof HttpEntity.Strict strict) {
return HttpEntities.create(
strict.getContentType(),
ByteString.fromString("test").concat(strict.getData()));
} else {
@@ -1172,8 +1171,7 @@ public class BasicDirectivesExamplesTest extends
JUnitRouteTest {
() ->
extractRequest(
req -> {
- if (req.entity() instanceof HttpEntity.Strict) {
- final HttpEntity.Strict strict = (HttpEntity.Strict)
req.entity();
+ if (req.entity() instanceof HttpEntity.Strict strict) {
return complete(
"Request entity is strict, data=" +
strict.getData().utf8String());
} else {
diff --git
a/docs/src/test/java/docs/http/javadsl/server/directives/HeaderDirectivesExamplesTest.java
b/docs/src/test/java/docs/http/javadsl/server/directives/HeaderDirectivesExamplesTest.java
index 514384d93..b0ae37677 100644
---
a/docs/src/test/java/docs/http/javadsl/server/directives/HeaderDirectivesExamplesTest.java
+++
b/docs/src/test/java/docs/http/javadsl/server/directives/HeaderDirectivesExamplesTest.java
@@ -93,8 +93,8 @@ public class HeaderDirectivesExamplesTest extends
JUnitRouteTest {
// #headerValue
final Function<HttpHeader, Optional<Host>> extractHostPort =
header -> {
- if (header instanceof Host) {
- return Optional.of((Host) header);
+ if (header instanceof Host host) {
+ return Optional.of(host);
} else {
return Optional.empty();
}
@@ -189,11 +189,11 @@ public class HeaderDirectivesExamplesTest extends
JUnitRouteTest {
new JavaPartialFunction<HttpHeader, Integer>() {
@Override
public Integer apply(HttpHeader x, boolean isCheck) throws Exception
{
- if (x instanceof Host) {
+ if (x instanceof Host host) {
if (isCheck) {
return null;
} else {
- return ((Host) x).port();
+ return host.port();
}
} else {
throw noMatch();
@@ -220,8 +220,8 @@ public class HeaderDirectivesExamplesTest extends
JUnitRouteTest {
// #optionalHeaderValue
final Function<HttpHeader, Optional<Integer>> extractHostPort =
header -> {
- if (header instanceof Host) {
- return Optional.of(((Host) header).port());
+ if (header instanceof Host host) {
+ return Optional.of(host.port());
} else {
return Optional.empty();
}
@@ -306,11 +306,11 @@ public class HeaderDirectivesExamplesTest extends
JUnitRouteTest {
new JavaPartialFunction<HttpHeader, Integer>() {
@Override
public Integer apply(HttpHeader x, boolean isCheck) throws Exception
{
- if (x instanceof Host) {
+ if (x instanceof Host host) {
if (isCheck) {
return null;
} else {
- return ((Host) x).port();
+ return host.port();
}
} else {
throw noMatch();
diff --git
a/docs/src/test/java/docs/http/javadsl/server/directives/WebSocketDirectivesExamplesTest.java
b/docs/src/test/java/docs/http/javadsl/server/directives/WebSocketDirectivesExamplesTest.java
index 013ff3b36..3bfa74ca4 100644
---
a/docs/src/test/java/docs/http/javadsl/server/directives/WebSocketDirectivesExamplesTest.java
+++
b/docs/src/test/java/docs/http/javadsl/server/directives/WebSocketDirectivesExamplesTest.java
@@ -59,16 +59,14 @@ public class WebSocketDirectivesExamplesTest extends
JUnitRouteTest {
Flow.of(Message.class)
.mapConcat(
msg -> {
- if (msg instanceof TextMessage) {
- final TextMessage tm = (TextMessage) msg;
+ if (msg instanceof TextMessage tm) {
final TextMessage ret =
TextMessage.create(
Source.single("Hello ")
.concat(tm.getStreamedText())
.concat(Source.single("!")));
return Collections.singletonList(ret);
- } else if (msg instanceof BinaryMessage) {
- final BinaryMessage bm = (BinaryMessage) msg;
+ } else if (msg instanceof BinaryMessage bm) {
bm.getStreamedData().runWith(Sink.ignore(),
materializer());
return Collections.emptyList();
} else {
@@ -108,16 +106,14 @@ public class WebSocketDirectivesExamplesTest extends
JUnitRouteTest {
Flow.of(Message.class)
.mapConcat(
msg -> {
- if (msg instanceof TextMessage) {
- final TextMessage tm = (TextMessage) msg;
+ if (msg instanceof TextMessage tm) {
final TextMessage ret =
TextMessage.create(
Source.single("Hello ")
.concat(tm.getStreamedText())
.concat(Source.single("!")));
return Collections.singletonList(ret);
- } else if (msg instanceof BinaryMessage) {
- final BinaryMessage bm = (BinaryMessage) msg;
+ } else if (msg instanceof BinaryMessage bm) {
bm.getStreamedData().runWith(Sink.ignore(),
materializer());
return Collections.emptyList();
} else {
diff --git
a/http-core/src/main/java/org/apache/pekko/http/javadsl/model/HttpHeader.java
b/http-core/src/main/java/org/apache/pekko/http/javadsl/model/HttpHeader.java
index 0bda92f55..f0d35f53d 100644
---
a/http-core/src/main/java/org/apache/pekko/http/javadsl/model/HttpHeader.java
+++
b/http-core/src/main/java/org/apache/pekko/http/javadsl/model/HttpHeader.java
@@ -56,8 +56,8 @@ public abstract class HttpHeader {
value,
org.apache.pekko.http.impl.model.parser.HeaderParser$.MODULE$.DefaultSettings());
- if (result instanceof
org.apache.pekko.http.scaladsl.model.HttpHeader$ParsingResult$Ok) {
- return
((org.apache.pekko.http.scaladsl.model.HttpHeader$ParsingResult$Ok)
result).header();
+ if (result instanceof
org.apache.pekko.http.scaladsl.model.HttpHeader$ParsingResult$Ok ok) {
+ return ok.header();
} else {
throw new IllegalHeaderException(
((org.apache.pekko.http.scaladsl.model.HttpHeader$ParsingResult$Error)
result).error());
diff --git
a/http-core/src/main/java/org/apache/pekko/http/shaded/com/twitter/hpack/HeaderField.java
b/http-core/src/main/java/org/apache/pekko/http/shaded/com/twitter/hpack/HeaderField.java
index 3f5cacdbc..c6f9c0122 100644
---
a/http-core/src/main/java/org/apache/pekko/http/shaded/com/twitter/hpack/HeaderField.java
+++
b/http-core/src/main/java/org/apache/pekko/http/shaded/com/twitter/hpack/HeaderField.java
@@ -82,11 +82,10 @@ class HeaderField implements Comparable<HeaderField> {
if (obj == this) {
return true;
}
- if (!(obj instanceof HeaderField)) {
- return false;
+ if (obj instanceof HeaderField other) {
+ return name.equals(other.name) && value.equals(other.value);
}
- HeaderField other = (HeaderField) obj;
- return name.equals(other.name) && value.equals(other.value);
+ return false;
}
@Override
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2AlpnSupport.scala
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2AlpnSupport.scala
index 542937603..e8cecbfc8 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2AlpnSupport.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2AlpnSupport.scala
@@ -18,11 +18,9 @@ import pekko.annotation.InternalApi
import pekko.http.impl.engine.http2.Http2AlpnSupport.{ H2, HTTP11 }
import pekko.stream.TLSProtocol.NegotiateNewSession
import pekko.stream.impl.io.TlsUtils
-import pekko.util.JavaVersion
import java.{ util => ju }
import javax.net.ssl.SSLEngine
-import scala.util.Try
/**
* INTERNAL API
@@ -39,29 +37,10 @@ private[http] object Http2AlpnSupport {
* Enables server-side Http/2 ALPN support for the given engine.
*/
def enableForServer(engine: SSLEngine, setChosenProtocol: String => Unit):
SSLEngine =
- if (isAlpnSupportedByJDK) Http2JDKAlpnSupport.jdkAlpnSupport(engine,
setChosenProtocol)
- else throw new RuntimeException(
- s"Need to run on a JVM >= 8u252 for ALPN support needed for HTTP/2.
Running on ${sys.props("java.version")}")
+ Http2JDKAlpnSupport.jdkAlpnSupport(engine, setChosenProtocol)
def clientSetApplicationProtocols(engine: SSLEngine, protocols:
Array[String]): Unit =
- if (isAlpnSupportedByJDK)
Http2JDKAlpnSupport.clientSetApplicationProtocols(engine, protocols)
- else throw new RuntimeException(
- s"Need to run on a JVM >= 8u252 for ALPN support needed for HTTP/2.
Running on ${sys.props("java.version")}")
-
- private def isAlpnSupportedByJDK: Boolean =
- // ALPN is supported starting with JDK 9
- JavaVersion.majorVersion >= 9 ||
- (classOf[SSLEngine].getMethods.exists(_.getName ==
"setHandshakeApplicationProtocolSelector")
- && {
- // This method only exists in the jetty-alpn provided implementation. If
it exists an old version of the jetty-alpn-agent is active which is not
supported
- // on JDK>= 8u252. When running on such a JVM, you can either just
remove the agent or (if you want to support older JVMs with the same command
line),
- // use jetty-alpn-agent >= 2.0.10
- val jettyAlpnClassesAvailable =
Try(Class.forName("sun.security.ssl.ALPNExtension")).toOption.exists(
- _.getDeclaredMethods.exists(_.getName == "init"))
- if (jettyAlpnClassesAvailable) throw new RuntimeException(
- "On JDK >= 8u252 you need to either remove jetty-alpn-agent or use
version 2.0.10 (which is a noop)")
- else true
- })
+ Http2JDKAlpnSupport.clientSetApplicationProtocols(engine, protocols)
}
/**
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/impl/util/StringTools.scala
b/http-core/src/main/scala/org/apache/pekko/http/impl/util/StringTools.scala
index 1d371107d..2c652c132 100644
--- a/http-core/src/main/scala/org/apache/pekko/http/impl/util/StringTools.scala
+++ b/http-core/src/main/scala/org/apache/pekko/http/impl/util/StringTools.scala
@@ -15,7 +15,6 @@ package org.apache.pekko.http.impl.util
import org.apache.pekko
import pekko.annotation.InternalApi
-import pekko.util.{ JavaVersion, Unsafe }
import scala.annotation.nowarn
@@ -24,8 +23,6 @@ import scala.annotation.nowarn
*/
@InternalApi
private[http] object StringTools {
- private val avoidUnsafe = JavaVersion.majorVersion >= 17
-
@nowarn("msg=deprecated")
def asciiStringFromBytes(bytes: Array[Byte]): String =
// Deprecated constructor but also (unfortunately) the fastest way to
convert a ASCII encoded byte array
@@ -33,14 +30,8 @@ private[http] object StringTools {
new String(bytes, 0)
def asciiStringBytes(string: String): Array[Byte] = {
- if (avoidUnsafe) {
- // this is as fast as Unsafe.copyUSAsciiStrToBytes for recent JDK
versions
- // and avoids the use of deprecated Unsafe methods
- string.getBytes(java.nio.charset.StandardCharsets.US_ASCII)
- } else {
- val bytes = new Array[Byte](string.length)
- Unsafe.copyUSAsciiStrToBytes(string, bytes)
- bytes
- }
+ // this is as fast as Unsafe.copyUSAsciiStrToBytes for recent JDK versions
+ // and avoids the use of deprecated Unsafe methods
+ string.getBytes(java.nio.charset.StandardCharsets.US_ASCII)
}
}
diff --git
a/http-tests/src/test/java/org/apache/pekko/http/javadsl/server/directives/ExecutionDirectivesTest.java
b/http-tests/src/test/java/org/apache/pekko/http/javadsl/server/directives/ExecutionDirectivesTest.java
index 14440f97a..c23c9b02e 100644
---
a/http-tests/src/test/java/org/apache/pekko/http/javadsl/server/directives/ExecutionDirectivesTest.java
+++
b/http-tests/src/test/java/org/apache/pekko/http/javadsl/server/directives/ExecutionDirectivesTest.java
@@ -130,9 +130,9 @@ public class ExecutionDirectivesTest extends JUnitRouteTest
{
RejectionHandler.defaultHandler()
.mapRejectionResponse(
response -> {
- if (response.entity() instanceof HttpEntity.Strict) {
+ if (response.entity() instanceof HttpEntity.Strict entity) {
String message =
- ((HttpEntity.Strict) response.entity())
+ entity
.getData()
.utf8String()
.replaceAll("\"", "\\\"");
diff --git a/project/Common.scala b/project/Common.scala
index 260f012ec..da0762a30 100644
--- a/project/Common.scala
+++ b/project/Common.scala
@@ -31,7 +31,7 @@ object Common extends AutoPlugin {
"-Wconf:msg=is deprecated \\(since 2\\.13\\.:s",
"-Wconf:msg=reached max recursion depth:s",
"-Wconf:msg=Prefer the Scala annotation over Java's `@Deprecated`:s",
- "-release:8"),
+ "-release:" + javacTarget),
scalacOptions ++= onlyOnScala2(Seq(
"-Xlint",
// Silence deprecation notices for changes introduced in Scala 2.12
@@ -43,21 +43,11 @@ object Common extends AutoPlugin {
"-Wconf:cat=other-match-analysis&msg=match may not be
exhaustive:s")).value,
scalacOptions ++= onlyOnScala3(Seq("-Wconf:cat=deprecation:s")).value,
javacOptions ++=
- Seq("-encoding", "UTF-8") ++ onlyOnJdk8("-source", "1.8") ++
onlyAfterJdk8("--release", "8"),
- // restrict to 'compile' scope because otherwise it is also passed to
- // javadoc and -target is not valid there.
- // https://github.com/sbt/sbt/issues/1785
- Compile / compile / javacOptions ++=
- // From jdk9 onwards this is covered by the '-release' flag above
- onlyOnJdk8("-target", "1.8"),
+ Seq("-encoding", "UTF-8", "--release", javacTarget),
mimaReportSignatureProblems := true,
Global / parallelExecution :=
sys.props.getOrElse("pekko.http.parallelExecution", "true") != "false")
- val specificationVersion: String = sys.props("java.specification.version")
- def isJdk8: Boolean =
-
VersionNumber(specificationVersion).matchesSemVer(SemanticSelector(s"=1.8"))
- def onlyOnJdk8[T](values: T*): Seq[T] = if (isJdk8) values else Seq.empty[T]
- def onlyAfterJdk8[T](values: T*): Seq[T] = if (isJdk8) Seq.empty[T] else
values
+ val javacTarget: String = "17"
def onlyAfterScala212[T](values: Seq[T]): Def.Initialize[Seq[T]] =
Def.setting {
if (scalaMinorVersion.value >= 12) values else Seq.empty[T]
}
diff --git a/project/Doc.scala b/project/Doc.scala
index b6113ec94..d68af10a1 100644
--- a/project/Doc.scala
+++ b/project/Doc.scala
@@ -19,7 +19,6 @@ import sbtunidoc.BaseUnidocPlugin.autoImport.{ unidoc,
unidocProjectFilter }
import sbtunidoc.JavaUnidocPlugin.autoImport.JavaUnidoc
import sbtunidoc.ScalaUnidocPlugin.autoImport.ScalaUnidoc
import sbtunidoc.GenJavadocPlugin.autoImport.unidocGenjavadocVersion
-import Common.isJdk8
object Doc {
val BinVer = """(\d+\.\d+)\.\d+""".r
@@ -151,9 +150,8 @@ object UnidocRoot extends AutoPlugin {
ScalaUnidocPlugin &&
CliOptions.genjavadocEnabled.ifTrue(JavaUnidocPlugin).getOrElse(plugins.JvmPlugin)
val pekkoSettings = UnidocRoot.CliOptions.genjavadocEnabled.ifTrue(Seq(
- JavaUnidoc / unidoc / javacOptions ++= (
- if (isJdk8) Seq("-Xdoclint:none")
- else Seq("-Xdoclint:none", "--ignore-source-errors")),
+ JavaUnidoc / unidoc / javacOptions ++=
+ Seq("-Xdoclint:none", "--ignore-source-errors"),
// genjavadoc needs to generate synthetic methods since the java code uses
them
// fails since Akka HTTP 10.0.11 disabled to get the doc gen to pass, see
#1584
// scalacOptions += "-P:genjavadoc:suppressSynthetic=false",
diff --git a/project/plugins.sbt b/project/plugins.sbt
index 0d33b0863..e15dac55d 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -22,6 +22,8 @@ addSbtPlugin("com.lightbend.sbt" % "sbt-bill-of-materials" %
"1.0.2")
addSbtPlugin("com.github.sbt" % "sbt-license-report" % "1.7.0")
addSbtPlugin("org.apache.pekko" % "pekko-sbt-paradox" % "1.0.1")
+addSbtPlugin("com.lightbend.paradox" % "sbt-paradox-theme" % "0.10.7")
+addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.10.7")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0")
addSbtPlugin("net.bzzt" % "sbt-reproducible-builds" % "0.32")
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]