jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Schumacher <felix.schumac...@internetallee.de>
Subject Re: svn commit: r1781805 - /jmeter/trunk/src/core/org/apache/jmeter/gui/logging/GuiLogEventBus.java
Date Sun, 05 Feb 2017 21:00:48 GMT


Am 5. Februar 2017 21:56:14 MEZ schrieb pmouawad@apache.org:
>Author: pmouawad
>Date: Sun Feb  5 20:56:14 2017
>New Revision: 1781805
>
>URL: http://svn.apache.org/viewvc?rev=1781805&view=rev
>Log:
>Take into account Felix comment
>
>Modified:
>jmeter/trunk/src/core/org/apache/jmeter/gui/logging/GuiLogEventBus.java
>
>Modified:
>jmeter/trunk/src/core/org/apache/jmeter/gui/logging/GuiLogEventBus.java
>URL:
>http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/logging/GuiLogEventBus.java?rev=1781805&r1=1781804&r2=1781805&view=diff
>==============================================================================
>---
>jmeter/trunk/src/core/org/apache/jmeter/gui/logging/GuiLogEventBus.java
>(original)
>+++
>jmeter/trunk/src/core/org/apache/jmeter/gui/logging/GuiLogEventBus.java
>Sun Feb  5 20:56:14 2017
>@@ -17,9 +17,8 @@
>  */
> package org.apache.jmeter.gui.logging;
> 
>-import java.util.Arrays;
>-import java.util.LinkedHashSet;
>-import java.util.Set;
>+import java.util.ArrayList;
>+import java.util.List;
> 
> /**
>  * GUI Log Event Bus.
>@@ -30,7 +29,7 @@ public class GuiLogEventBus {
>     /**
>      * Registered GUI log event listeners array.
>      */
>-    private GuiLogEventListener [] listeners;
>+    private List<GuiLogEventListener> listeners = new ArrayList<>();

A set would probably have fine it, too.

But thanks for taking care of this.

Felix

> 
>     /**
>      * Default constructor.
>@@ -44,14 +43,7 @@ public class GuiLogEventBus {
>* @param listener a GUI log event listener ({@link
>GuiLogEventListener})
>      */
>     public void registerEventListener(GuiLogEventListener listener) {
>-        if (listeners == null) {
>-            listeners = new GuiLogEventListener[] { listener };
>-        } else {
>-            Set<GuiLogEventListener> set = new
>LinkedHashSet<>(Arrays.asList(listeners));
>-            set.add(listener);
>-            GuiLogEventListener [] arr = new
>GuiLogEventListener[set.size()];
>-            listeners = set.toArray(arr);
>-        }
>+        listeners.add(listener);
>     }
> 
>     /**
>@@ -59,12 +51,7 @@ public class GuiLogEventBus {
>* @param listener a GUI log event listener ({@link
>GuiLogEventListener})
>      */
>    public void unregisterEventListener(GuiLogEventListener listener) {
>-        if (listeners != null) {
>-            Set<GuiLogEventListener> set = new
>LinkedHashSet<>(Arrays.asList(listeners));
>-            set.remove(listener);
>-            GuiLogEventListener [] arr = new
>GuiLogEventListener[set.size()];
>-            listeners = set.toArray(arr);
>-        }
>+        listeners.remove(listener);
>     }
> 
>     /**
>@@ -72,10 +59,8 @@ public class GuiLogEventBus {
>      * @param logEvent log event object
>      */
>     public void postEvent(LogEventObject logEventObject) {
>-        if (listeners != null) {
>-            for (GuiLogEventListener listener : listeners) {
>-                listener.processLogEvent(logEventObject);
>-            }
>+        for (GuiLogEventListener listener : listeners) {
>+            listener.processLogEvent(logEventObject);
>         }
>     }
> }

Mime
View raw message