jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1654539 - /jmeter/trunk/src/core/org/apache/jmeter/gui/LoggerPanel.java
Date Sat, 24 Jan 2015 15:18:31 GMT
Author: pmouawad
Date: Sat Jan 24 15:18:31 2015
New Revision: 1654539

URL: http://svn.apache.org/r1654539
Log:
Bug 57440 - OutOfMemoryError after introduction of JSyntaxTextArea in LoggerPanel due to disableUndo
not being taken into account
Bugzilla Id: 57440

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/LoggerPanel.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/LoggerPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/LoggerPanel.java?rev=1654539&r1=1654538&r2=1654539&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/LoggerPanel.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/LoggerPanel.java Sat Jan 24 15:18:31 2015
@@ -25,9 +25,6 @@ import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.ScrollPaneConstants;
 import javax.swing.SwingUtilities;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.Document;
-import javax.swing.text.Element;
 
 import org.apache.jmeter.gui.util.JSyntaxTextArea;
 import org.apache.jmeter.gui.util.JTextScrollPane;
@@ -99,20 +96,14 @@ public class LoggerPanel extends JPanel
             @Override
             public void run() {
                 synchronized (textArea) {
-                    Document doc;
-                    try {
-                        doc = textArea.getDocument();
-                        Element root = doc.getDefaultRootElement();
-                        int lineCount = root.getElementCount();
-                        if (lineCount>LOGGER_PANEL_MAX_LINES_COUNT) {
-                            int end = root.getElement(lineCount-LOGGER_PANEL_MAX_LINES_COUNT-1).getEndOffset();
-                            doc.remove(0, end);
-                         }
-                        doc.insertString(doc.getLength(), format.format(logEvent), null);
-                        textArea.setCaretPosition(doc.getLength()-1);
-                    } catch (BadLocationException e) {
-                        // NOOP 
+                    textArea.append(format.format(logEvent));
+                    int currentLength = textArea.getText().length();
+                    // If LOGGER_PANEL_MAX_LENGTH is 0, it means all log events are kept
+                    if(LOGGER_PANEL_MAX_LENGTH != 0 && currentLength> LOGGER_PANEL_MAX_LENGTH)
{
+                        textArea.setText(textArea.getText().substring(Math.max(0, currentLength-LOGGER_PANEL_MAX_LENGTH),

+                                currentLength));
                     }
+                    textArea.setCaretPosition(textArea.getText().length());
                 }
             }
         });



Mime
View raw message