logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r564474 - /logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java
Date Fri, 10 Aug 2007 05:55:50 GMT
Author: sdeboy
Date: Thu Aug  9 22:55:50 2007
New Revision: 564474

URL: http://svn.apache.org/viewvc?view=rev&rev=564474
Log:
Prevent numberformatexceptions when entering a non-number value in goto-line dialog

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java?view=diff&rev=564474&r1=564473&r2=564474
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java Thu Aug  9 22:55:50
2007
@@ -27,8 +27,6 @@
 import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.awt.event.ContainerEvent;
-import java.awt.event.ContainerListener;
 import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseAdapter;
@@ -121,7 +119,6 @@
 import org.apache.log4j.spi.LoggerRepositoryEx;
 import org.apache.log4j.spi.LoggingEvent;
 import org.apache.log4j.spi.RepositorySelector;
-import org.apache.log4j.xml.DOMConfigurator;
 import org.apache.log4j.xml.XMLDecoder;
 
 
@@ -724,12 +721,16 @@
       new AbstractAction() {
         public void actionPerformed(ActionEvent e) {
           String inputLine = JOptionPane.showInputDialog(LogUI.this, "Enter the line number
to go:", "Goto Line", -1);
-          int lineNumber = Integer.parseInt(inputLine);
-          List eventList = getCurrentLogPanel().getFilteredEvents();
-
-          if (lineNumber > 0 && lineNumber <= eventList.size()) {
-              getCurrentLogPanel().setSelectedEvent(lineNumber);
-          } else {
+          try {
+        	  int lineNumber = Integer.parseInt(inputLine);
+              List eventList = getCurrentLogPanel().getFilteredEvents();
+
+              if (lineNumber > 0 && lineNumber <= eventList.size()) {
+                  getCurrentLogPanel().setSelectedEvent(lineNumber);
+              } else {
+                  JOptionPane.showMessageDialog(LogUI.this, "You have entered an invalid
line number", "Error", 0);
+              }
+          } catch (NumberFormatException nfe) {
               JOptionPane.showMessageDialog(LogUI.this, "You have entered an invalid line
number", "Error", 0);
           }
         }



Mime
View raw message