Handle null CodeSource when determining Spring Boot version

Closes gh-16956
See gh-16182
pull/16972/head
Andy Wilkinson 6 years ago
parent a5537bd2e1
commit 5e62faf720

@ -21,6 +21,7 @@ import java.io.IOException;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.security.CodeSource;
import java.util.jar.Attributes;
import java.util.jar.Attributes.Name;
import java.util.jar.JarFile;
@ -62,8 +63,12 @@ public final class SpringBootVersion {
if (implementationVersion != null) {
return implementationVersion;
}
URL codeSourceLocation = SpringBootVersion.class.getProtectionDomain()
.getCodeSource().getLocation();
CodeSource codeSource = SpringBootVersion.class.getProtectionDomain()
.getCodeSource();
if (codeSource == null) {
return null;
}
URL codeSourceLocation = codeSource.getLocation();
try {
URLConnection connection = codeSourceLocation.openConnection();
if (connection instanceof JarURLConnection) {

Loading…
Cancel
Save