diff --git a/core/src/main/java/net/sourceforge/jnlp/JNLPFile.java b/core/src/main/java/net/sourceforge/jnlp/JNLPFile.java index 78dca8195..b988b46ab 100644 --- a/core/src/main/java/net/sourceforge/jnlp/JNLPFile.java +++ b/core/src/main/java/net/sourceforge/jnlp/JNLPFile.java @@ -261,7 +261,7 @@ protected JNLPFile() { final String httpAgent = getResources().getPropertiesMap().get(HTTP_AGENT); // Do not set http.agent in stage 2 as it can be set from the vmarg to the jvm - if (! StringUtils.isBlank(httpAgent) && !"true".equalsIgnoreCase(System.getenv(ApplicationInstance.IGNORE_JNLP_RESOURCE_PROPERTIES))) { + if (! StringUtils.isBlank(httpAgent) && !"true".equalsIgnoreCase(System.getenv(ApplicationInstance.IGNORE_HTTP_AGENT_PROPERTY))) { System.setProperty(HTTP_AGENT, httpAgent); if (!HttpURLConnection.userAgent.contains(httpAgent)) { LOG.warn("Cannot set HTTP User-Agent as a connection has been opened before reading the JNLP file"); diff --git a/core/src/main/java/net/sourceforge/jnlp/runtime/ApplicationInstance.java b/core/src/main/java/net/sourceforge/jnlp/runtime/ApplicationInstance.java index 17d583a7b..ddface9ee 100644 --- a/core/src/main/java/net/sourceforge/jnlp/runtime/ApplicationInstance.java +++ b/core/src/main/java/net/sourceforge/jnlp/runtime/ApplicationInstance.java @@ -16,6 +16,7 @@ package net.sourceforge.jnlp.runtime; +import net.adoptopenjdk.icedteaweb.JavaSystemPropertiesConstants; import net.adoptopenjdk.icedteaweb.jnlp.element.resource.ExtensionDesc; import net.adoptopenjdk.icedteaweb.jnlp.element.resource.PropertyDesc; import net.adoptopenjdk.icedteaweb.jnlp.element.security.SecurityDesc; @@ -53,7 +54,7 @@ public class ApplicationInstance { private static final String DEPLOYMENT_SYSPROP = "deployment.javaws"; private static final String DEPLOYMENT_SYSPROP_VALUE = "IcedTea-Web"; - public static final String IGNORE_JNLP_RESOURCE_PROPERTIES = "ignoreJnlpResourceProperties"; + public static final String IGNORE_HTTP_AGENT_PROPERTY = "ignoreHttpAgentProperty"; // todo: should attempt to unload the environment variables // installed by the application. @@ -143,9 +144,6 @@ private void installEnvironment() { } private void setSystemPropertiesFromJnlp() { - if ("true".equalsIgnoreCase(System.getenv(IGNORE_JNLP_RESOURCE_PROPERTIES))) { - return; - } final List props = collectPropertiesFromJnlpHierarchy(new ArrayList<>(), file); if (!(props.size() == 0)) { @@ -158,8 +156,11 @@ private void setSystemPropertiesFromJnlp() { final PrivilegedAction setPropertiesAction = () -> { for (PropertyDesc propDesc : props) { - LOG.debug("Setting System Property {} with value {}", propDesc.getKey(), propDesc.getValue()); - System.setProperty(propDesc.getKey(), propDesc.getValue()); + if (!propDesc.getKey().equals(JavaSystemPropertiesConstants.HTTP_AGENT)) { + setSystemProperty(propDesc); + } else if (!"true".equalsIgnoreCase(System.getenv(ApplicationInstance.IGNORE_HTTP_AGENT_PROPERTY))) { + setSystemProperty(propDesc); + } } return null; }; @@ -169,6 +170,11 @@ private void setSystemPropertiesFromJnlp() { } } + private void setSystemProperty(PropertyDesc propDesc) { + LOG.debug("Setting System Property {} with value {}", propDesc.getKey(), propDesc.getValue()); + System.setProperty(propDesc.getKey(), propDesc.getValue()); + } + /** * Returns the jnlpfile on which is this application based * @return JNLP file for this task.