[MSHARED-969] Environment variable with null value by slawekjaranowski · Pull Request #68 · apache/maven-shared-utils (original) (raw)

mkarg

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not talk about popularity neither about reflection, but solely about creating garbage needlessly. I doubt the race condition actually will happen here, as the variable is effectively final at that point.

public void environmentVariableWithNullShouldNotBeAddedToList() {
Commandline commandline = new Commandline();
commandline.addEnvironment("TEST_NULL_ENV", null);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With reard to my previous comments I'd like to ask the OS experts what sense it make to store null in an environment variable?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I wrote before Command Line object has local map of environment variable which are provided to Runtime.exec after translate this map to list of name=value. Translation is done in getEnvironmentVariables.

Please look at my last comment at jira and new test in last update.