Skip to content

Commit

Permalink
Merge pull request #1408 from theathlete3141/#1395
Browse files Browse the repository at this point in the history
#1395 - fix delay between the first active user(s) and the first request(s) in Karate-Gatling
  • Loading branch information
ptrthomas committed Dec 21, 2020
2 parents 510afff + 38de2ab commit b716ca0
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,29 @@ public static List<Feature> findFeatureFiles(File workingDir, List<String> paths
return features;
}

private static final ScanResult scanResult = new ClassGraph().acceptPaths("/").scan();

public static Resource getResource(File workingDir, String path) {
if (path.startsWith("classpath:")) {
path = removePrefix(path);
File file = classPathToFile(path);
if (file != null) {
return new FileResource(file, true, path);
}
List<Resource> resources = new ArrayList();
try (ScanResult scanResult = new ClassGraph().acceptPaths("/").scan()) {
ResourceList rl = scanResult.getResourcesWithPath(removePrefix(path));
rl.forEachByteArrayIgnoringIOException((res, bytes) -> {
URI uri = res.getURI();
if ("file".equals(uri.getScheme())) {
File found = Paths.get(uri).toFile();
resources.add(new FileResource(found, true, res.getPath()));
} else {
resources.add(new JarResource(bytes, res.getPath()));
}
});
List<Resource> resources = new ArrayList<>();
ResourceList rl = scanResult.getResourcesWithPath(path);
if (rl == null) {
rl = ResourceList.emptyList();
}
rl.forEachByteArrayIgnoringIOException((res, bytes) -> {
URI uri = res.getURI();
if ("file".equals(uri.getScheme())) {
File found = Paths.get(uri).toFile();
resources.add(new FileResource(found, true, res.getPath()));
} else {
resources.add(new JarResource(bytes, res.getPath()));
}
});
if (resources.isEmpty()) {
throw new RuntimeException("not found: " + path);
}
Expand Down

0 comments on commit b716ca0

Please sign in to comment.