@@ -104,23 +104,24 @@ private static SourcePathHandle getHandleInDirectory(Path directory, String sour
104
104
}
105
105
106
106
private static SourcePathHandle getHandleInArchive (Path archive , String sourcePath , String [] subPaths , Charset encoding ) throws Throwable {
107
- FileSystem archiveFileSystem = FileSystems .newFileSystem (archive , (ClassLoader )null );
108
- if (subPaths == null ) {
109
- Path sourceFile = archiveFileSystem .getPath (sourcePath );
110
- return isFile (sourceFile ) ? new SourcePathHandle (sourceFile , true , encoding ) : null ;
111
- } else {
112
- if (subPaths .length == 1 && MODULES_SUBPATH .equals (subPaths [0 ])) {
113
- Path path = archiveFileSystem .getRootDirectories ().iterator ().next ();
114
- List <Path > subfolders = Files .walk (path , 1 ).filter (Files ::isDirectory ).collect (Collectors .toList ());
115
- for (Path subfolder : subfolders ) {
116
- Path sourceFile = subfolder .resolve (sourcePath );
107
+ try (FileSystem archiveFileSystem = FileSystems .newFileSystem (archive , (ClassLoader )null )) {
108
+ if (subPaths == null ) {
109
+ Path sourceFile = archiveFileSystem .getPath (sourcePath );
110
+ return isFile (sourceFile ) ? new SourcePathHandle (sourceFile , true , encoding ) : null ;
111
+ } else {
112
+ if (subPaths .length == 1 && MODULES_SUBPATH .equals (subPaths [0 ])) {
113
+ Path path = archiveFileSystem .getRootDirectories ().iterator ().next ();
114
+ List <Path > subfolders = Files .walk (path , 1 ).filter (Files ::isDirectory ).collect (Collectors .toList ());
115
+ for (Path subfolder : subfolders ) {
116
+ Path sourceFile = subfolder .resolve (sourcePath );
117
+ if (isFile (sourceFile )) return new SourcePathHandle (sourceFile , true , encoding );
118
+ }
119
+ } else for (String subPath : subPaths ) {
120
+ Path sourceFile = archiveFileSystem .getPath (subPath , sourcePath );
117
121
if (isFile (sourceFile )) return new SourcePathHandle (sourceFile , true , encoding );
118
122
}
119
- } else for (String subPath : subPaths ) {
120
- Path sourceFile = archiveFileSystem .getPath (subPath , sourcePath );
121
- if (isFile (sourceFile )) return new SourcePathHandle (sourceFile , true , encoding );
123
+ return null ;
122
124
}
123
- return null ;
124
125
}
125
126
}
126
127
0 commit comments