Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/apache/maven/shared/utils/Os.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ private static String getOsFamily() {
return fam;
}
}
return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I didn't find a contract, that ensures this piece of code should not be null. I'm afraid, that could have side effects in code that uses it.

For example:

if (Os.OS_FAMILY == null) {
}

This snippet would have another meaning after our change.

On the other side, the class Os is deprecated, so maybe it is okay to take this risk.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. probably better not to take it then.

return "";
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/apache/maven/shared/utils/OsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
Expand Down Expand Up @@ -112,6 +113,11 @@ public void testGetValidFamilies() {
assertTrue(osFamilies.contains(Os.FAMILY_ZOS));
}

@Test
public void testOsFamilyNotNull() {
assertNotNull(Os.OS_FAMILY);
}

@Test
public void testIsArch() {
assertTrue(Os.isArch("i386"), "Arch is i386");
Expand Down
Loading