Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting JVM option via system property (e.g. liberty.jvm.xyz ) doesn't override POM property of same name #1565

Closed
scottkurz opened this issue Jul 19, 2022 · 2 comments

Comments

@scottkurz
Copy link
Member

For a POM with property like:

<properties>
    <liberty.jvm.arg1>-Xmx2048m</liberty.jvm.arg1>
</properties>

I might think I can do: mvn liberty:dev -Dliberty.jvm.arg1="-Xmx4096m" to override, since in general, in Maven, system properties will override POM properties.

However, the current liberty-maven-plugin impl will write both values into the generated jvm.options, e.g.:

jvm.options

-Xmx2048m
-Xmx4096m

In certain cases this may happen to "work", if the JVM ignores the first and uses the second, say.

However if you wanted to "unset" the POM property by passing mvn liberty:dev -Dliberty.jvm.arg1= then this might not work as well.

Looking at the plugin code, I see the root cause is how we use a list to store the JVM option props:

 protected List<String> jvmMavenProps = new ArrayList<String>();   
 ... 
 case JVM:        jvmMavenProps.add(value);

This makes some sense since we throw away the "key" and only use the "value", but leads to the problem above.

PROPOSAL

We should investigate whether we can treat the liberty.jvm.xyz properties with more of a "map" behavior and have the one value override/replace the other. We should think through the complete merging algorithm, including all possible sources for the JVM options, to make sure this makes sense, before doing.

@cherylking
Copy link
Member

cherylking commented Jul 21, 2022

The server-param-pom-override-it test case confirms some odd behavior related to jvm options. The <jvmOptions> plugin config is last in the jvm.options file, taking precedence over the <liberty.jvm.maxHeap>-Xmx1024m</liberty.jvm.maxHeap> Maven property in the same pom.xml. There is also a jvm.options file in the src/main/liberty/config dir that I think gets overridden by the config in the pom.xml.

We should check the behavior of the server.env properties as well if we change the logic for this.

The Maven properties that start with liberty.var are verified by the test case and the cmd line property (through invoker.properties) takes precedence over the Maven property in the pom.xml.

@scottkurz
Copy link
Member Author

I happened to see this issue in the backlog and realized we fixed this in #1779

Confirmed that mvn -Dliberty.env.aaa=555 -Dliberty.jvm.arg1="-Xmx3072m" overrides similarly-named POM properties for each.

@cherylking don't think there was anything more to test, so closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants