Skip to content

Commit 1794cda

Browse files
committed
chore: check for valid id in acceptFolder
Also make sure the LinkedJdkProvider does not use `acceptFolder` when getting the list of available JDKs.
1 parent 59c51dd commit 1794cda

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/main/java/dev/jbang/devkitman/jdkproviders/BaseFoldersJdkProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected String jdkId(String name) {
134134
}
135135

136136
protected boolean acceptFolder(@NonNull Path jdkFolder) {
137-
return JavaUtils.hasJavacCmd(jdkFolder);
137+
return isValidId(jdkFolder.getFileName().toString()) && JavaUtils.hasJavacCmd(jdkFolder);
138138
}
139139

140140
@Override

src/main/java/dev/jbang/devkitman/jdkproviders/LinkedJdkProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public boolean canUse() {
5050
String[] parts = idOrToken.split("@", 2);
5151
if (parts.length == 2 && isValidId(parts[0]) && isValidPath(parts[1])) {
5252
Path jdkPath = Paths.get(parts[1]);
53-
if (super.acceptFolder(jdkPath)) {
53+
if (JavaUtils.hasJavacCmd(jdkPath)) {
5454
Optional<String> version = JavaUtils.resolveJavaVersionStringFromPath(jdkPath);
5555
if (!version.isPresent()) {
5656
throw new IllegalArgumentException(

0 commit comments

Comments
 (0)