Skip to content

Commit 9a0d983

Browse files
committed
Revert "Do not serialize version of Cookie for RFC 6265."
This reverts commit b37c986 for TCK compatibility Signed-off-by: Maxim Nesen <[email protected]>
1 parent 5bdf411 commit 9a0d983

File tree

9 files changed

+23
-309
lines changed

9 files changed

+23
-309
lines changed

core-common/src/main/java/org/glassfish/jersey/http/JerseyCookie.java

Lines changed: 0 additions & 76 deletions
This file was deleted.

core-common/src/main/java/org/glassfish/jersey/http/JerseyNewCookie.java

Lines changed: 0 additions & 91 deletions
This file was deleted.

core-common/src/main/java/org/glassfish/jersey/http/VersionOptional.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

core-common/src/main/java/org/glassfish/jersey/message/internal/CookieProvider.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2025 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -21,7 +21,6 @@
2121
import jakarta.inject.Singleton;
2222

2323
import org.glassfish.jersey.internal.LocalizationMessages;
24-
import org.glassfish.jersey.http.VersionOptional;
2524
import org.glassfish.jersey.spi.HeaderDelegateProvider;
2625

2726
import static org.glassfish.jersey.message.internal.Utils.throwIllegalArgumentExceptionIfNull;
@@ -47,15 +46,7 @@ public String toString(Cookie cookie) {
4746

4847
StringBuilder b = new StringBuilder();
4948

50-
boolean printVersion = false;
51-
if (cookie instanceof VersionOptional) {
52-
printVersion = ((VersionOptional) cookie).hasVersion();
53-
} else if (cookie.getVersion() == Cookie.DEFAULT_VERSION || cookie.getVersion() == VersionOptional.NETSCAPE_VERSION) {
54-
printVersion = true;
55-
}
56-
if (printVersion) {
57-
b.append("$Version=").append(cookie.getVersion()).append(';');
58-
}
49+
b.append("$Version=").append(cookie.getVersion()).append(';');
5950

6051
b.append(cookie.getName()).append('=');
6152
StringBuilderUtils.appendQuotedIfWhitespace(b, cookie.getValue());

core-common/src/main/java/org/glassfish/jersey/message/internal/CookiesParser.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import jakarta.ws.rs.core.NewCookie;
2929

3030
import org.glassfish.jersey.internal.LocalizationMessages;
31-
import org.glassfish.jersey.http.JerseyCookie;
32-
import org.glassfish.jersey.http.JerseyNewCookie;
3331

3432
/**
3533
* Cookies parser.
@@ -45,7 +43,7 @@ private static class MutableCookie {
4543

4644
String name;
4745
String value;
48-
Integer version = null;
46+
int version = Cookie.DEFAULT_VERSION;
4947
String path = null;
5048
String domain = null;
5149

@@ -55,14 +53,14 @@ public MutableCookie(String name, String value) {
5553
}
5654

5755
public Cookie getImmutableCookie() {
58-
return new JerseyCookie.Builder(name).version(version).value(value).path(path).domain(domain).build();
56+
return new Cookie(name, value, path, domain, version);
5957
}
6058
}
6159

6260
public static Map<String, Cookie> parseCookies(String header) {
6361
String bites[] = header.split("[;,]");
6462
Map<String, Cookie> cookies = new LinkedHashMap<String, Cookie>();
65-
Integer version = null;
63+
int version = 0;
6664
MutableCookie cookie = null;
6765
for (String bite : bites) {
6866
String crumbs[] = bite.split("=", 2);
@@ -125,7 +123,7 @@ private static class MutableNewCookie {
125123
String value = null;
126124
String path = null;
127125
String domain = null;
128-
Integer version = null;
126+
int version = Cookie.DEFAULT_VERSION;
129127
String comment = null;
130128
int maxAge = NewCookie.DEFAULT_MAX_AGE;
131129
boolean secure = false;
@@ -139,8 +137,7 @@ public MutableNewCookie(String name, String value) {
139137
}
140138

141139
public NewCookie getImmutableNewCookie() {
142-
return new JerseyNewCookie.Builder(name).version(version).value(value).path(path).domain(domain).comment(comment)
143-
.maxAge(maxAge).expiry(expiry).secure(secure).httpOnly(httpOnly).sameSite(sameSite).build();
140+
return new NewCookie(name, value, path, domain, version, comment, maxAge, expiry, secure, httpOnly, sameSite);
144141
}
145142
}
146143

core-common/src/main/java/org/glassfish/jersey/message/internal/NewCookieProvider.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2025 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2024 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,13 +16,11 @@
1616

1717
package org.glassfish.jersey.message.internal;
1818

19-
import jakarta.ws.rs.core.Cookie;
2019
import jakarta.ws.rs.core.NewCookie;
2120

2221
import jakarta.inject.Singleton;
2322

2423
import org.glassfish.jersey.internal.LocalizationMessages;
25-
import org.glassfish.jersey.http.VersionOptional;
2624
import org.glassfish.jersey.spi.HeaderDelegateProvider;
2725

2826
import java.util.Locale;
@@ -53,15 +51,7 @@ public String toString(final NewCookie cookie) {
5351
b.append(cookie.getName()).append('=');
5452
StringBuilderUtils.appendQuotedIfWhitespace(b, cookie.getValue());
5553

56-
boolean printVersion = false;
57-
if (cookie instanceof VersionOptional) {
58-
printVersion = ((VersionOptional) cookie).hasVersion();
59-
} else if (cookie.getVersion() == Cookie.DEFAULT_VERSION) {
60-
printVersion = true;
61-
}
62-
if (printVersion) {
63-
b.append(";").append("Version=").append(cookie.getVersion());
64-
}
54+
b.append(";").append("Version=").append(cookie.getVersion());
6555

6656
if (cookie.getComment() != null) {
6757
b.append(";Comment=");

0 commit comments

Comments
 (0)