Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] NPE when calling RepositoryCache.FileKey.isGitRepository on a relative path

On Wed, Jun 26, 2019 at 11:21 PM Dmitry Pavlenko <pavlenko@xxxxxxxxxxxxx> wrote:
I can reproduce the NPE with a single line:

  RepositoryCache.FileKey.isGitRepository(new File("repo.git"), FS.DETECTED)

if the relative path "repo.git" doesn't exist yet.

It's a regression, the previous (File-based, not Path-based) JGit versions
worked fine in this situation.

The problem happens because

  new File("repo.git").toPath().getParent()

evaluates to null in


(The corresponding line is:  Path dir = Files.isDirectory(file) ? file :
file.getParent();  )

The documentation doesn't mention whether the path can or cannot be

So I wonder whether this is expected behaviour, and I should use the
absolute path or is it a bug in JGit and it should work with relative paths
as well?

I added a test with your example but it doesn't fail on Mac:

Can you try that in your environment?


Back to the top