Skip to content

Commit 5d1ddc8

Browse files
authored
Merge pull request #945 from AdoptOpenJDK/setting_http_agent_for_ows
OWS-631: Fix properties defined in Jnlp not passed to application
2 parents c139a18 + a2ab17b commit 5d1ddc8

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

core/src/main/java/net/sourceforge/jnlp/JNLPFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ protected JNLPFile() {
261261

262262
final String httpAgent = getResources().getPropertiesMap().get(HTTP_AGENT);
263263
// Do not set http.agent in stage 2 as it can be set from the vmarg to the jvm
264-
if (! StringUtils.isBlank(httpAgent) && !"true".equalsIgnoreCase(System.getenv(ApplicationInstance.IGNORE_JNLP_RESOURCE_PROPERTIES))) {
264+
if (! StringUtils.isBlank(httpAgent) && !"true".equalsIgnoreCase(System.getenv(ApplicationInstance.IGNORE_HTTP_AGENT_PROPERTY))) {
265265
System.setProperty(HTTP_AGENT, httpAgent);
266266
if (!HttpURLConnection.userAgent.contains(httpAgent)) {
267267
LOG.warn("Cannot set HTTP User-Agent as a connection has been opened before reading the JNLP file");

core/src/main/java/net/sourceforge/jnlp/runtime/ApplicationInstance.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package net.sourceforge.jnlp.runtime;
1818

19+
import net.adoptopenjdk.icedteaweb.JavaSystemPropertiesConstants;
1920
import net.adoptopenjdk.icedteaweb.jnlp.element.resource.ExtensionDesc;
2021
import net.adoptopenjdk.icedteaweb.jnlp.element.resource.PropertyDesc;
2122
import net.adoptopenjdk.icedteaweb.jnlp.element.security.SecurityDesc;
@@ -53,7 +54,7 @@ public class ApplicationInstance {
5354

5455
private static final String DEPLOYMENT_SYSPROP = "deployment.javaws";
5556
private static final String DEPLOYMENT_SYSPROP_VALUE = "IcedTea-Web";
56-
public static final String IGNORE_JNLP_RESOURCE_PROPERTIES = "ignoreJnlpResourceProperties";
57+
public static final String IGNORE_HTTP_AGENT_PROPERTY = "ignoreHttpAgentProperty";
5758

5859
// todo: should attempt to unload the environment variables
5960
// installed by the application.
@@ -143,9 +144,6 @@ private void installEnvironment() {
143144
}
144145

145146
private void setSystemPropertiesFromJnlp() {
146-
if ("true".equalsIgnoreCase(System.getenv(IGNORE_JNLP_RESOURCE_PROPERTIES))) {
147-
return;
148-
}
149147
final List<PropertyDesc> props = collectPropertiesFromJnlpHierarchy(new ArrayList<>(), file);
150148

151149
if (!(props.size() == 0)) {
@@ -158,8 +156,11 @@ private void setSystemPropertiesFromJnlp() {
158156

159157
final PrivilegedAction<Object> setPropertiesAction = () -> {
160158
for (PropertyDesc propDesc : props) {
161-
LOG.debug("Setting System Property {} with value {}", propDesc.getKey(), propDesc.getValue());
162-
System.setProperty(propDesc.getKey(), propDesc.getValue());
159+
if (!propDesc.getKey().equals(JavaSystemPropertiesConstants.HTTP_AGENT)) {
160+
setSystemProperty(propDesc);
161+
} else if (!"true".equalsIgnoreCase(System.getenv(ApplicationInstance.IGNORE_HTTP_AGENT_PROPERTY))) {
162+
setSystemProperty(propDesc);
163+
}
163164
}
164165
return null;
165166
};
@@ -169,6 +170,11 @@ private void setSystemPropertiesFromJnlp() {
169170
}
170171
}
171172

173+
private void setSystemProperty(PropertyDesc propDesc) {
174+
LOG.debug("Setting System Property {} with value {}", propDesc.getKey(), propDesc.getValue());
175+
System.setProperty(propDesc.getKey(), propDesc.getValue());
176+
}
177+
172178
/**
173179
* Returns the jnlpfile on which is this application based
174180
* @return JNLP file for this task.

0 commit comments

Comments
 (0)