[hg] main-silver: #83762: Throwable.printStackTrace() replaced b...

  • From:
  • To: , , ,
  • Subject: [hg] main-silver: #83762: Throwable.printStackTrace() replaced b...
  • Date: Thu, 17 Jan 2013 11:59:07 -0800

changeset 44c85914671d in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/44c85914671d
description:
        #83762: Throwable.printStackTrace() replaced by ErrorManager.notify()

diffstat:

 ant.debugger/src/org/netbeans/modules/ant/debugger/DebuggerAntLogger.java    
                            |  17 +-
 ant.debugger/src/org/netbeans/modules/ant/debugger/IOManager.java            
                            |   3 +-
 ant.debugger/src/org/netbeans/modules/ant/debugger/Utils.java                
                            |  83 +++++++--
 ant.debugger/test/unit/src/org/netbeans/modules/ant/debugger/StepTest.java   
                            |   6 +-
 api.debugger/src/org/netbeans/api/debugger/Lookup.java                       
                            |   2 +-
 
debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/BreakpointAnnotationProvider.java
 |   8 +-
 
debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ToolTipAnnotation.java
            |   3 +-
 debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/IOManager.java    
                            |   3 +-
 
debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesNodeModel.java
                |   3 +-
 
debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesTableModel.java
               |   4 +-
 
debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteFXScreenshot.java
               |   1 -
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/JPDADebuggerActionProvider.java
             |   2 -
 spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerModule.java     
                            |   3 +-
 
web.debug/src/org/netbeans/modules/web/debug/variablesfilterring/JSPVariablesNodeModelFilter.java
        |   3 +-
 14 files changed, 92 insertions(+), 49 deletions(-)

diffs (443 lines):

diff --git 
a/ant.debugger/src/org/netbeans/modules/ant/debugger/DebuggerAntLogger.java 
b/ant.debugger/src/org/netbeans/modules/ant/debugger/DebuggerAntLogger.java
--- 
a/ant.debugger/src/org/netbeans/modules/ant/debugger/DebuggerAntLogger.java
+++ 
b/ant.debugger/src/org/netbeans/modules/ant/debugger/DebuggerAntLogger.java
@@ -52,6 +52,8 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import org.apache.tools.ant.module.api.AntProjectCookie;
 import org.apache.tools.ant.module.spi.AntLogger;
 import org.apache.tools.ant.module.spi.AntSession;
@@ -338,20 +340,21 @@
         }
         
         // start debugging othervise
+        FileObject fo = FileUtil.toFileObject (s.getOriginatingScript ());
+        DataObject dob;
         try {
-            FileObject fo = FileUtil.toFileObject (s.getOriginatingScript 
());
-            DataObject dob = DataObject.find (fo);
+            dob = DataObject.find (fo);
+        } catch (DataObjectNotFoundException ex) {
+            
Logger.getLogger(DebuggerAntLogger.class.getName()).log(Level.CONFIG, "No 
DataObject from "+fo, ex);
+            return null;
+        }
             AntProjectCookie antCookie = 
dob.getLookup().lookup(AntProjectCookie.class);
             if (antCookie == null)
-                throw new NullPointerException ();
+            throw new NullPointerException ("No AntProjectCookie provided by 
"+dob);
             d = startDebugging (antCookie, antEvent, execTask);
             runningDebuggers.put (s, d);
             runningDebuggers2.put (d, s);
             return d;
-        } catch (DataObjectNotFoundException ex) {
-            ex.printStackTrace ();
-            return null;
-        }
     }
 
     private static AntDebugger startDebugging (
diff --git 
a/ant.debugger/src/org/netbeans/modules/ant/debugger/IOManager.java 
b/ant.debugger/src/org/netbeans/modules/ant/debugger/IOManager.java
--- a/ant.debugger/src/org/netbeans/modules/ant/debugger/IOManager.java
+++ b/ant.debugger/src/org/netbeans/modules/ant/debugger/IOManager.java
@@ -49,6 +49,7 @@
 import java.util.LinkedList;
 import javax.swing.SwingUtilities;
 import org.openide.awt.StatusDisplayer;
+import org.openide.util.Exceptions;
 import org.openide.util.RequestProcessor;
 import org.openide.windows.IOProvider;
 import org.openide.windows.InputOutput;
@@ -119,7 +120,7 @@
                                     debuggerOut.close ();
                                 StatusDisplayer.getDefault ().setStatusText 
(t.text);
                             } catch (IOException ex) {
-                                ex.printStackTrace ();
+                                Exceptions.printStackTrace(ex);
                             }
                         }
                     }
