Skip to content

Commit

Permalink
Merge pull request #44199 from MikeEdgar/lock-free-url-stream
Browse files Browse the repository at this point in the history
Bump smallrye-open-api to 4.0.1; Avoid Windows JAR locking
  • Loading branch information
phillip-kruger authored Nov 4, 2024
2 parents d8f1436 + 3832988 commit c90e362
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<smallrye-config.version>3.10.0</smallrye-config.version>
<smallrye-health.version>4.1.0</smallrye-health.version>
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
<smallrye-open-api.version>4.0.0</smallrye-open-api.version>
<smallrye-open-api.version>4.0.1</smallrye-open-api.version>
<smallrye-graphql.version>2.11.0</smallrye-graphql.version>
<smallrye-fault-tolerance.version>6.6.1</smallrye-fault-tolerance.version>
<smallrye-jwt.version>4.6.0</smallrye-jwt.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -936,10 +936,18 @@ Map.<String, Supplier<String>> entry("YAML", openAPI::toYAML))
}
});

@SuppressWarnings("deprecation")
openApiDocumentProducer.produce(new OpenApiDocumentBuildItem(toOpenApiDocument(finalOpenAPI)));
}

/**
* We need to use the deprecated OpenApiDocument as long as
* OpenApiDocumentBuildItem needs to be produced.
*/
@SuppressWarnings("deprecation")
OpenApiDocument toOpenApiDocument(SmallRyeOpenAPI finalOpenAPI) {
OpenApiDocument output = OpenApiDocument.newInstance();
output.set(finalOpenAPI.model());
openApiDocumentProducer.produce(new OpenApiDocumentBuildItem(output));
return output;
}

@BuildStep
Expand Down Expand Up @@ -1100,16 +1108,24 @@ private Stream<? extends InputStream> loadResources(String path, List<Pattern> i
}

private InputStream loadResource(String path, URL url) {
try (InputStream inputStream = url.openStream()) {
if (inputStream != null) {
byte[] contents = IoUtil.readBytes(inputStream);
return new ByteArrayInputStream(contents);
}
Supplier<String> msg = () -> "An error occurred while processing %s for %s".formatted(url, path);

try {
return ClassPathUtils.readStream(url, inputStream -> {
if (inputStream != null) {
try {
byte[] contents = IoUtil.readBytes(inputStream);
return new ByteArrayInputStream(contents);
} catch (IOException ioe) {
throw new UncheckedIOException(msg.get(), ioe);
}
}

return null;
});
} catch (IOException e) {
throw new UncheckedIOException("An error occurred while processing %s for %s".formatted(url, path), e);
throw new UncheckedIOException(msg.get(), e);
}

return null;
}

private boolean shouldIgnore(List<Pattern> ignorePatterns, String url) {
Expand Down Expand Up @@ -1137,6 +1153,7 @@ private List<String> getResourceFiles(Path resourcePath, Path target) {
}
} else {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
// QuarkusClassLoader will return a ByteArrayInputStream of directory entry names
try (InputStream inputStream = cl.getResourceAsStream(resourceName)) {
if (inputStream != null) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) {
Expand Down

0 comments on commit c90e362

Please sign in to comment.