Skip to content

Commit 71dc07b

Browse files
authored
Fix loading of YAML recipes on Windows (#6575)
1 parent 532ff36 commit 71dc07b

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

rewrite-core/src/main/java/org/openrewrite/marketplace/YamlRecipeBundleResolver.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
import java.io.IOException;
2121
import java.io.InputStream;
22-
import java.io.UncheckedIOException;
2322
import java.net.URI;
2423
import java.nio.file.Files;
24+
import java.nio.file.Path;
2525
import java.nio.file.Paths;
2626
import java.util.Properties;
2727

@@ -36,12 +36,23 @@ public String getEcosystem() {
3636

3737
@Override
3838
public RecipeBundleReader resolve(RecipeBundle bundle) {
39-
try (InputStream is = Files.exists(Paths.get(bundle.getPackageName())) ?
40-
Files.newInputStream(Paths.get(bundle.getPackageName())) :
41-
URI.create(bundle.getPackageName()).toURL().openStream()) {
42-
return new YamlRecipeBundleReader(bundle, is, URI.create(bundle.getPackageName()), properties);
43-
} catch (IOException e) {
44-
throw new UncheckedIOException(e);
39+
try {
40+
Path path = Paths.get(bundle.getPackageName());
41+
if (Files.exists(path)) {
42+
try (InputStream is = Files.newInputStream(path)) {
43+
return new YamlRecipeBundleReader(bundle, is, path.toUri(), properties);
44+
}
45+
}
46+
} catch (Exception ignored) {
47+
}
48+
49+
try {
50+
URI resource = URI.create(bundle.getPackageName());
51+
try (InputStream is = resource.toURL().openStream()) {
52+
return new YamlRecipeBundleReader(bundle, is, resource, properties);
53+
}
54+
} catch (Exception e) {
55+
throw new RuntimeException(e);
4556
}
4657
}
4758
}

0 commit comments

Comments
 (0)