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;
|
private static boolean enabled = false;
|
||||||
|
|
||||||
|
|
||||||
public static synchronized JGoogleAnalyticsTracker getTracker() {
|
public static synchronized JGoogleAnalyticsTracker getTracker() throws Throwable {
|
||||||
if (tracker != null)
|
if (tracker != null)
|
||||||
return tracker;
|
return tracker;
|
||||||
|
|
||||||
|
@ -66,10 +66,18 @@ public class Analytics {
|
||||||
|
|
||||||
if (currentView == null) {
|
if (currentView == null) {
|
||||||
// track application startup
|
// track application startup
|
||||||
|
try {
|
||||||
getTracker().trackPageViewFromSearch(view, title, host, getJavaRuntimeIdentifier(), getDeploymentMethod());
|
getTracker().trackPageViewFromSearch(view, title, host, getJavaRuntimeIdentifier(), getDeploymentMethod());
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Logger.getLogger(Analytics.class.getName()).log(Level.WARNING, e.toString());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// track application state change
|
// track application state change
|
||||||
|
try {
|
||||||
getTracker().trackPageViewFromReferrer(view, title, host, host, currentView);
|
getTracker().trackPageViewFromReferrer(view, title, host, host, currentView);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Logger.getLogger(Analytics.class.getName()).log(Level.WARNING, e.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentView = view;
|
currentView = view;
|
||||||
|
@ -85,7 +93,11 @@ public class Analytics {
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
try {
|
||||||
getTracker().trackEvent(normalize(category), normalize(action), normalize(label), value);
|
getTracker().trackEvent(normalize(category), normalize(action), normalize(label), value);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Logger.getLogger(Analytics.class.getName()).log(Level.WARNING, e.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,9 +146,11 @@ public class Analytics {
|
||||||
|
|
||||||
|
|
||||||
private static String getUserAgent() {
|
private static String getUserAgent() {
|
||||||
String wm = null;
|
// initialize with default values
|
||||||
String os = null;
|
String wm = System.getProperty("os.name");
|
||||||
|
String os = System.getProperty("os.name") + " " + System.getProperty("os.version");
|
||||||
|
|
||||||
|
try {
|
||||||
if (Platform.isWindows()) {
|
if (Platform.isWindows()) {
|
||||||
wm = "Windows";
|
wm = "Windows";
|
||||||
os = "Windows NT " + System.getProperty("os.version");
|
os = "Windows NT " + System.getProperty("os.version");
|
||||||
|
@ -153,9 +167,9 @@ public class Analytics {
|
||||||
} else if (Platform.isMac()) {
|
} else if (Platform.isMac()) {
|
||||||
wm = "Macintosh";
|
wm = "Macintosh";
|
||||||
os = System.getProperty("os.name");
|
os = System.getProperty("os.name");
|
||||||
} else {
|
}
|
||||||
wm = System.getProperty("os.name");
|
} catch (Throwable e) {
|
||||||
os = System.getProperty("os.name") + " " + System.getProperty("os.version");
|
// 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"));
|
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();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final String VISITOR_ID = "visitorId";
|
private static final String VISITOR_ID = "visitorId";
|
||||||
private static final String TIMESTAMP_FIRST = "timestampFirst";
|
private static final String TIMESTAMP_FIRST = "timestampFirst";
|
||||||
private static final String TIMESTAMP_LAST = "timestampLast";
|
private static final String TIMESTAMP_LAST = "timestampLast";
|
||||||
|
@ -252,7 +265,6 @@ public class Analytics {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static {
|
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)
|
// 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);
|
Logger.getLogger("com.dmurph.tracking").setLevel(Level.OFF);
|
||||||
|
|
|
@ -66,7 +66,11 @@ public enum NativeRenameAction implements RenameAction {
|
||||||
|
|
||||||
|
|
||||||
public static boolean isSupported() {
|
public static boolean isSupported() {
|
||||||
|
try {
|
||||||
return Platform.isWindows();
|
return Platform.isWindows();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
package net.sourceforge.filebot.archive;
|
package net.sourceforge.filebot.archive;
|
||||||
|
|
||||||
|
|
||||||
import com.sun.jna.Platform;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import net.sf.sevenzipjbinding.IArchiveOpenCallback;
|
import net.sf.sevenzipjbinding.IArchiveOpenCallback;
|
||||||
import net.sf.sevenzipjbinding.IInStream;
|
import net.sf.sevenzipjbinding.IInStream;
|
||||||
|
@ -10,6 +10,8 @@ import net.sf.sevenzipjbinding.ISevenZipInArchive;
|
||||||
import net.sf.sevenzipjbinding.SevenZip;
|
import net.sf.sevenzipjbinding.SevenZip;
|
||||||
import net.sf.sevenzipjbinding.SevenZipNativeInitializationException;
|
import net.sf.sevenzipjbinding.SevenZipNativeInitializationException;
|
||||||
|
|
||||||
|
import com.sun.jna.Platform;
|
||||||
|
|
||||||
|
|
||||||
public class SevenZipLoader {
|
public class SevenZipLoader {
|
||||||
|
|
||||||
|
@ -22,10 +24,14 @@ public class SevenZipLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize 7z-JBinding native libs
|
// initialize 7z-JBinding native libs
|
||||||
|
try {
|
||||||
try {
|
try {
|
||||||
if (Platform.isWindows()) {
|
if (Platform.isWindows()) {
|
||||||
System.loadLibrary(Platform.is64Bit() ? "libgcc_s_sjlj-1" : "mingwm10");
|
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");
|
System.loadLibrary("7-Zip-JBinding");
|
||||||
SevenZip.initLoadedLibraries(); // NATIVE LIBS MUST BE LOADED WITH SYSTEM CLASSLOADER
|
SevenZip.initLoadedLibraries(); // NATIVE LIBS MUST BE LOADED WITH SYSTEM CLASSLOADER
|
||||||
|
|
|
@ -119,11 +119,11 @@ def XML(bc) {
|
||||||
|
|
||||||
|
|
||||||
// Shell helper
|
// Shell helper
|
||||||
import static com.sun.jna.Platform.*
|
import com.sun.jna.Platform
|
||||||
|
|
||||||
def execute(Object... args) {
|
def execute(Object... args) {
|
||||||
def cmd = args.toList()*.toString()
|
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
|
// normalize file separator for windows and run with cmd so any executable in PATH will just work
|
||||||
cmd = ['cmd', '/c'] + cmd
|
cmd = ['cmd', '/c'] + cmd
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,15 @@ import com.sun.jna.WString;
|
||||||
public class MediaInfo implements Closeable {
|
public class MediaInfo implements Closeable {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
try {
|
||||||
// libmediainfo for linux depends on libzen
|
// libmediainfo for linux depends on libzen
|
||||||
if (Platform.isLinux()) {
|
if (Platform.isLinux()) {
|
||||||
try {
|
|
||||||
// We need to load dependencies first, because we know where our native libs are (e.g. Java Web Start Cache).
|
// 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.
|
// If we do not, the system will look for dependencies, but only in the library path.
|
||||||
NativeLibrary.getInstance("zen");
|
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