mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-02 08:25:02 -04:00
JNAs Platform might throw an LinkageError in it's initializer when used on certain headless platform, make sure to gracefully ignore any and all errors caused by JNAs Platform.
This commit is contained in:
parent
417d1f6256
commit
c4082db18d
@ -30,7 +30,7 @@ public class Analytics {
|
||||
private static boolean enabled = false;
|
||||
|
||||
|
||||
public static synchronized JGoogleAnalyticsTracker getTracker() {
|
||||
public static synchronized JGoogleAnalyticsTracker getTracker() throws Throwable {
|
||||
if (tracker != null)
|
||||
return tracker;
|
||||
|
||||
@ -66,10 +66,18 @@ public class Analytics {
|
||||
|
||||
if (currentView == null) {
|
||||
// track application startup
|
||||
getTracker().trackPageViewFromSearch(view, title, host, getJavaRuntimeIdentifier(), getDeploymentMethod());
|
||||
try {
|
||||
getTracker().trackPageViewFromSearch(view, title, host, getJavaRuntimeIdentifier(), getDeploymentMethod());
|
||||
} catch (Throwable e) {
|
||||
Logger.getLogger(Analytics.class.getName()).log(Level.WARNING, e.toString());
|
||||
}
|
||||
} else {
|
||||
// track application state change
|
||||
getTracker().trackPageViewFromReferrer(view, title, host, host, currentView);
|
||||
try {
|
||||
getTracker().trackPageViewFromReferrer(view, title, host, host, currentView);
|
||||
} catch (Throwable e) {
|
||||
Logger.getLogger(Analytics.class.getName()).log(Level.WARNING, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
currentView = view;
|
||||
@ -85,7 +93,11 @@ public class Analytics {
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
getTracker().trackEvent(normalize(category), normalize(action), normalize(label), value);
|
||||
try {
|
||||
getTracker().trackEvent(normalize(category), normalize(action), normalize(label), value);
|
||||
} catch (Throwable e) {
|
||||
Logger.getLogger(Analytics.class.getName()).log(Level.WARNING, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -134,28 +146,30 @@ public class Analytics {
|
||||
|
||||
|
||||
private static String getUserAgent() {
|
||||
String wm = null;
|
||||
String os = null;
|
||||
// initialize with default values
|
||||
String wm = System.getProperty("os.name");
|
||||
String os = System.getProperty("os.name") + " " + System.getProperty("os.version");
|
||||
|
||||
if (Platform.isWindows()) {
|
||||
wm = "Windows";
|
||||
os = "Windows NT " + System.getProperty("os.version");
|
||||
} else if (Platform.isX11()) {
|
||||
wm = "X11";
|
||||
if (Platform.isLinux())
|
||||
os = "Linux " + System.getProperty("os.arch");
|
||||
else if (Platform.isSolaris())
|
||||
os = "SunOS " + System.getProperty("os.version");
|
||||
else if (Platform.isFreeBSD())
|
||||
os = "FreeBSD";
|
||||
else if (Platform.isOpenBSD())
|
||||
os = "OpenBSD";
|
||||
} else if (Platform.isMac()) {
|
||||
wm = "Macintosh";
|
||||
os = System.getProperty("os.name");
|
||||
} else {
|
||||
wm = System.getProperty("os.name");
|
||||
os = System.getProperty("os.name") + " " + System.getProperty("os.version");
|
||||
try {
|
||||
if (Platform.isWindows()) {
|
||||
wm = "Windows";
|
||||
os = "Windows NT " + System.getProperty("os.version");
|
||||
} else if (Platform.isX11()) {
|
||||
wm = "X11";
|
||||
if (Platform.isLinux())
|
||||
os = "Linux " + System.getProperty("os.arch");
|
||||
else if (Platform.isSolaris())
|
||||
os = "SunOS " + System.getProperty("os.version");
|
||||
else if (Platform.isFreeBSD())
|
||||
os = "FreeBSD";
|
||||
else if (Platform.isOpenBSD())
|
||||
os = "OpenBSD";
|
||||
} else if (Platform.isMac()) {
|
||||
wm = "Macintosh";
|
||||
os = System.getProperty("os.name");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// ignore any Platform detection issues and especially ignore LinkageErrors that might occur on headless machines
|
||||
}
|
||||
|
||||
return String.format("%s/%s (%s; U; %s; JRE %s)", getApplicationName(), getApplicationVersion(), wm, os, System.getProperty("java.version"));
|
||||
@ -207,7 +221,6 @@ public class Analytics {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
private static final String VISITOR_ID = "visitorId";
|
||||
private static final String TIMESTAMP_FIRST = "timestampFirst";
|
||||
private static final String TIMESTAMP_LAST = "timestampLast";
|
||||
@ -252,7 +265,6 @@ public class Analytics {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
// disable useless background logging, if it doesn't work it doesn't work, won't affect anything (putting it here works for Java 7)
|
||||
Logger.getLogger("com.dmurph.tracking").setLevel(Level.OFF);
|
||||
|
@ -66,7 +66,11 @@ public enum NativeRenameAction implements RenameAction {
|
||||
|
||||
|
||||
public static boolean isSupported() {
|
||||
return Platform.isWindows();
|
||||
try {
|
||||
return Platform.isWindows();
|
||||
} catch (Throwable e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
package net.sourceforge.filebot.archive;
|
||||
|
||||
|
||||
import com.sun.jna.Platform;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.sevenzipjbinding.IArchiveOpenCallback;
|
||||
import net.sf.sevenzipjbinding.IInStream;
|
||||
@ -10,6 +10,8 @@ import net.sf.sevenzipjbinding.ISevenZipInArchive;
|
||||
import net.sf.sevenzipjbinding.SevenZip;
|
||||
import net.sf.sevenzipjbinding.SevenZipNativeInitializationException;
|
||||
|
||||
import com.sun.jna.Platform;
|
||||
|
||||
|
||||
public class SevenZipLoader {
|
||||
|
||||
@ -23,8 +25,12 @@ public class SevenZipLoader {
|
||||
|
||||
// initialize 7z-JBinding native libs
|
||||
try {
|
||||
if (Platform.isWindows()) {
|
||||
System.loadLibrary(Platform.is64Bit() ? "libgcc_s_sjlj-1" : "mingwm10");
|
||||
try {
|
||||
if (Platform.isWindows()) {
|
||||
System.loadLibrary(Platform.is64Bit() ? "libgcc_s_sjlj-1" : "mingwm10");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Logger.getLogger(SevenZipLoader.class.getName()).warning("Failed to preload library: " + e);
|
||||
}
|
||||
|
||||
System.loadLibrary("7-Zip-JBinding");
|
||||
|
@ -119,11 +119,11 @@ def XML(bc) {
|
||||
|
||||
|
||||
// Shell helper
|
||||
import static com.sun.jna.Platform.*
|
||||
import com.sun.jna.Platform
|
||||
|
||||
def execute(Object... args) {
|
||||
def cmd = args.toList()*.toString()
|
||||
if (isWindows()) {
|
||||
if (tryQuietly{ Platform.isWindows() }) {
|
||||
// normalize file separator for windows and run with cmd so any executable in PATH will just work
|
||||
cmd = ['cmd', '/c'] + cmd
|
||||
}
|
||||
|
@ -21,15 +21,15 @@ import com.sun.jna.WString;
|
||||
public class MediaInfo implements Closeable {
|
||||
|
||||
static {
|
||||
// libmediainfo for linux depends on libzen
|
||||
if (Platform.isLinux()) {
|
||||
try {
|
||||
try {
|
||||
// libmediainfo for linux depends on libzen
|
||||
if (Platform.isLinux()) {
|
||||
// We need to load dependencies first, because we know where our native libs are (e.g. Java Web Start Cache).
|
||||
// If we do not, the system will look for dependencies, but only in the library path.
|
||||
NativeLibrary.getInstance("zen");
|
||||
} catch (LinkageError e) {
|
||||
Logger.getLogger(MediaInfo.class.getName()).warning("Failed to preload libzen");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Logger.getLogger(MediaInfo.class.getName()).warning("Failed to preload libzen");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user