diff --git a/ant.debugger/src/org/netbeans/modules/ant/debugger/Utils.java 
b/ant.debugger/src/org/netbeans/modules/ant/debugger/Utils.java
--- a/ant.debugger/src/org/netbeans/modules/ant/debugger/Utils.java
+++ b/ant.debugger/src/org/netbeans/modules/ant/debugger/Utils.java
@@ -51,12 +51,15 @@
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import javax.swing.JEditorPane;
 import javax.swing.SwingUtilities;
 import javax.swing.text.BadLocationException;
 import javax.swing.text.DefaultEditorKit;
 import javax.swing.text.EditorKit;
 import javax.swing.text.StyledDocument;
+import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 import org.apache.tools.ant.module.api.support.TargetLister;
@@ -91,6 +94,8 @@
  */
 public class Utils {
             
+    private static final Logger logger = 
Logger.getLogger(Utils.class.getName());
+    
     private static Object currentLine;
     
     static synchronized void markCurrent (final Object line) {
@@ -201,20 +206,34 @@
         FileObject fileObject = FileUtil.toFileObject (file);
         EditorCookie editor;
         LineCookie lineCookie;
+        DataObject d;
         try {
-            DataObject d = DataObject.find (fileObject);
+            d = DataObject.find (fileObject);
+        } catch (DataObjectNotFoundException donfex) {
+            logger.log(Level.CONFIG, "No DataObject for "+fileObject, 
donfex);
+            return null;
+        }
             editor = d.getLookup().lookup (EditorCookie.class);
             lineCookie = d.getLookup().lookup (LineCookie.class);
             assert editor != null;
             assert lineCookie != null;
         
+        InputSource in = null;
+        try {
             StyledDocument doc = editor.openDocument ();
-            InputSource in = createInputSource 
-                (fileObject, editor, doc);
-            if (in == null) return null;
+            in = createInputSource (fileObject, editor, doc);
+        } catch (IOException ioex) {
+            logger.log(Level.CONFIG, "A problem while opening "+fileObject, 
ioex);
+        } catch (BadLocationException blex) {
+            logger.log(Level.CONFIG, "A problem while opening "+fileObject, 
blex);
+        }
+        if (in == null) {
+            return null;
+        }
+        final int[] line = new int [4];
             SAXParserFactory factory = SAXParserFactory.newInstance ();
+        try {
             SAXParser parser = factory.newSAXParser ();
-            final int[] line = new int [4];
             class Handler extends DefaultHandler {
                 private Locator locator;
                 @Override
@@ -253,6 +272,16 @@
                 }
             }
             parser.parse (in, new Handler ());
+        } catch (IOException ioex) {
+            logger.log(Level.CONFIG, "A problem while reading "+fileObject, 
ioex);
+            return null;
+        } catch (ParserConfigurationException pcex) {
+            logger.log(Level.CONFIG, "A problem while parsing "+fileObject, 
pcex);
+            return null;
+        } catch (SAXException saxex) {
+            logger.log(Level.CONFIG, "A problem while parsing "+fileObject, 
saxex);
+            return null;
+        }
             if (line [0] == 0) return null;
             Annotatable[] annotatables = new Annotatable [
                 line [2] - line [0] + 1
@@ -263,10 +292,6 @@
                 annotatables [i++] = l;
             }
             return annotatables;
-        } catch (Exception e) {
-            e.printStackTrace ();
-        }
-        return null;
     }
     
     static Object getLine (
@@ -277,23 +302,33 @@
         assert fileObject != null : "No build script for " + target.getName 
();
         EditorCookie editor;
         LineCookie lineCookie;
+        DataObject d;
         try {
-            DataObject d = DataObject.find (fileObject);
+            d = DataObject.find (fileObject);
+        } catch (DataObjectNotFoundException donfex) {
+            logger.log(Level.CONFIG, "No DataObject for "+fileObject, 
donfex);
+            return null;
+        }
             editor = d.getLookup().lookup (EditorCookie.class);
             lineCookie = d.getLookup().lookup (LineCookie.class);
             assert editor != null;
             assert lineCookie != null;
-        } catch (DataObjectNotFoundException e) {
-            throw new AssertionError (e);
-        }
+        InputSource in = null;
         try {
             StyledDocument doc = editor.openDocument ();
-            InputSource in = createInputSource 
-                (fileObject, editor, doc);
-            if (in == null) return null;
+            in = createInputSource (fileObject, editor, doc);
+        } catch (IOException ioex) {
+            logger.log(Level.CONFIG, "A problem while opening "+fileObject, 
ioex);
+        } catch (BadLocationException blex) {
+            logger.log(Level.CONFIG, "A problem while opening "+fileObject, 
blex);
+        }
+        if (in == null) {
+            return null;
+        }
+        final int[] line = new int [4];
             SAXParserFactory factory = SAXParserFactory.newInstance ();
