-
-
Notifications
You must be signed in to change notification settings - Fork 794
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
Ensure filesystems are created so paths can be gotten #2504
Conversation
@@ -78,5 +79,10 @@ fun CliArgs.extractUris(): Collection<URI> { | |||
val pathUris = config?.let { MultipleExistingPathConverter().convert(it).map(Path::toUri) } ?: emptyList() | |||
val resourceUris = configResource?.let { MultipleClasspathResourceConverter().convert(it).map(URL::toURI) } | |||
?: emptyList() | |||
resourceUris.forEach { | |||
runCatching { | |||
FileSystems.newFileSystem(it, emptyMap<String, Any>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for analyzing this issue!
I would prefer the second answer on stackoverflow
private FileSystem initFileSystem(URI uri) throws IOException
{
try
{
return FileSystems.getFileSystem(uri);
}
catch( FileSystemNotFoundException e )
{
Map<String, String> env = new HashMap<>();
env.put("create", "true");
return FileSystems.newFileSystem(uri, env);
}
}
Your code could be refactored to resourceUris.forEach(checkFileSystem)
.
The create=true
part sounds to be important.
12ae0ad
to
5637d6f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for helping us out and submitting the fix! 🙂
5637d6f
to
3e69c10
Compare
When getting resources from the classpath, the ZipFileSystem needs to be initialized manually. Fixes detekt#2503
3e69c10
to
4f55636
Compare
Codecov Report
@@ Coverage Diff @@
## master #2504 +/- ##
============================================
- Coverage 80.07% 80.04% -0.03%
Complexity 2257 2257
============================================
Files 378 378
Lines 6635 6641 +6
Branches 1180 1180
============================================
+ Hits 5313 5316 +3
- Misses 740 743 +3
Partials 582 582
Continue to review full report at Codecov.
|
@arturbosch this should be included in v1.7.1 in my opinion. |
When getting resources from the classpath, the ZipFileSystem
needs to be initialized manually.
Fixes #2503