changeset 1482:e3d4b4e9f37c

Made headless detection softer
author Jiri Vanek <jvanek@redhat.com>
date Mon, 10 Sep 2018 17:34:00 +0200
parents bcbef8d7bbd6
children 96c91c6c1bb3
files ChangeLog netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
diffstat 2 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon May 14 17:15:38 2018 +0200
+++ b/ChangeLog	Mon Sep 10 17:34:00 2018 +0200
@@ -1,3 +1,9 @@
+2018-05-24  Jiri Vanek <jvanek@redhat.com>
+
+	Made headless detection softer
+	* netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: JWindow().getOwner() repalced by GraphicsEnvironment.isHeadless()
+	JWindow().getOwner() was failing on headfull systems after headless check itself, on NPE.
+
 2018-05-14  Jiri Vanek <jvanek@redhat.com>
 
 	* netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java: getDocumentBase now returns codeBase as fallback when 
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java	Mon May 14 17:15:38 2018 +0200
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java	Mon Sep 10 17:34:00 2018 +0200
@@ -19,6 +19,9 @@
 import static net.sourceforge.jnlp.runtime.Translator.R;
 
 import java.awt.EventQueue;
+import java.awt.GraphicsEnvironment;
+import static java.awt.GraphicsEnvironment.isHeadless;
+import java.awt.HeadlessException;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -741,8 +744,10 @@
             }
             if (!headless) {
                 try {
-                    new JWindow().getOwner();
-                } catch (Exception ex) {
+                    if (GraphicsEnvironment.isHeadless()) {
+                        throw new HeadlessException();
+                    }
+                } catch (HeadlessException ex) {
                     headless = true;
                     OutputController.getLogger().log(ex);
                     OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, Translator.R("HEADLESS_MISSCONFIGURED"));