Skip to content

Commit

Permalink
Avoid toUri call in QuarkusCompiler
Browse files Browse the repository at this point in the history
and only retrieve one path from zfs, instead of always reading at least the root path
  • Loading branch information
Postremus committed Jan 22, 2022
1 parent c6233ad commit 0598cfd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayDeque;
Expand All @@ -23,6 +24,7 @@

import io.quarkus.bootstrap.app.CuratedApplication;
import io.quarkus.bootstrap.app.QuarkusBootstrap;
import io.quarkus.fs.util.FileSystemProviders;
import io.quarkus.maven.dependency.ResolvedDependency;
import io.quarkus.paths.PathCollection;

Expand Down Expand Up @@ -74,17 +76,16 @@ public QuarkusCompiler(CuratedApplication application,
: context.getDevModeRunnerJarFile().getCanonicalPath();
while (!toParse.isEmpty()) {
Path path = toParse.poll();
URI uri = path.toUri();
File file = path.toFile();
String s = file.getAbsolutePath();
if (!parsedFiles.contains(s)) {
parsedFiles.add(s);
if (!file.exists()) {
continue;
}
if (uri.getScheme().equals("file")) {
if (path.getFileSystem() == FileSystems.getDefault()) {
classPathElements.add(file);
} else if (uri.getScheme().equals("jar")) {
} else if (path.getFileSystem().provider() == FileSystemProviders.ZIP_PROVIDER) {
// skip adding the dev mode runner jar to the classpath to prevent
// hitting a bug in JDK - https://bugs.openjdk.java.net/browse/JDK-8232170
// which causes the programmatic java file compilation to fail.
Expand Down Expand Up @@ -156,10 +157,10 @@ public void setupSourceCompilationContext(DevModeContext context, Set<File> clas
+ "'. It is advised that this module be compiled before launching dev mode");
return;
}
compilationUnit.getSourcePaths().forEach(sourcePath -> {
for (Path sourcePath : compilationUnit.getSourcePaths()) {
final String srcPathStr = sourcePath.toString();
if (this.compilationContexts.containsKey(srcPathStr)) {
return;
continue;
}
this.compilationContexts.put(srcPathStr,
new CompilationProvider.Context(
Expand All @@ -175,7 +176,7 @@ public void setupSourceCompilationContext(DevModeContext context, Set<File> clas
context.getTargetJvmVersion(),
context.getCompilerPluginArtifacts(),
context.getCompilerPluginsOptions()));
});
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ public static <R> R processAsPath(URL url, Function<Path, R> function) {
throw new RuntimeException("Failed to create a URL for '" + file.substring(0, exclam) + "'", e);
}
try (FileSystem jarFs = ZipUtils.newFileSystem(jar)) {
Path localPath = jarFs.getPath("/");
Path localPath;
if (exclam >= 0) {
localPath = localPath.resolve(file.substring(exclam + 1));
localPath = jarFs.getPath(file.substring(exclam + 1));
} else {
localPath = jarFs.getPath("/");
}
return function.apply(localPath);
} catch (IOException e) {
Expand Down

0 comments on commit 0598cfd

Please sign in to comment.