+        try {
             SAXParser parser = factory.newSAXParser ();
-            final int[] line = new int [4];
             class Handler extends DefaultHandler {
                 private Locator locator;
                 @Override
@@ -332,6 +367,16 @@
                 }
             }
             parser.parse (in, new Handler ());
+        } catch (IOException ioex) {
+            logger.log(Level.CONFIG, "A problem while reading "+fileObject, 
ioex);
+            return null;
+        } catch (ParserConfigurationException pcex) {
+            logger.log(Level.CONFIG, "A problem while parsing "+fileObject, 
pcex);
+            return null;
+        } catch (SAXException saxex) {
+            logger.log(Level.CONFIG, "A problem while parsing "+fileObject, 
saxex);
+            return null;
+        }
             if (line [0] == 0) return null;
             
             int ln = line [0] - 1;
@@ -352,10 +397,6 @@
                     annotatables.add (l);
                 }
             return annotatables.toArray (new Annotatable [annotatables.size 
()]);
-        } catch (Exception e) {
-            e.printStackTrace ();
-        }
-        return null;
     }
     
     private static int findIndexOf(String text, String target) {
diff --git 
a/ant.debugger/test/unit/src/org/netbeans/modules/ant/debugger/StepTest.java 
b/ant.debugger/test/unit/src/org/netbeans/modules/ant/debugger/StepTest.java
--- 
a/ant.debugger/test/unit/src/org/netbeans/modules/ant/debugger/StepTest.java
+++ 
b/ant.debugger/test/unit/src/org/netbeans/modules/ant/debugger/StepTest.java
@@ -86,8 +86,7 @@
     }
     
     public static final class Lkp extends ProxyLookup {
-        public Lkp() {
-            try {
+        public Lkp() throws InstantiationException, IllegalAccessException, 
ClassNotFoundException {
                 setLookups(new Lookup[] {
                     Lookups.fixed(new Object[] {
                         new IFL(),
@@ -95,9 +94,6 @@
                         new DebuggerAntLogger ()
                     }),
                 });
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
         }
     }
 
diff --git a/api.debugger/src/org/netbeans/api/debugger/Lookup.java 
b/api.debugger/src/org/netbeans/api/debugger/Lookup.java
--- a/api.debugger/src/org/netbeans/api/debugger/Lookup.java
+++ b/api.debugger/src/org/netbeans/api/debugger/Lookup.java
@@ -504,7 +504,7 @@
                 }
                 return l; 
             } catch (IOException e) {
-                e.printStackTrace ();
+                Exceptions.printStackTrace(e);
             }
             throw new InternalError ("Can not read from Meta-inf!");
         }
diff --git 
a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/BreakpointAnnotationProvider.java
 
