Skip to content

Commit 147ca8d

Browse files
committed
add FileClasspathEntry validation
Signed-off-by: Andrey Litvitski <[email protected]>
1 parent 27e9bc6 commit 147ca8d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

spring-boot-testjars/src/main/java/org/springframework/experimental/boot/server/exec/FileClasspathEntry.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ public class FileClasspathEntry implements ClasspathEntry {
2424

2525
private final File file;
2626

27-
public FileClasspathEntry(String file) {
28-
this(new File(file));
27+
public FileClasspathEntry(String filePath) {
28+
File file = new File(filePath);
29+
if (!file.isDirectory() && !file.getName().toLowerCase().endsWith("jar")) {
30+
throw new IllegalArgumentException("File must be a jar file or directory");
31+
}
32+
this.file = file;
2933
}
3034

3135
public FileClasspathEntry(File file) {

0 commit comments

Comments
 (0)