Skip to content

Commit e8f32c3

Browse files
authored
Merge pull request #4922 from senivam/31_merged
merge actual master into 3.1
2 parents b7a3946 + 2267fb7 commit e8f32c3

File tree

7 files changed

+136
-14
lines changed

7 files changed

+136
-14
lines changed

connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyConnector.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.HashMap;
2525
import java.util.List;
2626
import java.util.Map;
27+
import java.util.NoSuchElementException;
2728
import java.util.concurrent.CompletableFuture;
2829
import java.util.concurrent.CompletionException;
2930
import java.util.concurrent.ExecutorService;
@@ -102,7 +103,7 @@ class NettyConnector implements Connector {
102103
private final Integer maxPoolSizeTotal; //either from Jersey config, or default
103104
private final Integer maxPoolIdle; // either from Jersey config, or default
104105

105-
private static final String INACTIVE_POOLED_CONNECTION_HANDLER = "inactive_pooled_connection_handler";
106+
static final String INACTIVE_POOLED_CONNECTION_HANDLER = "inactive_pooled_connection_handler";
106107
private static final String PRUNE_INACTIVE_POOL = "prune_inactive_pool";
107108
private static final String READ_TIMEOUT_HANDLER = "read_timeout_handler";
108109
private static final String REQUEST_HANDLER = "request_handler";
@@ -190,10 +191,18 @@ protected CompletableFuture<ClientResponse> execute(final ClientRequest jerseyRe
190191
synchronized (conns) {
191192
while (chan == null && !conns.isEmpty()) {
192193
chan = conns.remove(conns.size() - 1);
193-
chan.pipeline().remove(INACTIVE_POOLED_CONNECTION_HANDLER);
194-
chan.pipeline().remove(PRUNE_INACTIVE_POOL);
194+
try {
195+
chan.pipeline().remove(INACTIVE_POOLED_CONNECTION_HANDLER);
196+
chan.pipeline().remove(PRUNE_INACTIVE_POOL);
197+
} catch (NoSuchElementException e) {
198+
/*
199+
* Eat it.
200+
* It could happen that the channel was closed, pipeline cleared and
201+
* then it will fail to remove the names with this exception.
202+
*/
203+
}
195204
if (!chan.isOpen()) {
196-
chan = null;
205+
chan = null;
197206
}
198207
}
199208
}

ext/cdi/jersey-cdi1x/src/main/java/org/glassfish/jersey/ext/cdi1x/internal/CdiComponentProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ private boolean bind(final Class<?> clazz, final Set<Class<?>> providerContracts
307307
final boolean isJaxRsResource = runtimeSpecifics.isJaxRsResource(clazz);
308308

309309
if (isJaxRsResource && !runtimeSpecifics.isAcceptableResource(clazz)) {
310-
LOGGER.warning(LocalizationMessages.CDI_NON_INSTANTIABLE_COMPONENT(clazz));
310+
LOGGER.log(clazz.isInterface() ? Level.FINE : Level.WARNING,
311+
LocalizationMessages.CDI_NON_INSTANTIABLE_COMPONENT(clazz));
311312
return false;
312313
}
313314

ext/microprofile/mp-rest-client/src/main/java/org/glassfish/jersey/microprofile/restclient/RestClientBuilderImpl.java

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import java.util.concurrent.Executors;
3737
import java.util.concurrent.TimeUnit;
3838
import java.util.function.Supplier;
39+
import java.util.logging.Level;
40+
import java.util.logging.Logger;
3941

4042
import jakarta.annotation.Priority;
4143
import javax.net.ssl.HostnameVerifier;
@@ -445,10 +447,42 @@ public RestClientBuilder proxyAddress(String proxyHost, int proxyPort) {
445447
if (proxyPort <= 0 || proxyPort > 65535) {
446448
throw new IllegalArgumentException("Invalid proxy port");
447449
}
448-
property(ClientProperties.PROXY_URI, proxyHost + ":" + proxyPort);
450+
451+
// If proxyString is something like "localhost:8765" we need to add a scheme since the connectors expect one
452+
String proxyString = createProxyString(proxyHost, proxyPort);
453+
454+
property(ClientProperties.PROXY_URI, proxyString);
449455
return this;
450456
}
451457

458+
static String createProxyString(String proxyHost, int proxyPort) {
459+
boolean prependScheme = false;
460+
String proxyString = proxyHost + ":" + proxyPort;
461+
462+
if (proxyString.split(":").length == 2) {
463+
// Check if first character is a number to account for if proxyHost is given as an IP rather than a name
464+
// URI.create("127.0.0.1:8765") will lead to an IllegalArgumentException
465+
if (proxyString.matches("\\d.*")) {
466+
prependScheme = true;
467+
} else {
468+
// "localhost:8765" will set the scheme as "localhost" and the host as "null"
469+
URI proxyURI = URI.create(proxyString);
470+
if (proxyURI.getHost() == null && proxyURI.getScheme().equals(proxyHost)) {
471+
prependScheme = true;
472+
}
473+
}
474+
}
475+
476+
if (prependScheme) {
477+
proxyString = "http://" + proxyString;
478+
Logger.getLogger(RestClientBuilderImpl.class.getName()).log(Level.FINE,
479+
"No scheme provided with proxyHost: " + proxyHost + ". Defaulting to HTTP, proxy address = "
480+
+ proxyString);
481+
}
482+
483+
return proxyString;
484+
}
485+
452486
@Override
453487
public RestClientBuilder queryParamStyle(QueryParamStyle queryParamStyle) {
454488
if (queryParamStyle != null) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2021 Payara Foundation 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+
package org.glassfish.jersey.microprofile.restclient;
18+
19+
import org.junit.Assert;
20+
import org.junit.Test;
21+
22+
import static org.glassfish.jersey.microprofile.restclient.RestClientBuilderImpl.createProxyString;
23+
24+
public class RestClientBuilderImplTest {
25+
26+
@Test
27+
public void createProxyStringTest() {
28+
Assert.assertTrue(createProxyString("localhost", 8765).equals("http://localhost:8765"));
29+
Assert.assertTrue(createProxyString("http://localhost", 8765).equals("http://localhost:8765"));
30+
Assert.assertTrue(createProxyString("127.0.0.1", 8765).equals("http://127.0.0.1:8765"));
31+
Assert.assertTrue(createProxyString("http://192.168.1.1", 8765).equals("http://192.168.1.1:8765"));
32+
}
33+
}

tools/jersey-doc-modulelist-maven-plugin/pom.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2222
<modelVersion>4.0.0</modelVersion>
2323

24+
<parent>
25+
<groupId>org.eclipse.ee4j</groupId>
26+
<artifactId>project</artifactId>
27+
<version>1.0.7</version>
28+
</parent>
29+
2430
<groupId>org.glassfish.jersey.tools.plugins</groupId>
2531
<artifactId>jersey-doc-modulelist-maven-plugin</artifactId>
2632
<packaging>maven-plugin</packaging>
@@ -53,6 +59,12 @@
5359
<artifactId>maven-dependency-tree</artifactId>
5460
<version>${maven.shared.version}</version>
5561
</dependency>
62+
<dependency>
63+
<groupId>org.apache.maven.plugin-tools</groupId>
64+
<artifactId>maven-plugin-annotations</artifactId>
65+
<version>3.6.1</version>
66+
<scope>provided</scope>
67+
</dependency>
5668
</dependencies>
5769

5870
<build>
@@ -74,6 +86,23 @@
7486
<fork>false</fork>
7587
</configuration>
7688
</plugin>
89+
<plugin>
90+
<groupId>org.apache.maven.plugins</groupId>
91+
<artifactId>maven-plugin-plugin</artifactId>
92+
<version>3.6.0</version>
93+
<configuration>
94+
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
95+
</configuration>
96+
<executions>
97+
<execution>
98+
<id>default-descriptor</id>
99+
<goals>
100+
<goal>descriptor</goal>
101+
</goals>
102+
<phase>process-classes</phase>
103+
</execution>
104+
</executions>
105+
</plugin>
77106
</plugins>
78107
</build>
79108

tools/jersey-doc-modulelist-maven-plugin/src/main/java/org/glassfish/jersey/tools/plugins/GenerateJerseyModuleListMojo.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2021 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,6 +21,10 @@
2121
import org.apache.maven.plugin.AbstractMojo;
2222
import org.apache.maven.plugin.MojoExecutionException;
2323
import org.apache.maven.plugin.logging.Log;
24+
import org.apache.maven.plugins.annotations.Component;
25+
import org.apache.maven.plugins.annotations.LifecyclePhase;
26+
import org.apache.maven.plugins.annotations.Mojo;
27+
import org.apache.maven.plugins.annotations.Parameter;
2428
import org.apache.maven.project.MavenProject;
2529

2630
import java.io.BufferedReader;
@@ -41,10 +45,11 @@
4145
* The plugins main MOJO class.
4246
* Walks through the maven dependency tree and creates the docbook output file.
4347
*
44-
* @goal generate
45-
* @phase process-sources
46-
* @aggregator
48+
* goal: generate
49+
* phase: process-sources
50+
* aggregator
4751
*/
52+
@Mojo(name = "generate", aggregator = true, defaultPhase = LifecyclePhase.PROCESS_SOURCES)
4853
public class GenerateJerseyModuleListMojo extends AbstractMojo {
4954

5055
/**
@@ -82,18 +87,21 @@ public class GenerateJerseyModuleListMojo extends AbstractMojo {
8287
* @required
8388
* @readonly
8489
*/
90+
@Parameter(defaultValue = "${project.basedir}")
8591
private MavenProject mavenProject;
8692

8793
/**
8894
* @component
8995
* @required
9096
* @readonly
9197
*/
98+
@Parameter( defaultValue = "${session}", readonly = true )
9299
private MavenSession mavenSession;
93100

94101
/**
95102
* @parameter default-value="modules.xml"
96103
*/
104+
@Parameter(defaultValue = "modules.xml")
97105
private String outputFileName;
98106

99107
/**
@@ -103,6 +111,7 @@ public class GenerateJerseyModuleListMojo extends AbstractMojo {
103111
*
104112
* @parameter
105113
*/
114+
@Parameter
106115
private String templateFileName;
107116

108117
/**
@@ -112,6 +121,7 @@ public class GenerateJerseyModuleListMojo extends AbstractMojo {
112121
*
113122
* @parameter
114123
*/
124+
@Parameter
115125
private String tableHeaderFileName;
116126

117127
/**
@@ -120,6 +130,7 @@ public class GenerateJerseyModuleListMojo extends AbstractMojo {
120130
*
121131
* @parameter
122132
*/
133+
@Parameter
123134
private String tableFooterFileName;
124135

125136
/**
@@ -129,11 +140,13 @@ public class GenerateJerseyModuleListMojo extends AbstractMojo {
129140
*
130141
* @parameter
131142
*/
143+
@Parameter
132144
private String tableRowFileName;
133145

134146
/**
135147
* @parameter default-value="false"
136148
*/
149+
@Parameter(defaultValue = "false")
137150
private boolean outputUnmatched;
138151

139152
private Configuration configuration;

tools/jersey-doc-modulelist-maven-plugin/src/main/java/org/glassfish/jersey/tools/plugins/HelpMojo.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2021 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
@@ -20,14 +20,17 @@
2020
import org.apache.maven.plugin.MojoExecutionException;
2121
import org.apache.maven.plugin.MojoFailureException;
2222
import org.apache.maven.plugin.logging.Log;
23+
import org.apache.maven.plugins.annotations.LifecyclePhase;
24+
import org.apache.maven.plugins.annotations.Mojo;
2325

2426
/**
2527
* Displays the plugin help message.
2628
*
27-
* @goal help
28-
* @phase process-sources
29-
* @aggregator
29+
* goal: help
30+
* phase: process-sources
31+
* aggregator
3032
*/
33+
@Mojo(name = "help", aggregator = true, defaultPhase = LifecyclePhase.PROCESS_SOURCES)
3134
public class HelpMojo extends AbstractMojo {
3235

3336
private Log log;

0 commit comments

Comments
 (0)