b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/BreakpointAnnotationProvider.java
--- 
a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/BreakpointAnnotationProvider.java
+++ 
b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/BreakpointAnnotationProvider.java
@@ -56,6 +56,8 @@
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.netbeans.api.debugger.Breakpoint;
 import org.netbeans.api.debugger.Breakpoint.VALIDITY;
@@ -297,13 +299,11 @@
         if (b instanceof LineBreakpoint) {
             LineBreakpoint lb = (LineBreakpoint) b;
             try {
-                if (fo.getURL().equals(new URL(lb.getURL()))) {
+                if (fo.toURL().equals(new URL(lb.getURL()))) {
                     return new int[] { lb.getLineNumber() };
                 }
             } catch (MalformedURLException ex) {
                 Exceptions.printStackTrace(ex);
-            } catch (FileStateInvalidException ex) {
-                Exceptions.printStackTrace(ex);
             }
             return null;
         } else if (b instanceof FieldBreakpoint) {
@@ -471,7 +471,7 @@
         try {
             dataObject = DataObject.find(fo);
         } catch (DataObjectNotFoundException donfex) {
-            donfex.printStackTrace();
+            
Logger.getLogger(BreakpointAnnotationProvider.class.getName()).log(Level.INFO,
 "No DO for "+fo, donfex);
             return ;
         }
         LineCookie lc = dataObject.getCookie(LineCookie.class);
diff --git 
a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ToolTipAnnotation.java
 
b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ToolTipAnnotation.java
--- 
a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ToolTipAnnotation.java
+++ 
b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ToolTipAnnotation.java
@@ -104,6 +104,7 @@
 import org.netbeans.spi.debugger.jpda.EditorContext.Operation;
 
 import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
+import org.openide.util.Exceptions;
 
 
 public class ToolTipAnnotation extends Annotation implements Runnable {
@@ -225,7 +226,7 @@
                         toStringMethod.setAccessible(true);
                         toString = (String) toStringMethod.invoke(v, 
TO_STRING_LENGTH_LIMIT);
                     } catch (Exception ex) {
-                        ex.printStackTrace();
+                        Exceptions.printStackTrace(ex);
                     }
                     if (toString == null) {
                         toString = ((ObjectVariable) v).getToStringValue();
diff --git 
a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/IOManager.java 
b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/IOManager.java
--- 
a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/IOManager.java
+++ 
b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/IOManager.java
@@ -52,6 +52,7 @@
 import org.netbeans.api.debugger.Properties;
 import org.netbeans.api.debugger.jpda.JPDADebugger;
 import org.openide.awt.StatusDisplayer;
+import org.openide.util.Exceptions;
 import org.openide.util.RequestProcessor;
 import org.openide.windows.IOProvider;
 import org.openide.windows.InputOutput;
@@ -192,7 +193,7 @@
                                // if ((t.where & STATUS_OUT) != 0)
                                     StatusDisplayer.getDefault 
().setStatusText (t.text);
                             } catch (IOException ex) {
-                                ex.printStackTrace ();
+                                Exceptions.printStackTrace(ex);
                             }
                             if (closed) {
                                 debuggerOut.close ();
diff --git 
a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesNodeModel.java
 
b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesNodeModel.java
--- 
a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesNodeModel.java
+++ 
b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesNodeModel.java
@@ -73,6 +73,7 @@
 import org.netbeans.spi.viewmodel.TreeModel;
 import org.netbeans.spi.viewmodel.ModelListener;
 import org.netbeans.spi.viewmodel.UnknownTypeException;
+import org.openide.util.Exceptions;
 import org.openide.util.NbBundle;
 import org.openide.util.RequestProcessor;
 import org.openide.util.datatransfer.PasteType;
@@ -340,7 +341,7 @@
             toStringMethod.setAccessible(true);
             toString = (String) toStringMethod.invoke(v, 
TO_STRING_LENGTH_LIMIT);
         } catch (Exception ex) {
-            ex.printStackTrace();
+            Exceptions.printStackTrace(ex);
         }
         if (toString == null) {
             toString = v.getToStringValue();
diff --git 
a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesTableModel.java
 
b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesTableModel.java
--- 
a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesTableModel.java
+++ 
b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesTableModel.java
@@ -71,6 +71,7 @@
 import org.netbeans.spi.viewmodel.UnknownTypeException;
 import org.openide.DialogDisplayer;
 import org.openide.NotifyDescriptor;
+import org.openide.util.Exceptions;
 import org.openide.util.NbBundle;
 import org.openide.util.NbPreferences;
 
@@ -205,8 +206,7 @@
                             getEvaluatedWatchMethod.setAccessible(true);
                             row = (JPDAWatch) 
getEvaluatedWatchMethod.invoke(row);
                         } catch (Exception ex) {
-                            // Log it only
-                            ex.printStackTrace();
+                            Exceptions.printStackTrace(ex);
                         }
                     }
                     if (row instanceof ObjectVariable) {
diff --git 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteFXScreenshot.java
 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteFXScreenshot.java
--- 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteFXScreenshot.java
+++ 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteFXScreenshot.java
@@ -318,7 +318,6 @@
         } catch (InvocationException e) {
             throw new RetrievalException(e.getMessage(), e);
         } catch (ClassNotPreparedException e) {
-            e.printStackTrace();
             throw new RetrievalException(e.getMessage(), e);
         }
     }
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/JPDADebuggerActionProvider.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/JPDADebuggerActionProvider.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/JPDADebuggerActionProvider.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/JPDADebuggerActionProvider.java
@@ -144,9 +144,7 @@
         } catch (VMDisconnectedExceptionWrapper e) {
         } catch (InternalExceptionWrapper e) {
         } catch (IllegalThreadStateException e) {
-            e.printStackTrace();
         } catch (InvalidRequestStateException e) {
-            e.printStackTrace();
         }
     }
     
