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
Fix the set property's overrides #15165
Conversation
The System properties should only be preferred if override flag is set.
Thanks for your report. Can you provide a reproducer and/or a stack trace? |
Hey @lukaseder thanks for quick reply. To be honest I assumed that it was reproducible in a much more trivial way but I'm seeing now that this is not the case, will get back to you with a reproducer during the day. |
@lukaseder done :) please, find the reproducer and description in the PR description |
Ah yes, thanks a lot for the reproducer. I can see it now. I've created an issue for this: It seems that only unpublished snapshot versions are affected, so far. I'll check your fix suggestion soon. |
@lukaseder I couldn't reproduce it with the latest release (3.18.4 IIRC), so I think it's not in any of the releases indeed. |
I don't think your suggested fix is correct. You suggested if ((p != null && currentValueIsDefault) || override) But it should be:
|
Fixed in versions:
Thanks again for your report! |
I noticed while working on an unrelated feature proposal, and testing it with a production project, that the jooq-maven-plugin was failing with NPE because the
set()
method was overwriting thetargetDirectory
even thoughoverride
flag was not set and no system properties were passed.Hopefully I got the idea of method correctly.
The stack trace of the NPE:
Reproducer:
target/generated-sources/jooq
mvn compile
What happens:
generator.getTarget().getDirectory()
points to the default directory at the moment before this line is executednull
because we didn't specify the target directory using system propertyoverride
isn'ttrue
either, which makes it then check if the current target directory equals to the default value, and it doesjooq.codegen.target.directory
, which happens to benull
Fix
So if I understand correctly, the logic you were going for is:
override
is active, then take whatever is in the system properties, even if it's null (allowing us to unset some values, which otherwise would be impossible)override
is not active but the system property contains some value (not null) and the current value equals todefault
then use the value from the system property insteadoverride
is not active but the system property contains some value (not null) and the current value is not the same as default then ignore the system property (not sure about this one)