Skip to content

Commit 25a3cb4

Browse files
authored
merge of the actual 2.x into the 3.0
2 parents 9ac4c9d + 21d14a9 commit 25a3cb4

File tree

54 files changed

+1747
-234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1747
-234
lines changed

NOTICE.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Notice for Jersey
1+
# Notice for Jersey
22
This content is produced and maintained by the Eclipse Jersey project.
33

44
* Project home: https://projects.eclipse.org/projects/ee4j.jersey
@@ -57,25 +57,25 @@ Bootstrap v3.3.7
5757
* Project: http://getbootstrap.com
5858
* Copyright: 2011-2016 Twitter, Inc
5959

60-
Google Guava Version 18.0
60+
Google Guava Version 33.3.0-jre
6161
* License: Apache License, 2.0
62-
* Copyright (C) 2009 The Guava Authors
62+
* Copyright (C) 2009, 2024 The Guava Authors
6363

64-
jakarta.inject Version: 1
64+
jakarta.inject Version: 2.0.1
6565
* License: Apache License, 2.0
66-
* Copyright (C) 2009 The JSR-330 Expert Group
66+
* Copyright (C) 2009, 2021 The JSR-330 Expert Group
6767

6868
Javassist Version 3.30.2-GA
6969
* License: Apache License, 2.0
7070
* Project: http://www.javassist.org/
7171
* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
7272

73-
Jackson JAX-RS Providers Version 2.17.1
73+
Jackson JAX-RS Providers Version 2.17.2
7474
* License: Apache License, 2.0
7575
* Project: https://github.com/FasterXML/jackson-jaxrs-providers
7676
* Copyright: (c) 2009-2024 FasterXML, LLC. All rights reserved unless otherwise indicated.
7777

78-
jQuery v1.12.4
78+
jQuery v3.7.1
7979
* License: jquery.org/license
8080
* Project: jquery.org
8181
* Copyright: (c) jQuery Foundation

