Skip to content

Commit f86cdf0

Browse files
authored
Add Apache5 properties to be grabbed by config (#5536)
* Add Apache5 properties to be grabbed by config Signed-off-by: jansupol <jan.supol@oracle.com>
1 parent 604cf2e commit f86cdf0

File tree

3 files changed

+31
-34
lines changed

3 files changed

+31
-34
lines changed

core-common/src/main/java/org/glassfish/jersey/internal/config/JerseySystemPropertiesConfigurationModel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 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
@@ -29,6 +29,7 @@ class JerseySystemPropertiesConfigurationModel extends SystemPropertiesConfigura
2929
"org.glassfish.jersey.servlet.ServletProperties",
3030
"org.glassfish.jersey.message.MessageProperties",
3131
"org.glassfish.jersey.apache.connector.ApacheClientProperties",
32+
"org.glassfish.jersey.apache5.connector.Apache5ClientProperties",
3233
"org.glassfish.jersey.helidon.connector.HelidonClientProperties",
3334
"org.glassfish.jersey.jdk.connector.JdkConnectorProperties",
3435
"org.glassfish.jersey.jetty.connector.JettyClientProperties",

tests/integration/property-check/pom.xml

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright (c) 2014, 2023 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2014, 2024 Oracle and/or its affiliates. All rights reserved.
55
66
This program and the accompanying materials are made available under the
77
terms of the Eclipse Public License v. 2.0, which is available at
@@ -72,6 +72,11 @@
7272
<artifactId>jersey-apache-connector</artifactId>
7373
<scope>test</scope>
7474
</dependency>
75+
<dependency>
76+
<groupId>org.glassfish.jersey.connectors</groupId>
77+
<artifactId>jersey-apache5-connector</artifactId>
78+
<scope>test</scope>
79+
</dependency>
7580
<dependency>
7681
<groupId>org.glassfish.jersey.security</groupId>
7782
<artifactId>oauth1-server</artifactId>
@@ -108,28 +113,4 @@
108113
</plugin>
109114
</plugins>
110115
</build>
111-
112-
<profiles>
113-
<profile>
114-
<id>jdk19+</id>
115-
<activation>
116-
<jdk>[19,)</jdk>
117-
</activation>
118-
<build>
119-
<pluginManagement>
120-
<plugins>
121-
<plugin>
122-
<groupId>org.apache.maven.plugins</groupId>
123-
<artifactId>maven-surefire-plugin</artifactId>
124-
<configuration>
125-
<excludes>
126-
<exclude>**/SystemPropertiesConfigurationModelTest.java</exclude>
127-
</excludes>
128-
</configuration>
129-
</plugin>
130-
</plugins>
131-
</pluginManagement>
132-
</build>
133-
</profile>
134-
</profiles>
135116
</project>

tests/integration/property-check/src/test/java/org/glassfish/jersey/internal/config/SystemPropertiesConfigurationModelTest.java

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 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
@@ -32,6 +32,7 @@
3232

3333
import org.glassfish.jersey.CommonProperties;
3434
import org.glassfish.jersey.apache.connector.ApacheClientProperties;
35+
import org.glassfish.jersey.apache5.connector.Apache5ClientProperties;
3536
import org.glassfish.jersey.client.ClientProperties;
3637
import org.glassfish.jersey.internal.InternalProperties;
3738
import org.glassfish.jersey.internal.util.JdkVersion;
@@ -79,24 +80,34 @@ public void allPropertyClassLoaded() throws IOException {
7980
@Test
8081
public void propertyLoadedWhenSecurityException() {
8182
final String TEST_STRING = "test";
82-
SecurityManager sm = System.getSecurityManager();
83-
String policy = System.getProperty("java.security.policy");
83+
final boolean isSm = JdkVersion.getJdkVersion().getMajor() < 19;
84+
SecurityManager sm = null;
85+
String policy = null;
86+
if (isSm) {
87+
sm = System.getSecurityManager();
88+
policy = System.getProperty("java.security.policy");
89+
}
8490
try {
8591
System.setProperty(CommonProperties.ALLOW_SYSTEM_PROPERTIES_PROVIDER, Boolean.TRUE.toString());
8692
System.setProperty(ServerProperties.APPLICATION_NAME, TEST_STRING);
8793
System.setProperty(ClientProperties.BACKGROUND_SCHEDULER_THREADPOOL_SIZE, TEST_STRING);
8894
System.setProperty(ServletProperties.JAXRS_APPLICATION_CLASS, TEST_STRING);
8995
System.setProperty(MessageProperties.IO_BUFFER_SIZE, TEST_STRING);
9096
System.setProperty(ApacheClientProperties.DISABLE_COOKIES, TEST_STRING);
97+
System.setProperty(Apache5ClientProperties.DISABLE_COOKIES, TEST_STRING);
9198
System.setProperty(JettyClientProperties.ENABLE_SSL_HOSTNAME_VERIFICATION, TEST_STRING);
9299
System.setProperty(MultiPartProperties.TEMP_DIRECTORY, TEST_STRING);
93100
System.setProperty(OAuth1ServerProperties.REALM, TEST_STRING);
94101
JerseySystemPropertiesConfigurationModel model = new JerseySystemPropertiesConfigurationModel();
95102
assertTrue(model.as(CommonProperties.ALLOW_SYSTEM_PROPERTIES_PROVIDER, Boolean.class));
96-
String securityPolicy = SystemPropertiesConfigurationModelTest.class.getResource("/server.policy").getFile();
97-
System.setProperty("java.security.policy", securityPolicy);
98-
SecurityManager manager = new SecurityManager();
99-
System.setSecurityManager(manager);
103+
104+
if (isSm) {
105+
String securityPolicy = SystemPropertiesConfigurationModelTest.class.getResource("/server.policy").getFile();
106+
System.setProperty("java.security.policy", securityPolicy);
107+
SecurityManager manager = new SecurityManager();
108+
System.setSecurityManager(manager);
109+
}
110+
100111
Map<String, Object> properties = model.getProperties();
101112
assertEquals(TEST_STRING, properties.get(ServerProperties.APPLICATION_NAME));
102113
assertEquals(Boolean.TRUE.toString(), properties.get(CommonProperties.ALLOW_SYSTEM_PROPERTIES_PROVIDER));
@@ -109,7 +120,9 @@ public void propertyLoadedWhenSecurityException() {
109120
assertEquals(TEST_STRING, properties.get(MessageProperties.IO_BUFFER_SIZE));
110121
assertFalse(properties.containsKey(MessageProperties.DEFLATE_WITHOUT_ZLIB));
111122
assertEquals(TEST_STRING, properties.get(ApacheClientProperties.DISABLE_COOKIES));
123+
assertEquals(TEST_STRING, properties.get(Apache5ClientProperties.DISABLE_COOKIES));
112124
assertFalse(properties.containsKey(ApacheClientProperties.CONNECTION_MANAGER));
125+
assertFalse(properties.containsKey(Apache5ClientProperties.CONNECTION_MANAGER));
113126
assertEquals(TEST_STRING, properties.get(JettyClientProperties.ENABLE_SSL_HOSTNAME_VERIFICATION));
114127
assertFalse(properties.containsKey(JettyClientProperties.DISABLE_COOKIES));
115128
assertEquals(TEST_STRING, properties.get(MultiPartProperties.TEMP_DIRECTORY));
@@ -120,7 +133,9 @@ public void propertyLoadedWhenSecurityException() {
120133
if (policy != null) {
121134
System.setProperty("java.security.policy", policy);
122135
}
123-
System.setSecurityManager(sm);
136+
if (isSm) {
137+
System.setSecurityManager(sm);
138+
}
124139
}
125140
}
126141

0 commit comments

Comments
 (0)