Skip to content
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

[BUG] :test:logger-usage:test failure flakey test #2893

Closed
VachaShah opened this issue Apr 13, 2022 · 3 comments · Fixed by #5645
Closed

[BUG] :test:logger-usage:test failure flakey test #2893

VachaShah opened this issue Apr 13, 2022 · 3 comments · Fixed by #5645
Assignees
Labels
bug Something isn't working flaky-test Random test failure that succeeds on second run

Comments

@VachaShah
Copy link
Collaborator

Describe the bug
:test:logger-usage:test failure

java.lang.RuntimeException: unable to install test security manager
        at org.opensearch.bootstrap.BootstrapForTesting.<clinit>(BootstrapForTesting.java:190)
        at org.opensearch.test.OpenSearchTestCase.<clinit>(OpenSearchTestCase.java:251)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:468)
        at com.carrotsearch.randomizedtesting.RandomizedRunner$2.run(RandomizedRunner.java:623)

        Caused by:
        java.lang.NullPointerException: Cannot invoke "String.length()" because "input" is null
            at java.base/sun.nio.fs.UnixPath.normalizeAndCheck(UnixPath.java:75)
            at java.base/sun.nio.fs.UnixPath.<init>(UnixPath.java:69)
            at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:275)
            at org.opensearch.common.io.PathUtils.get(PathUtils.java:73)
            at org.opensearch.bootstrap.BootstrapForTesting.<clinit>(BootstrapForTesting.java:134)
            ... 4 more

Appeared in
#2726 (comment)
#1096 (comment)

@anasalkouz
Copy link
Member

@davidlago Could you look into this?

@dbwiddis
Copy link
Member

dbwiddis commented Dec 27, 2022

Stack trace related to JDK Bug 8254876, fix in JDK16 just throws the NPE earlier.

Cause is passing a null as first in PathUtils.get():

/**
* Returns a {@code Path} from name components.
* <p>
* This works just like {@code Paths.get()}.
* Remember: just like {@code Paths.get()} this is NOT A STRING CONCATENATION
* UTILITY FUNCTION.
* <p>
* Remember: this should almost never be used. Usually resolve
* a path against an existing one!
*/
public static Path get(String first, String... more) {
return DEFAULT.getPath(first, more);
}

This argument is System.getProperty("tests.config") which is length-checked by Strings.hasLength():

if (Strings.hasLength(System.getProperty("tests.config"))) {
FilePermissionUtils.addSingleFilePath(perms, PathUtils.get(System.getProperty("tests.config")), "read,readlink");
}

But this should return false for null:

public static boolean hasLength(String str) {
return hasLength((CharSequence) str);
}

public static boolean hasLength(CharSequence str) {
return (str != null && str.length() > 0);
}

@dbwiddis
Copy link
Member

Failed to reproduce in 1000 test runs.

The only possible source of failure is a change in the system property between the null check (line 133) and retrieving the property again (line 134). Submitted #5645 to save the initial property value to ensure the null check is of the same String being passed later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working flaky-test Random test failure that succeeds on second run
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants