Skip to content

Commit 5880820

Browse files
committed
Disable URLConnection cache
This commit further implements the ability to disable JAR file caching when loading Smithy models. This is necessary to make loading models from JARs when using build tools like Gradle more reliable.
1 parent c7148b9 commit 5880820

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

smithy-model/src/main/java/software/amazon/smithy/model/loader/ModelAssembler.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,11 @@ public ModelAssembler addImport(URL url) {
304304
Objects.requireNonNull(url, "The provided url to ModelAssembler#addImport was null");
305305
inputStreamModels.put(url.toExternalForm(), () -> {
306306
try {
307-
return url.openStream();
307+
URLConnection connection = url.openConnection();
308+
if (properties.containsKey(ModelAssembler.DISABLE_JAR_CACHE)) {
309+
connection.setUseCaches(false);
310+
}
311+
return connection.getInputStream();
308312
} catch (IOException | UncheckedIOException e) {
309313
throw new ModelImportException("Unable to open Smithy model import URL: " + url.toExternalForm(), e);
310314
}

0 commit comments

Comments
 (0)