Skip to content

default AuthStore gives NPE where XDG_RUNTIME_DIR is not present #250

@maxandersen

Description

@maxandersen

Description of the bug

https://github.com/oras-project/oras-java/blob/main/src/main/java/land/oras/auth/AuthStore.java#L93 assumes certain env exist.

therefore basic init fails on windows and mac:

///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS land.oras:oras-java-sdk:0.2.3

import land.oras.Registry;

public class PullImage {
    public static void main(String[] args) {

            Registry registry = Registry.Builder.builder().defaults().build();
    }
} 

Gives you:

Exception in thread "main" java.lang.NullPointerException
        at java.base/java.util.Objects.requireNonNull(Objects.java:209)
        at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:263)
        at java.base/java.nio.file.Path.of(Path.java:147)
        at land.oras.auth.AuthStore.newStore(AuthStore.java:93)
        at land.oras.auth.AuthStoreAuthenticationProvider.<init>(AuthStoreAuthenticationProvider.java:41)
        at land.oras.Registry$Builder.defaults(Registry.java:672)
        at PullImage.main(PullImage.java:14)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions