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

Invoking file system methods with root path throws NullPointerException #132

Closed
infeo opened this issue May 12, 2022 · 0 comments · Fixed by #133
Closed

Invoking file system methods with root path throws NullPointerException #132

infeo opened this issue May 12, 2022 · 0 comments · Fixed by #133
Assignees
Labels
Milestone

Comments

@infeo
Copy link
Member

infeo commented May 12, 2022

The JDK filesystem API takes an arbitrary Path as an argument. Hence, also for the filesystem root the following is a valid method call:

Path root = fs.getPath("/");
Files.createDirectory(root);

Although the above will likely throw an exception, it should be an IOException. Currently, a NullPointerException is thrown, caused by

void assertCleartextNameLengthAllowed(CryptoPath cleartextPath) throws FileNameTooLongException {
String filename = cleartextPath.getFileName().toString();
if (filename.length() > fileSystemProperties.maxCleartextNameLength()) {
throw new FileNameTooLongException(cleartextPath.toString(), fileSystemProperties.maxCleartextNameLength());
}
}
.

We need some null-check for Path::getFileName. Additionally, we should check which other methods choke on the root path.

@infeo infeo added the bug label May 12, 2022
@infeo infeo added this to the 2.4.2 milestone May 12, 2022
@infeo infeo self-assigned this May 12, 2022
infeo added a commit that referenced this issue May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant