[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-distro-pkg-dev
Subject:    /hg/icedtea-web: Splashscreen error report made more detailed by...
From:       jvanek () icedtea ! classpath ! org
Date:       2013-01-30 15:50:42
Message-ID: hg.f321ab6fb6c5.1359561042.8643924302249223276 () icedtea ! classpath ! org
[Download RAW message or body]

changeset f321ab6fb6c5 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=f321ab6fb6c5
author: Jiri Vanek <jvanek@redhat.com>
date: Wed Jan 30 16:51:08 2013 +0100

	Splashscreen error report made more detailed by stored LaunchErrors
	* netx/net/sourceforge/jnlp/LaunchException.java: (LaunchExceptionWithStamp)
	new inner class for storing timestamp togetehr with error.
	(launchExceptionChain) new static list to capture LaunchErrors during
	runtime.
	* /netx/net/sourceforge/jnlp/resources/Messages.properties:
	* netx/net/sourceforge/jnlp/resources/Messages_cs_CZ.properties:
	Added explanation string
	* netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java:
	Is now displaying launchExceptionChain in its error report and is copying
	it to clipboard.
	* tests/unit/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialogTest.java:
  (getTextTest) adapted calls of getText for new Date.


diffstat:

 ChangeLog                                                                            \
|  16 ++  netx/net/sourceforge/jnlp/LaunchException.java                              \
|  43 +++++++  netx/net/sourceforge/jnlp/resources/Messages.properties                \
|   1 +  netx/net/sourceforge/jnlp/resources/Messages_cs_CZ.properties                \
|   3 +-  netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java \
|  60 +++++++++-  tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialogTest.java \
|   9 +-  6 files changed, 123 insertions(+), 9 deletions(-)

diffs (282 lines):

diff -r 74a70e0b15ef -r f321ab6fb6c5 ChangeLog
--- a/ChangeLog	Mon Jan 28 11:38:34 2013 -0500
+++ b/ChangeLog	Wed Jan 30 16:51:08 2013 +0100
@@ -1,3 +1,19 @@
+2013-01-30  Jiri Vanek  <jvanek@redhat.com>
+
+	Splashscreen error report made more detailed by stored LaunchErrors
+	* netx/net/sourceforge/jnlp/LaunchException.java: (LaunchExceptionWithStamp)
+	new inner class for storing timestamp togetehr with error.
+	(launchExceptionChain) new static list to capture LaunchErrors during
+	runtime.
+	* /netx/net/sourceforge/jnlp/resources/Messages.properties: 
+	* netx/net/sourceforge/jnlp/resources/Messages_cs_CZ.properties:
+	Added explanation string
+	* netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java:
 +	Is now displaying launchExceptionChain in its error report and is copying 
+	it to clipboard.
+	* tests/unit/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialogTest.java:
 +	(getTextTest) adapted calls of getText for new Date.
+
 2013-01-28 Adam Domurad  <adomurad@redhat.com>
 
 	Fix PR1157: Applets can hang browser after fatal exception
diff -r 74a70e0b15ef -r f321ab6fb6c5 netx/net/sourceforge/jnlp/LaunchException.java
--- a/netx/net/sourceforge/jnlp/LaunchException.java	Mon Jan 28 11:38:34 2013 -0500
+++ b/netx/net/sourceforge/jnlp/LaunchException.java	Wed Jan 30 16:51:08 2013 +0100
@@ -16,6 +16,11 @@
 
 package net.sourceforge.jnlp;
 
+import java.util.Collections;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+
 /**
  * Thrown when a JNLP application, applet, or installer could not
  * be created.
@@ -25,6 +30,29 @@
  */
 public class LaunchException extends Exception {
 
+
+    public static class LaunchExceptionWithStamp{
+        private final LaunchException ex;
+        private final Date stamp;
+
+        private LaunchExceptionWithStamp(LaunchException ex) {
+            this.ex=ex;
+            this.stamp=new Date();
+        }
+
+        public LaunchException getEx() {
+            return ex;
+        }
+
+        public Date getStamp() {
+            return stamp;
+        }
+
+
+
+    }
+    private static final List<LaunchExceptionWithStamp> launchExceptionChain = \
Collections.synchronizedList(new LinkedList<LaunchExceptionWithStamp>()); +
     private static final long serialVersionUID = 7283827853612357423L;
 
     /** the file being launched */
@@ -54,6 +82,7 @@
         this.summary = summary;
         this.description = description;
         this.severity = severity;
+        saveLaunchException(this);
     }
 
     /**
@@ -61,6 +90,7 @@
      */
     public LaunchException(Throwable cause) {
         super(cause);
+        saveLaunchException(this);
     }
 
     /**
@@ -68,6 +98,7 @@
      */
     public LaunchException(String message, Throwable cause) {
         super(message, cause);
+        saveLaunchException(this);
     }
 
     /**
@@ -78,6 +109,7 @@
      */
     public LaunchException(String message) {
         super(message);
+        saveLaunchException(this);
     }
 
     /**
@@ -117,4 +149,15 @@
         return severity;
     }
 
+    private synchronized void saveLaunchException(LaunchException ex) {
+        launchExceptionChain.add(new LaunchExceptionWithStamp(ex));
+
+    }
+
+    public synchronized static List<LaunchExceptionWithStamp> \
getLaunchExceptionChain() { +        return launchExceptionChain;
+    }
+    
+    
+
 }
diff -r 74a70e0b15ef -r f321ab6fb6c5 \
                netx/net/sourceforge/jnlp/resources/Messages.properties
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties	Mon Jan 28 11:38:34 \
                2013 -0500
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties	Wed Jan 30 16:51:08 \
2013 +0100 @@ -473,3 +473,4 @@
 SPLASHdefaultHomepage = Unspecified homepage, verify source rather
 SPLASHerrorInInformation = Error during loading of information element, verify \
source rather  SPLASHmissingInformation = Information element is missing, verify \
source rather +SPLASHchainWas = This is the list of exceptions that occurred \
launching your applet. Please note, those exceptions can be from multiple applets. \
                For a good bug report, be sure to run only one applet.
diff -r 74a70e0b15ef -r f321ab6fb6c5 \
                netx/net/sourceforge/jnlp/resources/Messages_cs_CZ.properties
--- a/netx/net/sourceforge/jnlp/resources/Messages_cs_CZ.properties	Mon Jan 28 \
                11:38:34 2013 -0500
+++ b/netx/net/sourceforge/jnlp/resources/Messages_cs_CZ.properties	Wed Jan 30 \
16:51:08 2013 +0100 @@ -468,4 +468,5 @@
 SPLASHanotherInfo= Dal\u0161\u00ed dostupn\u00e9 informace
 SPLASHdefaultHomepage = Nespecifikovan\u00e1 domovsk\u00e1 st\u00e1nka, je \
doporu\u010deno zkontrolovat zdroj  SPLASHerrorInInformation = Chyba \
na\u010d\u00edt\u00e1n\u00ed informa\u010dn\u00edho elementu, je doporu\u010deno \
                zkontrolovat zdroj
-SPLASHmissingInformation = Informa\u010dn\u00ed element chyb\u00fd, je \
doporu\u010deno zkontrolovat zdroj \ No newline at end of file
+SPLASHmissingInformation = Informa\u010dn\u00ed element chyb\u00fd, je \
doporu\u010deno zkontrolovat zdroj +SPLASHchainWas = N\u00ed\u017ee je seznam \
v\u00fdjimek, kter\u00e9 prov\u00e1zely start appeltu. Tento seznam ale \
m\u016f\u017er poch\u00e1zet z n\u011bkolik\u00e1 r\u016fzn\u00fdch applet\u016f. Pro \
dob\u00e9 chybo\u00e9 hl\u00e1\u0161en\u00ed stoj\u00e9 za to pustit applet \
izolovane. \ No newline at end of file
diff -r 74a70e0b15ef -r f321ab6fb6c5 \
                netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java
                
--- a/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java	Mon \
                Jan 28 11:38:34 2013 -0500
+++ b/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java	Wed \
Jan 30 16:51:08 2013 +0100 @@ -42,6 +42,8 @@
 import java.awt.event.WindowEvent;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.text.DateFormat;
+import java.util.Date;
 import java.util.List;
 import javax.swing.BorderFactory;
 import javax.swing.GroupLayout;
@@ -60,6 +62,7 @@
 import javax.swing.WindowConstants;
 import javax.swing.event.HyperlinkEvent;
 import javax.swing.event.HyperlinkListener;
+import net.sourceforge.jnlp.LaunchException;
 import net.sourceforge.jnlp.runtime.Translator;
 
 public class JEditorPaneBasedExceptionDialog extends JDialog implements \
HyperlinkListener { @@ -78,15 +81,19 @@
     // End of components declaration
     private final String message;
     private final Throwable exception;
+    private final Date shown;
+    private final String anotherInfo;
 
     /** Creates new form JEditorPaneBasedExceptionDialog */
     public JEditorPaneBasedExceptionDialog(java.awt.Frame parent, boolean modal, \
Throwable ex, InformationElement information, String anotherInfo) {  super(parent, \
modal); +        shown = new Date();
         initComponents();
         htmlErrorAndHelpPanel.setContentType("text/html");
         htmlErrorAndHelpPanel.setEditable(false);
+        this.anotherInfo=anotherInfo;
         List<String> l = infoElementToList(information);
-        this.message = getText(ex, l, anotherInfo);
+        this.message = getText(ex, l, anotherInfo, shown);
         this.exception = ex;
         if (exception == null) {
             closeAndCopyButton.setVisible(false);
@@ -199,7 +206,7 @@
     private void copyAndCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {
         if (exception != null) {
             try {
-                StringSelection data = new \
StringSelection(getExceptionStackTraceAsString(exception)); +                \
StringSelection data = new \
StringSelection(anotherInfo+"\n"+shown.toString()+"\n"+getExceptionStackTraceAsString(exception)+addPlainChain());
                
                 Clipboard clipboard = \
Toolkit.getDefaultToolkit().getSystemClipboard();  clipboard.setContents(data, data);
             } catch (Exception ex) {
@@ -241,7 +248,7 @@
         });
     }
 
-    static String getText(Throwable ex, List<String> l, String anotherInfo) {
+    static String getText(Throwable ex, List<String> l, String anotherInfo,Date \
shown) {  StringBuilder s = new StringBuilder("<html><body>");
         String info = "<p>"
                 + Translator.R(InfoItem.SPLASH + "mainL1", createLink())
@@ -258,9 +265,11 @@
                     + Translator.R(InfoItem.SPLASH + "mainL4")
                     + " </p>\n"
                     + info + formatListInfoList(l) + formatInfo(anotherInfo)
+                    +"<br>"+DateFormat.getInstance().format(shown)+"<br>"
                     + "<p>"
                     + Translator.R(InfoItem.SPLASH + "exWas")
-                    + " <br/>\n" + "<pre>" + getExceptionStackTraceAsString(ex) + \
"</pre>"; +                    + " <br/>\n" + "<pre>" + \
getExceptionStackTraceAsString(ex) + "</pre>" +                    + addChain();
 
 
         } else {
@@ -354,4 +363,47 @@
     }
 
 
+    private static String addChain() {
+        if (LaunchException.getLaunchExceptionChain().isEmpty()) {
+            return "";
+        }
+        return Translator.R(InfoItem.SPLASH + "chainWas")
+                + " <br/>\n" + "<pre>" + getChainAsString(true) + "</pre>";
+
+    }
+
+    private static String addPlainChain() {
+        if (LaunchException.getLaunchExceptionChain().isEmpty()) {
+            return "";
+        }
+        return "\n Chain: \n" + getChainAsString(false);
+
+    }
+
+    private static String getChainAsString(boolean formatTime) {
+        return getChainAsString(LaunchException.getLaunchExceptionChain(), \
formatTime); +    }
+
+    private static String \
getChainAsString(List<LaunchException.LaunchExceptionWithStamp> launchExceptionChain, \
boolean formatTime) { +        String s = "";
+        if (launchExceptionChain != null) {
+            int i = 0;
+            for (LaunchException.LaunchExceptionWithStamp launchException : \
launchExceptionChain) { +                i++;
+                s = s + i + ") at " + formatTime(launchException.getStamp(), \
formatTime) + "\n" + getExceptionStackTraceAsString(launchException.getEx()); +       \
} +        }
+        return s;
+    }
+
+    private static String formatTime(Date dateTime, boolean formatTime) {
+        if (dateTime == null) {
+            return "unknown time";
+        }
+        if (formatTime) {
+            return DateFormat.getInstance().format(dateTime);
+        } else {
+            return dateTime.toString();
+        }
+    }
 }
diff -r 74a70e0b15ef -r f321ab6fb6c5 \
tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialogTest.java
                
--- a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialogTest.java	Mon \
                Jan 28 11:38:34 2013 -0500
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialogTest.java	Wed \
Jan 30 16:51:08 2013 +0100 @@ -40,6 +40,7 @@
 import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import net.sourceforge.jnlp.runtime.Translator;
 import org.junit.Assert;
@@ -107,10 +108,10 @@
 
     @Test
     public void getTextTest() {
-        String s1 = JEditorPaneBasedExceptionDialog.getText(ex, l, ai);
-        String s2 = JEditorPaneBasedExceptionDialog.getText(ex, l, null);
-        String s3 = JEditorPaneBasedExceptionDialog.getText(ex, null, ai);
-        String s4 = JEditorPaneBasedExceptionDialog.getText(null, l, ai);
+        String s1 = JEditorPaneBasedExceptionDialog.getText(ex, l, ai, new Date());
+        String s2 = JEditorPaneBasedExceptionDialog.getText(ex, l, null, new \
Date()); +        String s3 = JEditorPaneBasedExceptionDialog.getText(ex, null, ai, \
new Date()); +        String s4 = JEditorPaneBasedExceptionDialog.getText(null, l, \
ai, new Date());  assertHtml(s1);
         assertHtml(s2);
         assertHtml(s3);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic