Polish
This commit is contained in:
parent
f1c893e523
commit
c22018aaa1
|
@ -17,11 +17,13 @@
|
||||||
package org.springframework.boot;
|
package org.springframework.boot;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.JarURLConnection;
|
import java.net.JarURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.security.CodeSource;
|
||||||
import java.security.ProtectionDomain;
|
import java.security.ProtectionDomain;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
@ -162,15 +164,13 @@ class StartupInfoLogger {
|
||||||
try {
|
try {
|
||||||
ProtectionDomain protectionDomain = (this.sourceClass == null ? getClass()
|
ProtectionDomain protectionDomain = (this.sourceClass == null ? getClass()
|
||||||
: this.sourceClass).getProtectionDomain();
|
: this.sourceClass).getProtectionDomain();
|
||||||
|
CodeSource codeSource = protectionDomain.getCodeSource();
|
||||||
|
if (codeSource == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
URL location = protectionDomain.getCodeSource().getLocation();
|
URL location = protectionDomain.getCodeSource().getLocation();
|
||||||
File file;
|
|
||||||
URLConnection connection = location.openConnection();
|
URLConnection connection = location.openConnection();
|
||||||
if (connection instanceof JarURLConnection) {
|
File file = getFile(location, connection);
|
||||||
file = new File(((JarURLConnection) connection).getJarFile().getName());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
file = new File(location.getPath());
|
|
||||||
}
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
@ -180,6 +180,13 @@ class StartupInfoLogger {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File getFile(URL location, URLConnection connection) throws IOException {
|
||||||
|
if (connection instanceof JarURLConnection) {
|
||||||
|
return new File(((JarURLConnection) connection).getJarFile().getName());
|
||||||
|
}
|
||||||
|
return new File(location.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
private String getValue(String prefix, Callable<Object> call) {
|
private String getValue(String prefix, Callable<Object> call) {
|
||||||
return getValue(prefix, call, "");
|
return getValue(prefix, call, "");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue