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

Bjorncs/jetty 12 #33270

Merged
merged 2 commits into from
Feb 7, 2025
Merged
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
28 changes: 12 additions & 16 deletions application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,6 @@
</dependency>

<!-- START JETTY embedded jars -->
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-common</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-java-server</artifactId>
Expand All @@ -171,10 +163,22 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee9</groupId>
<artifactId>jetty-ee9-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>jetty-http2-common</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>jetty-http2-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
Expand All @@ -187,18 +191,10 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-jakarta-servlet-api</artifactId>
</dependency>
<!-- END JETTY embedded jars -->

<dependency>
Expand Down
3 changes: 2 additions & 1 deletion client/go/internal/admin/jvm/xx_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ func (opts *Options) AddCommonXX() {
// not common after all:
opts.AddOption("-XX:MaxJavaStackTraceDepth=1000000")
// Aid debugging for slight cost in performance
opts.AddOption("-XX:-OmitStackTraceInFastThrow")
// TODO(2025-02-06, bjorncs): Disabled due to https://github.com/jetty/jetty.project/issues/12775
//opts.AddOption("-XX:-OmitStackTraceInFastThrow")
}
17 changes: 10 additions & 7 deletions cloud-tenant-base-dependencies-enforcer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,15 @@
<include>org.bouncycastle:bcpkix-jdk18on:${bouncycastle.vespa.version}:test</include>
<include>org.bouncycastle:bcprov-jdk18on:${bouncycastle.vespa.version}:test</include>
<include>org.bouncycastle:bcutil-jdk18on:${bouncycastle.vespa.version}:test</include>
<include>org.eclipse.jetty.http2:http2-client:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty.http2:http2-common:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty.http2:http2-hpack:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty.http2:http2-http-client-transport:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty.http2:http2-server:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty.toolchain:jetty-jakarta-servlet-api:${jetty-servlet-api.vespa.version}:test</include>
<include>org.eclipse.jetty.ee9:jetty-ee9-nested:jar:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty.ee9:jetty-ee9-security:jar:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty.ee9:jetty-ee9-servlet:jar:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty.http2:jetty-http2-client-transport:jar:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty.http2:jetty-http2-client:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty.http2:jetty-http2-common:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty.http2:jetty-http2-hpack:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty.http2:jetty-http2-server:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty.toolchain:jetty-jakarta-servlet-api:jar:${jetty-servlet-api.vespa.version}:test</include>
<include>org.eclipse.jetty:jetty-alpn-client:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty:jetty-alpn-java-client:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty:jetty-alpn-java-server:${jetty.vespa.version}:test</include>
Expand All @@ -190,7 +193,7 @@
<include>org.eclipse.jetty:jetty-jmx:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty:jetty-security:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty:jetty-server:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty:jetty-servlet:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty:jetty-session:jar:${jetty.vespa.version}:test</include>
<include>org.eclipse.jetty:jetty-util:${jetty.vespa.version}:test</include>

<include>org.hamcrest:hamcrest:${hamcrest.vespa.version}:test</include>
Expand Down
36 changes: 16 additions & 20 deletions container-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@

<!-- START JETTY embedded jars -->
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-common</artifactId>
<!-- Required for JDK9ServerALPNProcessor through ServiceLoader API -->
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-java-server</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -155,8 +156,8 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-server</artifactId>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-server</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -165,9 +166,8 @@
</exclusions>
</dependency>
<dependency>
<!-- Required for JDK9ServerALPNProcessor through ServiceLoader API -->
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-java-server</artifactId>
<artifactId>jetty-client</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -176,8 +176,8 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-server</artifactId>
<groupId>org.eclipse.jetty.ee9</groupId>
<artifactId>jetty-ee9-servlet</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -187,7 +187,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
<artifactId>jetty-http</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -196,8 +196,8 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>jetty-http2-common</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -206,8 +206,8 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>jetty-http2-server</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -217,7 +217,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
<artifactId>jetty-io</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -227,7 +227,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<artifactId>jetty-jmx</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -237,7 +237,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<artifactId>jetty-server</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -255,10 +255,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-jakarta-servlet-api</artifactId>
</dependency>
<!-- END JETTY embedded jars -->

