| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Google Web Toolkit
Revision: 3609
Author: scottb@google.com
Date: 03 Sep 2008 17:22:53
Changes:Fixes issue #2607; TreeItemLogger now eagerly grabs exception info from a thrown exception to break lingering dependency on user code. Partial back-port from OOPHM.
Suggested by: zundel
Review by: zundel
| ... | ...@@ -41,7 +41,9 @@ | |
| 41 | 41 | * Represents an individual log event. |
| 42 | 42 | */ |
| 43 | 43 | public static class LogEvent { |
| 44 | public final Throwable caught; | |
| 44 | public final String exceptionDetail; | |
| 45 | ||
| 46 | public final String exceptionName; | |
| 45 | 47 | |
| 46 | 48 | public final HelpInfo helpInfo; |
| 47 | 49 | |
| ... | ...@@ -57,12 +59,13 @@ | |
| 57 | 59 | |
| 58 | 60 | public LogEvent(TreeItemLogger logger, boolean isBranchCommit, int index, |
| 59 | 61 | Type type, String message, Throwable caught, HelpInfo helpInfo) { |
| 62 | this.exceptionDetail = AbstractTreeLogger.getStackTraceAsString(caught); | |
| 63 | this.exceptionName = AbstractTreeLogger.getExceptionName(caught); | |
| 60 | 64 | this.logger = logger; |
| 61 | 65 | this.isBranchCommit = isBranchCommit; |
| 62 | 66 | this.index = index; |
| 63 | 67 | this.type = type; |
| 64 | 68 | this.message = message; |
| 65 | this.caught = caught; | |
| 66 | 69 | this.helpInfo = helpInfo; |
| 67 | 70 | } |
| 68 | 71 | |
| ... | ...@@ -161,13 +164,8 @@ | |
| 161 | 164 | // |
| 162 | 165 | String label = message; |
| 163 | 166 | if (label == null) { |
| 164 | if (caught != null) { | |
| 165 | label = caught.getMessage(); | |
| 166 | ||
| 167 | if (label == null || label.trim().length() == 0) { | |
| 168 | label = caught.toString(); | |
| 169 | } | |
| 170 | } | |
| 167 | assert (exceptionName != null); | |
| 168 | label = exceptionName; | |
| 171 | 169 | } |
| 172 | 170 | treeItem.setText(label); |
| 173 | 171 |
| ... | ...@@ -16,6 +16,7 @@ | |
| 16 | 16 | package com.google.gwt.dev.util.log; |
| 17 | 17 | |
| 18 | 18 | import com.google.gwt.core.ext.TreeLogger; |
| 19 | import com.google.gwt.core.ext.UnableToCompleteException; | |
| 19 | 20 | |
| 20 | 21 | import java.util.HashSet; |
| 21 | 22 | |
| ... | ...@@ -45,8 +46,12 @@ | |
| 45 | 46 | + "amount of memory, use the -Xmx flag at startup (java -Xmx128M ...)"; |
| 46 | 47 | |
| 47 | 48 | public static String getStackTraceAsString(Throwable e) { |
| 48 | // For each cause, print the requested number of entries of its stack trace, | |
| 49 | // being careful to avoid getting stuck in an infinite loop. | |
| 49 | // Show the exception info for anything other than "UnableToComplete". | |
| 50 | if (e == null || e instanceof UnableToCompleteException) { | |
| 51 | return null; | |
| 52 | } | |
| 53 | // For each cause, print the requested number of entries of its stack | |
| 54 | // trace, being careful to avoid getting stuck in an infinite loop. | |
| 50 | 55 | // |
| 51 | 56 | StringBuffer message = new StringBuffer(); |
| 52 | 57 | Throwable currentCause = e; |
| ... | ...@@ -72,6 +77,13 @@ | |
| 72 | 77 | return message.toString(); |
| 73 | 78 | } |
| 74 | 79 | |
| 80 | protected static String getExceptionName(Throwable e) { | |
| 81 | if (e == null || e instanceof UnableToCompleteException) { | |
| 82 | return null; | |
| 83 | } | |
| 84 | return e.getClass().getSimpleName(); | |
| 85 | } | |
| 86 | ||
| 75 | 87 | public int indexWithinMyParent; |
| 76 | 88 | |
| 77 | 89 | private TreeLogger.Type logLevel = TreeLogger.ALL; |
| ... | ...@@ -15,7 +15,6 @@ | |
| 15 | 15 | */ |
| 16 | 16 | package com.google.gwt.dev.util.log; |
| 17 | 17 | |
| 18 | import com.google.gwt.core.ext.UnableToCompleteException; | |
| 19 | 18 | import com.google.gwt.core.ext.TreeLogger.HelpInfo; |
| 20 | 19 | import com.google.gwt.dev.shell.BrowserWidget; |
| 21 | 20 | import com.google.gwt.dev.util.log.TreeItemLogger.LogEvent; |
| ... | ...@@ -317,11 +316,8 @@ | |
| 317 | 316 | |
| 318 | 317 | // Show the exception info for anything other than "UnableToComplete". |
| 319 | 318 | // |
| 320 | if (logEvent != null && logEvent.caught != null) { | |
| 321 | if (!(logEvent.caught instanceof UnableToCompleteException)) { | |
| 322 | String stackTrace = AbstractTreeLogger.getStackTraceAsString(logEvent.caught); | |
| 323 | sb.append(stackTrace); | |
| 324 | } | |
| 319 | if (logEvent != null && logEvent.exceptionDetail != null) { | |
| 320 | sb.append(logEvent.exceptionDetail); | |
| 325 | 321 | } |
| 326 | 322 | |
| 327 | 323 | details.setText(sb.toString()); |