Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.x' into 'upstream/3.0'
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Nesen <maxim.nesen@oracle.com>
  • Loading branch information
senivam committed Sep 27, 2024
2 parents 4af9942 + 89de7de commit 21d14a9
Show file tree
Hide file tree
Showing 27 changed files with 594 additions and 111 deletions.
14 changes: 7 additions & 7 deletions NOTICE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Notice for Jersey
# Notice for Jersey
This content is produced and maintained by the Eclipse Jersey project.

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

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

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

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

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

jQuery v1.12.4
jQuery v3.7.1
* License: jquery.org/license
* Project: jquery.org
* Copyright: (c) jQuery Foundation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import java.net.Proxy;
import java.net.URL;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Logger;

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

private static class DefaultConnectionFactory implements ConnectionFactory {

private final ConcurrentHashMap<URL, Lock> locks = new ConcurrentHashMap<>();

@Override
public HttpURLConnection getConnection(final URL url) throws IOException {
return (HttpURLConnection) url.openConnection();
return connect(url, null);
}

@Override
public HttpURLConnection getConnection(URL url, Proxy proxy) throws IOException {
return connect(url, proxy);
}

private HttpURLConnection connect(URL url, Proxy proxy) throws IOException {
Lock lock = locks.computeIfAbsent(url, u -> new ReentrantLock());
lock.lock();
try {
return (proxy == null) ? (HttpURLConnection) url.openConnection() : (HttpURLConnection) url.openConnection(proxy);
} finally {
lock.unlock();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -24,13 +24,12 @@
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import static org.glassfish.jersey.internal.guava.Preconditions.checkNotNull;

/**
* Collections utils, which provide transforming views for {@link List} and {@link Map}.
*
Expand Down Expand Up @@ -197,8 +196,8 @@ public int size() {
* @return union view of given sets.
*/
public static <E> Set<E> setUnionView(final Set<? extends E> set1, final Set<? extends E> set2) {
checkNotNull(set1, "set1");
checkNotNull(set2, "set2");
Objects.requireNonNull(set1, "set1");
Objects.requireNonNull(set2, "set2");

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

/**
* Create a view of a difference of provided sets.
* Create a view of a difference of provided sets, i.e. the diff filters out from the first set the items included
* in the second set.
* <p>
* View is updated whenever any of the provided set changes.
*
* @param set1 first set.
* @param set2 second set.
* @param <E> set item type.
* @return union view of given sets.
* @return view that is a difference of given sets.
*/
public static <E> Set<E> setDiffView(final Set<? extends E> set1, final Set<? extends E> set2) {
checkNotNull(set1, "set1");
checkNotNull(set2, "set2");
Objects.requireNonNull(set1, "set1");
Objects.requireNonNull(set2, "set2");

return new AbstractSet<E>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

/**
* Common Jersey core io classes.
*/
package org.glassfish.jersey.io;
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.io.spi;

import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
import java.io.OutputStream;

/**
* A marker interface that the stream provided to Jersey can implement,
* noting that the stream does not need to call {@link #flush()} prior to {@link #close()}.
* That way, {@link #flush()} method is not called twice.
*
* <p>
* Usable by {@link javax.ws.rs.client.ClientRequestContext#setEntityStream(OutputStream)}.
* Usable by {@link javax.ws.rs.container.ContainerResponseContext#setEntityStream(OutputStream)}.
* </p>
*
* <p>
* This marker interface can be useful for the customer OutputStream to know the {@code flush} did not come from
* Jersey before close. By default, when the entity stream is to be closed by Jersey, {@code flush} is called first.
* </p>
*/
public interface FlushedCloseable extends Flushable, Closeable {
/**
* Flushes this stream by writing any buffered output to the underlying stream.
* Then closes this stream and releases any system resources associated
* with it. If the stream is already closed then invoking this
* method has no effect.
*
* <p> As noted in {@link AutoCloseable#close()}, cases where the
* close may fail require careful attention. It is strongly advised
* to relinquish the underlying resources and to internally
* <em>mark</em> the {@code Closeable} as closed, prior to throwing
* the {@code IOException}.
*
* @throws IOException if an I/O error occurs
*/
public void close() throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

/**
* Common Jersey core io SPI classes.
*/
package org.glassfish.jersey.io.spi;
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.glassfish.jersey.internal.util.collection.LazyValue;
import org.glassfish.jersey.internal.util.collection.Value;
import org.glassfish.jersey.internal.util.collection.Values;
import org.glassfish.jersey.io.spi.FlushedCloseable;

/**
* Base outbound message context implementation.
Expand Down Expand Up @@ -561,11 +562,13 @@ public void close() {
if (hasEntity()) {
try {
final OutputStream es = getEntityStream();
es.flush();
if (!FlushedCloseable.class.isInstance(es)) {
es.flush();
}
es.close();
} catch (IOException e) {
// Happens when the client closed connection before receiving the full response.
// This is OK and not interesting in vast majority of the cases
// This is OK and not interesting in the vast majority of the cases
// hence the log level set to FINE to make sure it does not flood the log unnecessarily
// (especially for clients disconnecting from SSE listening, which is very common).
Logger.getLogger(OutboundMessageContext.class.getName()).log(Level.FINE, e.getMessage(), e);
Expand Down
18 changes: 9 additions & 9 deletions examples/NOTICE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Notice for Jersey
# Notice for Jersey
This content is produced and maintained by the Eclipse Jersey project.

* Project home: https://projects.eclipse.org/projects/ee4j.jersey
Expand Down Expand Up @@ -39,8 +39,8 @@ aopalliance Version 1

Bean Validation API 3.0.2
* License: Apache License, 2.0
* Project: http://beanvalidation.org/1.1/
* Copyright: 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* Project: http://beanvalidation.org/3.0/
* Copyright: 2009, 2020 Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag.

Hibernate Validator CDI, 7.0.5.Final
Expand All @@ -58,25 +58,25 @@ CDI API Version 3.0
* Project: http://www.seamframework.org/Weld
* Copyright 2010, Red Hat, Inc., and individual contributors by the @authors tag.

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

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

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

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

jQuery v1.12.4
jQuery v3.7.1
* License: jquery.org/license
* Project: jquery.org
* Copyright: (c) jQuery Foundation
Expand Down
4 changes: 2 additions & 2 deletions examples/extended-wadl-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>2.0.13</version>
<artifactId>slf4j-reload4j</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>

Expand Down
4 changes: 2 additions & 2 deletions examples/osgi-http-service/functional-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@
<!-- Logging dependencies-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>2.0.13</version>
<artifactId>slf4j-reload4j</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>

Expand Down
9 changes: 9 additions & 0 deletions examples/servlet3-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@
</build>

<profiles>
<profile>
<id>jdk8_tests</id>
<activation>
<jdk>1.8</jdk>
</activation>
<properties>
<junit5.version>${junit5.jdk8.version}</junit5.version>
</properties>
</profile>
<profile>
<id>pre-release</id>
<build>
Expand Down
Loading

0 comments on commit 21d14a9

Please sign in to comment.