diff --git 
a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerModule.java 
b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerModule.java
--- a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerModule.java
+++ b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/DebuggerModule.java
@@ -47,6 +47,7 @@
 import java.lang.reflect.Method;
 import org.openide.LifecycleManager;
 import org.openide.modules.ModuleInstall;
+import org.openide.util.Exceptions;
 import org.openide.windows.WindowManager;
 import org.openide.windows.WindowSystemEvent;
 import org.openide.windows.WindowSystemListener;
@@ -85,7 +86,7 @@
             Method isExitingMethod = lcm.getClass().getMethod("isExiting");
             return (Boolean) isExitingMethod.invoke(lcm);
         } catch (Exception ex) {
-            ex.printStackTrace();
+            Exceptions.printStackTrace(ex);
             return false;
         }
     }
diff --git 
a/web.debug/src/org/netbeans/modules/web/debug/variablesfilterring/JSPVariablesNodeModelFilter.java
 
b/web.debug/src/org/netbeans/modules/web/debug/variablesfilterring/JSPVariablesNodeModelFilter.java
--- 
a/web.debug/src/org/netbeans/modules/web/debug/variablesfilterring/JSPVariablesNodeModelFilter.java
+++ 
b/web.debug/src/org/netbeans/modules/web/debug/variablesfilterring/JSPVariablesNodeModelFilter.java
@@ -64,6 +64,7 @@
 import org.netbeans.spi.viewmodel.ModelListener;
 import org.netbeans.spi.viewmodel.NodeModel;
 import org.netbeans.spi.viewmodel.UnknownTypeException;
+import org.openide.util.Exceptions;
 import org.openide.util.NbBundle;
 import org.openide.util.RequestProcessor;
 import org.openide.util.datatransfer.PasteType;
@@ -228,7 +229,7 @@
             toStringMethod.setAccessible(true);
             toString = (String) toStringMethod.invoke(v, 
TO_STRING_LENGTH_LIMIT);
         } catch (Exception ex) {
-            ex.printStackTrace();
+            Exceptions.printStackTrace(ex);
         }
         if (toString == null) {
             toString = v.getToStringValue();

[hg] main-silver: #83762: Throwable.printStackTrace() replaced b...

mentlicher 01/17/2013

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close