From 856bf181e718d9cd498345c15f477b8177fb1605 Mon Sep 17 00:00:00 2001 From: Kevin Risden Date: Wed, 29 Mar 2023 16:29:02 -0400 Subject: [PATCH] JDK 20 --- .github/workflows/bin-solr-test.yml | 8 ++++---- .github/workflows/docker-test.yml | 8 ++++---- .github/workflows/gradle-precommit.yml | 10 +++++----- .github/workflows/solrj-test.yml | 8 ++++---- .../org/apache/solr/cloud/PackageManagerCLITest.java | 7 ++++++- .../solr/client/solrj/embedded/JettyWebappTest.java | 6 +++++- .../java/org/apache/solr/embedded/JettySolrRunner.java | 9 ++++++++- 7 files changed, 36 insertions(+), 20 deletions(-) diff --git a/.github/workflows/bin-solr-test.yml b/.github/workflows/bin-solr-test.yml index d8a6076da64..15817f84b18 100644 --- a/.github/workflows/bin-solr-test.yml +++ b/.github/workflows/bin-solr-test.yml @@ -17,12 +17,12 @@ jobs: steps: # Setup - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + - uses: actions/checkout@v3 + - name: Set up JDK 20 + uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 11 + java-version: 20 java-package: jdk - name: Grant execute permission for gradlew run: chmod +x gradlew diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index ddf6292d46f..69912ac8891 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -23,12 +23,12 @@ jobs: steps: # Setup - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + - uses: actions/checkout@v3 + - name: Set up JDK 20 + uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 11 + java-version: 20 java-package: jdk - name: Install ACL run: sudo apt-get install acl diff --git a/.github/workflows/gradle-precommit.yml b/.github/workflows/gradle-precommit.yml index 6cc1425db84..4248a994f7b 100644 --- a/.github/workflows/gradle-precommit.yml +++ b/.github/workflows/gradle-precommit.yml @@ -7,19 +7,19 @@ on: jobs: test: - name: gradle precommit w/ Java 11 + name: gradle precommit w/ Java 20 runs-on: ubuntu-latest steps: # Setup - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + - name: Set up JDK 20 + uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 11 + java-version: 20 java-package: jdk - name: Grant execute permission for gradlew diff --git a/.github/workflows/solrj-test.yml b/.github/workflows/solrj-test.yml index 625ab7ee437..86ca7f40285 100644 --- a/.github/workflows/solrj-test.yml +++ b/.github/workflows/solrj-test.yml @@ -16,12 +16,12 @@ jobs: steps: # Setup - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + - uses: actions/checkout@v3 + - name: Set up JDK 20 + uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 11 + java-version: 20 java-package: jdk - name: Grant execute permission for gradlew run: chmod +x gradlew diff --git a/solr/core/src/test/org/apache/solr/cloud/PackageManagerCLITest.java b/solr/core/src/test/org/apache/solr/cloud/PackageManagerCLITest.java index b1e11c45a3c..bdb063d0742 100644 --- a/solr/core/src/test/org/apache/solr/cloud/PackageManagerCLITest.java +++ b/solr/core/src/test/org/apache/solr/cloud/PackageManagerCLITest.java @@ -18,6 +18,7 @@ package org.apache.solr.cloud; import java.lang.invoke.MethodHandles; +import java.nio.file.Path; import java.util.Arrays; import org.apache.solr.cli.PackageTool; import org.apache.solr.cli.SolrCLI; @@ -30,6 +31,7 @@ import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.ResourceHandler; +import org.eclipse.jetty.util.resource.Resource; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -242,7 +244,10 @@ public void start() throws Exception { server.setStopAtShutdown(true); ResourceHandler resourceHandler = new ResourceHandler(); - resourceHandler.setResourceBase(resourceDir); + + // Using just setResourceBase(".") means that Jetty calls toRealPath with NO_FOLLOW_LINKS + // in PathResource line 226. This invocation bypasses that check by using a URI instead. + resourceHandler.setBaseResource(Resource.newResource(Path.of(resourceDir).toRealPath().toUri())); resourceHandler.setDirectoriesListed(true); HandlerList handlers = new HandlerList(); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java index 61968db2e4d..668783e5acf 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java @@ -19,6 +19,7 @@ import java.io.File; import java.io.InputStream; import java.net.URL; +import java.nio.file.Path; import java.util.Locale; import java.util.Random; import org.apache.http.Header; @@ -35,6 +36,7 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.session.DefaultSessionIdManager; +import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.webapp.WebAppContext; /** @@ -62,7 +64,9 @@ public void setUp() throws Exception { // insecure: only use for tests!!!! server.setSessionIdManager( new DefaultSessionIdManager(server, new Random(random().nextLong()))); - new WebAppContext(server, path, "/solr"); + // Using just WebAppContext with path means that Jetty calls toRealPath with NO_FOLLOW_LINKS + // in PathResource line 226. This invocation bypasses that check by using a URI instead. + new WebAppContext(server, Resource.newResource(Path.of(path).toRealPath().toUri()), "/solr"); ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory()); connector.setIdleTimeout(1000 * 60 * 60); diff --git a/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java b/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java index 1130df5d7ce..f37260d78f5 100644 --- a/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java +++ b/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java @@ -94,6 +94,7 @@ import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.Source; import org.eclipse.jetty.util.component.LifeCycle; +import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.util.thread.ReservedThreadExecutor; @@ -373,7 +374,13 @@ private void init(int port) { // Initialize the servlets final ServletContextHandler root = new ServletContextHandler(server, "/solr", ServletContextHandler.SESSIONS); - root.setResourceBase("."); + try { + // Using just setResourceBase(".") means that Jetty calls toRealPath with NO_FOLLOW_LINKS + // in PathResource line 226. This invocation bypasses that check by using a URI instead. + root.setBaseResource(Resource.newResource(Path.of(".").toRealPath().toUri())); + } catch (IOException e) { + throw new RuntimeException("Unable to set Jetty resource base", e); + } server.addEventListener( new LifeCycle.Listener() {