core-client/src/main/java/org/glassfish/jersey/client/ClientProperties.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,34 @@ public final class ClientProperties {
240240
@PropertyAlias
241241
public static final String OUTBOUND_CONTENT_LENGTH_BUFFER = CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER_CLIENT;
242242

243+
/**
244+
* If {@code true} then disable configuration of Json Binding (JSR-367)
245+
* feature on client.
246+
* <p>
247+
* By default, Json Binding on client is automatically enabled if global
248+
* property
249+
* {@value org.glassfish.jersey.CommonProperties#JSON_BINDING_FEATURE_DISABLE}
250+
* is not disabled. If set then the client property value overrides the
251+
* global property value.
252+
* <p>
253+
* The default value is {@code false}.
254+
* </p>
255+
* <p>
256+
* The name of the configuration property is <tt>{@value}</tt>.
257+
* </p>
258+
* <p>This constant is an alias for {@link CommonProperties#JSON_BINDING_FEATURE_DISABLE_CLIENT}.</p>
259+
*
260+
* @see org.glassfish.jersey.CommonProperties#JSON_BINDING_FEATURE_DISABLE
261+
* @since 2.45
262+
*/
263+
@PropertyAlias
264+
public static final String JSON_BINDING_FEATURE_DISABLE = CommonProperties.JSON_BINDING_FEATURE_DISABLE_CLIENT;
265+
243266
/**
244267
* If {@code true} then disable configuration of Json Processing (JSR-353)
245268
* feature on client.
246269
* <p>
247-
* By default Json Processing on client is automatically enabled if global
270+
* By default, Json Processing on client is automatically enabled if global
248271
* property
249272
* {@value org.glassfish.jersey.CommonProperties#JSON_PROCESSING_FEATURE_DISABLE}
250273
* is not disabled. If set then the client property value overrides the
@@ -265,7 +288,7 @@ public final class ClientProperties {
265288
/**
266289
* If {@code true} then disable META-INF/services lookup on client.
267290
* <p>
268-
* By default Jersey looks up SPI implementations described by {@code META-INF/services/*} files.
291+
* By default, Jersey looks up SPI implementations described by {@code META-INF/services/*} files.
269292
* Then you can register appropriate provider classes by {@link jakarta.ws.rs.core.Application}.
270293
* </p>
271294
* <p>

core-client/src/main/java/org/glassfish/jersey/client/HttpUrlConnectorProvider.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
import java.net.Proxy;
2222
import java.net.URL;
2323
import java.util.Map;
24+
import java.util.concurrent.ConcurrentHashMap;
25+
import java.util.concurrent.locks.Lock;
26+
import java.util.concurrent.locks.ReentrantLock;
2427
import java.util.logging.Logger;
2528

2629
import jakarta.ws.rs.client.Client;
@@ -295,9 +298,26 @@ default HttpURLConnection getConnection(URL url, Proxy proxy) throws IOException
295298

296299
private static class DefaultConnectionFactory implements ConnectionFactory {
297300

301+
private final ConcurrentHashMap<URL, Lock> locks = new ConcurrentHashMap<>();
302+
298303
@Override
299304
public HttpURLConnection getConnection(final URL url) throws IOException {
300-
return (HttpURLConnection) url.openConnection();
305+
return connect(url, null);
306+
}
307+
308+
@Override
309+
public HttpURLConnection getConnection(URL url, Proxy proxy) throws IOException {
310+
return connect(url, proxy);
311+
}
312+
313+
private HttpURLConnection connect(URL url, Proxy proxy) throws IOException {
314+
Lock lock = locks.computeIfAbsent(url, u -> new ReentrantLock());
315+
lock.lock();
316+
try {
317+
return (proxy == null) ? (HttpURLConnection) url.openConnection() : (HttpURLConnection) url.openConnection(proxy);
318+
} finally {
319+
lock.unlock();
320+
}
301321
}
302322
}
303323

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
18+
package org.glassfish.jersey;
19+
20+
import jakarta.ws.rs.core.Application;
21+
22+
/**
23+
* Implementation of this interface is capable of returning {@link Application}.
24+
*/
25+
public interface ApplicationSupplier {
26+
/**
27+
* Get Application.
28+
*
29+
* @return Application.
30+
*/
31+
Application getApplication();
32+
33+
}

core-common/src/main/java/org/glassfish/jersey/CommonProperties.java

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public final class CommonProperties {
7171
/**
7272
* If {@code true} then disable feature auto discovery globally on client/server.
7373
* <p>
74-
* By default auto discovery is automatically enabled. The value of this property may be overridden by the client/server
74+
* By default, auto discovery is automatically enabled. The value of this property may be overridden by the client/server
7575
* variant of this property.
7676
* <p>
7777
* The default value is {@code false}.
@@ -98,10 +98,55 @@ public final class CommonProperties {
9898
*/
9999
public static final String FEATURE_AUTO_DISCOVERY_DISABLE_SERVER = "jersey.config.server.disableAutoDiscovery";
100100

101+
102+
/**
103+
* If {@code true} then disable configuration of Json Binding (JSR-367) feature.
104+
* <p>
105+
* By default, Json Binding is automatically enabled. The value of this property may be overridden by the client/server
106+
* variant of this property.
107+
* <p>
108+
* The default value is {@code false}.
109+
* </p>
110+
* <p>
111+
* The name of the configuration property is <tt>{@value}</tt>.
112+
* </p>
113+
* @since 2.45
114+
*/
115+
public static final String JSON_BINDING_FEATURE_DISABLE = "jersey.config.disableJsonBinding";
116+
117+
/**
118+
* Client-specific version of {@link CommonProperties#JSON_BINDING_FEATURE_DISABLE}.
119+
*
120+
* If present, it overrides the generic one for the client environment.
121+
* @since 2.45
122+
*/
123+
public static final String JSON_BINDING_FEATURE_DISABLE_CLIENT = "jersey.config.client.disableJsonBinding";
124+
125+
/**
126+
* Server-specific version of {@link CommonProperties#JSON_BINDING_FEATURE_DISABLE}.
127+
*
128+
* If present, it overrides the generic one for the server environment.
129+
* @since 2.45
130+
*/
131+
public static final String JSON_BINDING_FEATURE_DISABLE_SERVER = "jersey.config.server.disableJsonBinding";
132+
133+
/**
134+
* Disables configuration of Json Binding (JSR-367) feature for {@link jakarta.ws.rs.core.Application} subclasses whose
135+
* package names are specified as a value. The value is comma-separated string defining prefixes of the application
136+
* package names.
137+
* <p>
138+
* By default, Json Binding is automatically enabled.
139+
* <p>
140+
* The name of the configuration property is <tt>{@value}</tt>.
141+
* </p>
142+
* @since 2.45
143+
*/
144+
public static final String JSON_BINDING_FEATURE_DISABLE_APPLICATION = "jersey.config.application.disableJsonBinding";
145+
101146
/**
102147
* If {@code true} then disable configuration of Json Processing (JSR-353) feature.
103148
* <p>
104-
* By default Json Processing is automatically enabled. The value of this property may be overridden by the client/server
149+
* By default, Json Processing is automatically enabled. The value of this property may be overridden by the client/server
105150
* variant of this property.
106151
* <p>
107152
* The default value is {@code false}.
@@ -131,7 +176,7 @@ public final class CommonProperties {
131176
/**
132177
* If {@code true} then disable META-INF/services lookup globally on client/server.
133178
* <p>
134-
* By default Jersey looks up SPI implementations described by META-INF/services/* files.
179+
* By default, Jersey looks up SPI implementations described by META-INF/services/* files.
135180
* Then you can register appropriate provider classes by {@link jakarta.ws.rs.core.Application}.
136181
* </p>
137182
* <p>
@@ -164,7 +209,7 @@ public final class CommonProperties {
164209
/**
165210
* If {@code true} then disable configuration of MOXy Json feature.
166211
* <p>
167-
* By default MOXy Json is automatically enabled. The value of this property may be overridden by the client/server
212+
* By default, MOXy Json is automatically enabled. The value of this property may be overridden by the client/server
168213
* variant of this property.
169214
* <p>
170215
* The default value is {@code false}.

core-common/src/main/java/org/glassfish/jersey/internal/util/PropertiesHelper.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 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
@@ -389,6 +389,27 @@ public static boolean isProperty(final Object value) {
389389
}
390390
}
391391

392+
/**
393+
* Converts the property value to {@code boolean} and checks it is {@code true} or empty.
394+
* Returns {@code true} if the value is {@code true} or empty but not {@code null}.
395+
*
396+
* <p>
397+
* The rationale behind this is that system property {@code -Dprop=true} is the same as {@code -Dprop}.
398+
* The property {@code -Dprop=false} behaves as if the {@code -Dprop} is not set at all.
399+
* </p>
400+
*
401+
* @param value property value.
402+
* @return {@code boolean} property value or {@code true} if the property value is not set or {@code false} if the property
403+
* is otherwise not convertible.
404+
*/
405+
public static boolean isPropertyOrNotSet(final Object value) {
406+
if (value instanceof Boolean) {
407+
return Boolean.class.cast(value);
408+
} else {
409+
return value != null && ("".equals(value.toString()) || Boolean.parseBoolean(value.toString()));
410+
}
411+
}
412+
392413
/**
393414
* Faster replacement of {@code RuntimeType#name().toLowerCase(Locale.ROOT)}
394415
* @param runtimeType The runtime type to lower case

core-common/src/main/java/org/glassfish/jersey/internal/util/collection/Views.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2019 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 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
@@ -24,13 +24,12 @@
2424
import java.util.List;
2525
import java.util.ListIterator;
2626
import java.util.Map;
27+
import java.util.Objects;
2728
import java.util.Set;
2829
import java.util.function.Function;
2930
import java.util.function.Predicate;
3031
import java.util.stream.Collectors;
3132

32-
import static org.glassfish.jersey.internal.guava.Preconditions.checkNotNull;
33-
3433
/**
3534
* Collections utils, which provide transforming views for {@link List} and {@link Map}.
3635
*
@@ -197,8 +196,8 @@ public int size() {
197196
* @return union view of given sets.
198197
*/
199198
public static <E> Set<E> setUnionView(final Set<? extends E> set1, final Set<? extends E> set2) {
200-
checkNotNull(set1, "set1");
201-
checkNotNull(set2, "set2");
199+
Objects.requireNonNull(set1, "set1");
200+
Objects.requireNonNull(set2, "set2");
202201

203202
return new AbstractSet<E>() {
204203
@Override
@@ -220,18 +219,19 @@ private Set<E> getUnion(Set<? extends E> set1, Set<? extends E> set2) {
220219
}
221220

222221
/**
223-
* Create a view of a difference of provided sets.
222+
* Create a view of a difference of provided sets, i.e. the diff filters out from the first set the items included
223+
* in the second set.
224224
* <p>
225225
* View is updated whenever any of the provided set changes.
226226
*
227227
* @param set1 first set.
228228
* @param set2 second set.
229229
* @param <E> set item type.
230-
* @return union view of given sets.
230+
* @return view that is a difference of given sets.
231231
*/
232232
public static <E> Set<E> setDiffView(final Set<? extends E> set1, final Set<? extends E> set2) {
233-
checkNotNull(set1, "set1");
234-
checkNotNull(set2, "set2");
233+
Objects.requireNonNull(set1, "set1");
234+
Objects.requireNonNull(set2, "set2");
235235

236236
return new AbstractSet<E>() {
237237
@Override
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
/**
18+
* Common Jersey core io classes.
19+
*/
20+
package org.glassfish.jersey.io;

0 commit comments

Comments
 (0)