Skip to content

[MSHARED-969] Environment variable with null value - #68

Merged
MartinKanters merged 1 commit into
apache:masterfrom
slawekjaranowski:fix-969
Apr 16, 2021
Merged

MartinKanters merged 1 commit into
apache:masterfrom
slawekjaranowski:fix-969

Conversation

@slawekjaranowski

Copy link
Copy Markdown
Member

No description provided.

Comment thread src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java Outdated
Comment thread src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java Outdated
@slawekjaranowski

Copy link
Copy Markdown
Member Author

@pzygielo thanks for review, I did fix

Comment thread src/main/java/org/apache/maven/shared/utils/cli/Commandline.java
Comment thread src/main/java/org/apache/maven/shared/utils/cli/Commandline.java

@mkarg mkarg left a comment

Copy link
Copy Markdown

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);

Copy link
Copy Markdown

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?

Copy link
Copy Markdown
Member Author

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.

@MartinKanters MartinKanters left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I agree with @slawekjaranowski and @elharo, this does fix potential bugs. I approve the changes. Thanks @slawekjaranowski!

@MartinKanters
MartinKanters merged commit 8b8d586 into apache:master Apr 16, 2021
@slawekjaranowski
slawekjaranowski deleted the fix-969 branch April 16, 2021 13:37
@jira-importer

Copy link
Copy Markdown

Resolve #282

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

Successfully merging this pull request may close these issues.

6 participants