- 
                Notifications
    
You must be signed in to change notification settings  - Fork 161
 
Embedded GlassFish - fixes related to system properties #25724
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
Embedded GlassFish - fixes related to system properties #25724
Conversation
Properties are not overwritten, if set on command line or by other means before starting the server.
| return this.sysPropName; | ||
| } | ||
| 
               | 
          ||
| public Optional<String> getSystemPropertyValue() { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This lib should be without tech debt and with good design. (EDIT: originally I thought it is in jdke, but it applies to the simple api too)
 - Missing javadoc
 - When I created 
GlassFishVariable, I had doubts if I should create alsogetValuemethods here, however I have found that it is a not good idea, because they don't save me of any pain. In your case,-Dcom.sun.aas.hostName=""(empty string) is not an empty optional. Also, sometimes I need a supplier, sometimes it would be better to use just optional, sometimes, I need some processing ... and soon it would be messy as usual. - Exactly opposite, evaluation of these variables are always somehow specific to some domain. There it belongs to. This class serves just to replace old set of hashmaps and constants used on older version, and give some order to the mapping of env option and system properties.
 
So I would move it to the SystemTasksImpl and maybe we could even improve the validation. Actually I am now looking on other usages, one other usages outside this PR contains a bug, another has completely different evaluation of the hostname, maybe depending on this code, not sure ... we should clean it up.
However I did not put these methods to GlassFishVariable intentionally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another idea: just remove this and use just nullcheck in SystemTasksImpl and we will target the hostname evaluation in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I'll just inline this methog SystemTasksImpl and remove it from GlassFishVariable. I added it to GlassFish variable because it makes the code cleaner in SystemTasksImpl, HOST_NAME.getSystemPropertyValue().isEmpty() instead of System.getProperty(HOST_NAME.getPropertyName()) != null), but it's not much different and still readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, if I change the code to respect forceOverwrite, then I don't even need this at all :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might need it to skip getting hostname if the property is already set and forceOverwrite is false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't know what to do if the property value is an empty string. Is it the same as an empty string (explicit reset)? Or it can be taken as an error. Maybe the first option is correct, then the optional doesn't work. As a paradox Optional can make it more complicated compared to old and ugly "null or empty" check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this method already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I only check for null, not empty. Empty means a value, the only reason why it would mean the property is not set would be if we want to allow deleting the property by setting it to an empty string. Makes sense in some cases, but I wouldn't bother here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but empty hostname doesn't sound something valid for me.
| for (int i = 1; i < split.length; i++) { | ||
| commandParams[i - 1] = split[i].trim(); | ||
| } | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
| LOG.log(Level.SEVERE, KernelLoggerInfo.exceptionHostname, ex); | ||
| } | ||
| if (hostname != null) { | ||
| setProperty(HOST_NAME.getSystemPropertyName(), hostname, false); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we both have a very good question ... why to ignore the forceOverwrite here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'll change it to follow forceOverwrite also here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it so that it uses only attempts to compute hostname and set the value if either forceOverwrite=true or if the value is not set. To avoid computing hostname if it's going to be ignored in the end. A very small optimization for an edge case, I know :)
a5763f2    to
    e0b5f80      
    Compare
  
    | 
           appserver/tests/embedded/runnable  | 
    
e0b5f80    to
    ca42dce      
    Compare
  
    | 
           So as you explained to me, the whole   | 
    
System properties can be set by the following means:
--propetiesfile (e.g. property "my.name" should have line "my.name=GlassFish Server" in the properties file, spaces shouldn't be escaped)Fixes number 3, which worked in 7.0.25 but stopped working in master.
Allows empty spaces in property values if setting via the create-system-properties admin command - space escaped by
\is treated as value not as a separator. This follows the same pattern as in the asadmin CLI tool.