<!-- PROVIDED scope -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.yolean.Exceptions;
import jakarta.servlet.http.Part;
import org.eclipse.jetty.server.MultiPartFormInputStream;
import org.eclipse.jetty.ee9.nested.MultiPartFormInputStream;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -16,6 +16,7 @@
*
* @author bjorncs
*/
// TODO(bjorncs, 2024-11-19): Remove dependency on Jakarta EE API
public class MultiPartFormParser {

private final MultiPartFormInputStream multipart;
Expand Down
62 changes: 31 additions & 31 deletions container-core/src/main/java/com/yahoo/jdisc/http/Cookie.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.http;

import org.eclipse.jetty.http.ComplianceViolation;
import org.eclipse.jetty.http.CookieCompliance;
import org.eclipse.jetty.http.CookieParser;
import org.eclipse.jetty.http.HttpCookie;
import org.eclipse.jetty.server.Cookies;
import org.eclipse.jetty.server.HttpCookieUtils;

import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -178,41 +181,38 @@ public static String toCookieHeader(Iterable<? extends Cookie> cookies) {
}

public static List<Cookie> fromCookieHeader(String headerVal) {
Cookies cookieCutter = new Cookies();
cookieCutter.addCookieField(headerVal);
return Arrays.stream(cookieCutter.getCookies())
.map(servletCookie -> {
Cookie cookie = new Cookie();
cookie.setName(servletCookie.getName());
cookie.setValue(servletCookie.getValue());
cookie.setPath(servletCookie.getPath());
cookie.setDomain(servletCookie.getDomain());
cookie.setMaxAge(servletCookie.getMaxAge(), TimeUnit.SECONDS);
cookie.setSecure(servletCookie.getSecure());
cookie.setHttpOnly(servletCookie.isHttpOnly());
return cookie;
})
.toList();
var cookies = new ArrayList<Cookie>();
var parser = CookieParser.newParser(
(name, value, version, domain, path, comment) -> {
var cookie = new Cookie();
cookie.setName(name);
cookie.setValue(value);
cookie.setDomain(domain);
cookie.setPath(path);
cookies.add(cookie);
},
CookieCompliance.RFC6265, ComplianceViolation.Listener.NOOP
);
parser.parseField(headerVal);
return List.copyOf(cookies);
}

public static List<String> toSetCookieHeaders(Iterable<? extends Cookie> cookies) {
return StreamSupport.stream(cookies.spliterator(), false)
.map(cookie ->
new org.eclipse.jetty.http.HttpCookie(
cookie.getName(),
cookie.getValue(),
cookie.getDomain(),
cookie.getPath(),
cookie.getMaxAge(TimeUnit.SECONDS),
cookie.isHttpOnly(),
cookie.isSecure(),
null, /* comment */
0, /* version */
Optional.ofNullable(cookie.getSameSite()).map(SameSite::jettySameSite).orElse(null)
).getRFC6265SetCookie())
.toList();
.map(c -> {
var builder = HttpCookie.build(c.getName(), c.getValue())
.domain(c.getDomain())
.path(c.getPath())
.maxAge(c.getMaxAge(TimeUnit.SECONDS))
.secure(c.isSecure())
.httpOnly(c.isHttpOnly());
if (c.getSameSite() != null) builder.sameSite(c.getSameSite().jettySameSite());
return HttpCookieUtils.getRFC6265SetCookie(builder.build());
}
).toList();
}


public static Cookie fromSetCookieHeader(String headerVal) {
return java.net.HttpCookie.parse(headerVal).stream()
.map(httpCookie -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ private HttpRequest(Request parent, URI uri, Method method, Version version) {
}
}

@SuppressWarnings("deprecation")
private static Map<String, List<String>> getUriQueryParameters(URI uri) {
if (uri.getRawQuery() == null) return Map.of();
MultiMap<String> params = new MultiMap<>();
UrlEncoded.decodeUtf8To(uri.getRawQuery(), params);
UrlEncoded.decodeUtf8To(uri.getRawQuery(), params); // deprecated
return Map.copyOf(params);
}

Expand Down
Loading
Loading