You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/07/16 17:42:16 UTC

(commons-net) branch master updated (82221137 -> a5acdd01)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git


    from 82221137 Javadoc
     new 8f1ef284 Use forEach()
     new a5acdd01 Javadoc

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/commons/net/ProtocolCommandEvent.java |  4 ++--
 .../apache/commons/net/ProtocolCommandSupport.java   | 16 ++++++----------
 .../org/apache/commons/net/io/CopyStreamAdapter.java | 20 ++++++++------------
 3 files changed, 16 insertions(+), 24 deletions(-)


(commons-net) 02/02: Javadoc

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git

commit a5acdd0149e83d5f50e64f07482c1857460665c0
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Wed Jul 16 13:42:10 2025 -0400

    Javadoc
---
 .../org/apache/commons/net/ProtocolCommandSupport.java   | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/apache/commons/net/ProtocolCommandSupport.java b/src/main/java/org/apache/commons/net/ProtocolCommandSupport.java
index 2ef8bab7..0f919902 100644
--- a/src/main/java/org/apache/commons/net/ProtocolCommandSupport.java
+++ b/src/main/java/org/apache/commons/net/ProtocolCommandSupport.java
@@ -31,6 +31,9 @@ import org.apache.commons.net.util.ListenerList;
  */
 public class ProtocolCommandSupport implements Serializable {
 
+    /**
+     * Serialization is unnecessary for this class. Reject attempts to do so until such time as the Serializable attribute can be dropped.
+     */
     private static final long serialVersionUID = -8017692739988399978L;
 
     /**
@@ -63,7 +66,7 @@ public class ProtocolCommandSupport implements Serializable {
     }
 
     /**
-     * Fires a ProtocolCommandEvent signalling the sending of a command to all registered listeners, invoking their
+     * Fires a ProtocolCommandEvent signaling the sending of a command to all registered listeners, invoking their
      * {@link org.apache.commons.net.ProtocolCommandListener#protocolCommandSent protocolCommandSent()} methods.
      *
      * @param command The string representation of the command type sent, not including the arguments (e.g., "STAT" or "GET").
@@ -72,9 +75,7 @@ public class ProtocolCommandSupport implements Serializable {
     public void fireCommandSent(final String command, final String message) {
         if (!listeners.isEmpty()) {
             final ProtocolCommandEvent event = new ProtocolCommandEvent(source, command, message);
-            for (final ProtocolCommandListener listener : listeners) {
-                listener.protocolCommandSent(event);
-            }
+            listeners.forEach(listener -> listener.protocolCommandSent(event));
         }
     }
 
@@ -90,9 +91,7 @@ public class ProtocolCommandSupport implements Serializable {
     public void fireReplyReceived(final int replyCode, final String message) {
         if (!listeners.isEmpty()) {
             final ProtocolCommandEvent event = new ProtocolCommandEvent(source, replyCode, message);
-            for (final ProtocolCommandListener listener : listeners) {
-                listener.protocolReplyReceived(event);
-            }
+            listeners.forEach(listener -> listener.protocolReplyReceived(event));
         }
     }
 
@@ -113,9 +112,6 @@ public class ProtocolCommandSupport implements Serializable {
     private void readObject(final ObjectInputStream ignored) {
         throw new UnsupportedOperationException("Serialization is not supported");
     }
-    /*
-     * Serialization is unnecessary for this class. Reject attempts to do so until such time as the Serializable attribute can be dropped.
-     */
 
     /**
      * Removes a ProtocolCommandListener.


(commons-net) 01/02: Use forEach()

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git

commit 8f1ef2844ae1509bef846509ee18daae8287e3ec
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Wed Jul 16 13:42:05 2025 -0400

    Use forEach()
---
 .../org/apache/commons/net/ProtocolCommandEvent.java |  4 ++--
 .../org/apache/commons/net/io/CopyStreamAdapter.java | 20 ++++++++------------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java b/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
index bbf43b7a..be2f98aa 100644
--- a/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
+++ b/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
@@ -54,7 +54,7 @@ public class ProtocolCommandEvent extends EventObject {
     private final String command;
 
     /**
-     * Creates a ProtocolCommandEvent signalling a reply to a command was received. ProtocolCommandEvents created with this constructor should only be sent
+     * Creates a ProtocolCommandEvent signaling a reply to a command was received. ProtocolCommandEvents created with this constructor should only be sent
      * after a complete command reply has been received from a server.
      *
      * @param source    The source of the event.
@@ -72,7 +72,7 @@ public class ProtocolCommandEvent extends EventObject {
     }
 
     /**
-     * Creates a ProtocolCommandEvent signalling a command was sent to the server. ProtocolCommandEvents created with this constructor should only be sent after
+     * Creates a ProtocolCommandEvent signaling a command was sent to the server. ProtocolCommandEvents created with this constructor should only be sent after
      * a command has been sent, but before the reply has been received.
      *
      * @param source  The source of the event.
diff --git a/src/main/java/org/apache/commons/net/io/CopyStreamAdapter.java b/src/main/java/org/apache/commons/net/io/CopyStreamAdapter.java
index 82863008..382c0d21 100644
--- a/src/main/java/org/apache/commons/net/io/CopyStreamAdapter.java
+++ b/src/main/java/org/apache/commons/net/io/CopyStreamAdapter.java
@@ -32,23 +32,23 @@ import org.apache.commons.net.util.ListenerList;
  */
 public class CopyStreamAdapter implements CopyStreamListener {
 
-    private final ListenerList<CopyStreamListener> internalListeners;
+    private final ListenerList<CopyStreamListener> listeners;
 
     /**
      * Creates a new copyStreamAdapter.
      */
     public CopyStreamAdapter() {
-        internalListeners = new ListenerList<>();
+        listeners = new ListenerList<>();
     }
 
     /**
-     * Registers a CopyStreamListener to receive CopyStreamEvents. Although this method is not declared to be synchronized, it is implemented in a thread safe
+     * Adds a CopyStreamListener to receive CopyStreamEvents. Although this method is not declared to be synchronized, it is implemented in a thread safe
      * manner.
      *
      * @param listener The CopyStreamlistener to register.
      */
     public void addCopyStreamListener(final CopyStreamListener listener) {
-        internalListeners.addListener(listener);
+        listeners.addListener(listener);
     }
 
     /**
@@ -60,9 +60,7 @@ public class CopyStreamAdapter implements CopyStreamListener {
      */
     @Override
     public void bytesTransferred(final CopyStreamEvent event) {
-        for (final CopyStreamListener listener : internalListeners) {
-            listener.bytesTransferred(event);
-        }
+        listeners.forEach(listener -> listener.bytesTransferred(event));
     }
 
     /**
@@ -77,17 +75,15 @@ public class CopyStreamAdapter implements CopyStreamListener {
      */
     @Override
     public void bytesTransferred(final long totalBytesTransferred, final int bytesTransferred, final long streamSize) {
-        for (final CopyStreamListener listener : internalListeners) {
-            listener.bytesTransferred(totalBytesTransferred, bytesTransferred, streamSize);
-        }
+        listeners.forEach(listener -> listener.bytesTransferred(totalBytesTransferred, bytesTransferred, streamSize));
     }
 
     /**
-     * Unregisters a CopyStreamListener. Although this method is not synchronized, it is implemented in a thread safe manner.
+     * Removes a CopyStreamListener. Although this method is not synchronized, it is implemented in a thread safe manner.
      *
      * @param listener The CopyStreamlistener to unregister.
      */
     public void removeCopyStreamListener(final CopyStreamListener listener) {
-        internalListeners.removeListener(listener);
+        listeners.removeListener(listener);
     }
 }