Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP JDK 20 #1505

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/bin-solr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/gradle-precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/solrj-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
Loading