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/17 11:57:04 UTC
(commons-net) branch master updated (d794583e -> c94cda6e)
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 d794583e Javadoc
new 37bef9d1 Extract constants
new 73695ae7 Collapse else if
new 62224d93 Camel case instance variable
new a7579156 Convert to upper case instead of cases-insensitive comparison x3
new 124cf3b2 Better instance variable name
new 526dce58 Extract constants
new 05d58f35 Fail-fast in org.apache.commons.net.PrintCommandListener.PrintCommandListener(PrintWriter, boolean, char, boolean) if PrintWriter is null
new a2c748f1 Avoid NullPointerException in org.apache.commons.net.PrintCommandListener.org.apache.commons.net.PrintCommandListener.protocolCommandSent(ProtocolCommandEvent)
new c94cda6e Merge branch 'master' of https://github.com/apache/commons-net.git
The 9 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:
src/changes/changes.xml | 3 ++
.../apache/commons/net/PrintCommandListener.java | 63 +++++++++++++---------
2 files changed, 41 insertions(+), 25 deletions(-)
(commons-net) 07/09: Fail-fast in org.apache.commons.net.PrintCommandListener.PrintCommandListener(PrintWriter, boolean, char, boolean) if PrintWriter is null
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 05d58f3588cb47972d7b0588e7d6af8a4c1c5473
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Thu Jul 17 07:49:28 2025 -0400
Fail-fast in
org.apache.commons.net.PrintCommandListener.PrintCommandListener(PrintWriter,
boolean, char, boolean) if PrintWriter is null
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/commons/net/PrintCommandListener.java | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 363b3116..cad58902 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -93,6 +93,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate org.apache.commons.net.util.Charsets.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Performance: NTFTPEntryParser.parseFTPEntry(String) doesn't need to parse timestamps if there is no name.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Improve error handling in org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createFileEntryParser(String, FTPClientConfig).</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Fail-fast in org.apache.commons.net.PrintCommandListener.PrintCommandListener(PrintWriter, boolean, char, boolean) if the PrintWriter is null.</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.net.nntp.Article#getChild().</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.net.nntp.Article#getNext().</action>
diff --git a/src/main/java/org/apache/commons/net/PrintCommandListener.java b/src/main/java/org/apache/commons/net/PrintCommandListener.java
index 5ad6df25..318bc21e 100644
--- a/src/main/java/org/apache/commons/net/PrintCommandListener.java
+++ b/src/main/java/org/apache/commons/net/PrintCommandListener.java
@@ -128,14 +128,14 @@ public class PrintCommandListener implements ProtocolCommandListener {
/**
* Constructs an instance which optionally suppresses login command text and indicates where the EOL starts with the specified character.
*
- * @param writer where to write the commands and responses
+ * @param writer where to write the commands and responses, not null.
* @param suppressLogin if {@code true}, only print command name for login
* @param eolMarker if non-zero, add a marker just before the EOL.
* @param showDirection if {@code true}, add {@code ">} " or {@code "< "} as appropriate to the output
* @since 3.0
*/
public PrintCommandListener(final PrintWriter writer, final boolean suppressLogin, final char eolMarker, final boolean showDirection) {
- this.writer = writer;
+ this.writer = Objects.requireNonNull(writer, "writer");
this.noLogin = suppressLogin;
this.eolMarker = eolMarker;
this.showDirection = showDirection;
(commons-net) 05/09: Better instance variable name
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 124cf3b2ddfbe4e02a01010ce23d0cef75ae15c2
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Thu Jul 17 07:42:41 2025 -0400
Better instance variable name
---
src/main/java/org/apache/commons/net/PrintCommandListener.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/commons/net/PrintCommandListener.java b/src/main/java/org/apache/commons/net/PrintCommandListener.java
index f21109e6..220e76b8 100644
--- a/src/main/java/org/apache/commons/net/PrintCommandListener.java
+++ b/src/main/java/org/apache/commons/net/PrintCommandListener.java
@@ -39,7 +39,7 @@ public class PrintCommandListener implements ProtocolCommandListener {
private final PrintWriter writer;
private final boolean noLogin;
private final char eolMarker;
- private final boolean directionMarker;
+ private final boolean showDirection;
/**
* Constructs an instance which prints everything using the default Charset.
@@ -136,7 +136,7 @@ public class PrintCommandListener implements ProtocolCommandListener {
this.writer = writer;
this.noLogin = suppressLogin;
this.eolMarker = eolMarker;
- this.directionMarker = showDirection;
+ this.showDirection = showDirection;
}
private String getPrintableString(final String msg) {
@@ -156,7 +156,7 @@ public class PrintCommandListener implements ProtocolCommandListener {
@Override
public void protocolCommandSent(final ProtocolCommandEvent event) {
- if (directionMarker) {
+ if (showDirection) {
writer.print("> ");
}
if (noLogin) {
@@ -180,7 +180,7 @@ public class PrintCommandListener implements ProtocolCommandListener {
@Override
public void protocolReplyReceived(final ProtocolCommandEvent event) {
- if (directionMarker) {
+ if (showDirection) {
writer.print("< ");
}
final String message = event.getMessage();
(commons-net) 02/09: Collapse else if
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 73695ae79436d5abae18a5f5969cf4a9f0501bde
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Thu Jul 17 07:38:15 2025 -0400
Collapse else if
---
.../java/org/apache/commons/net/PrintCommandListener.java | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/apache/commons/net/PrintCommandListener.java b/src/main/java/org/apache/commons/net/PrintCommandListener.java
index b878b67a..925e8887 100644
--- a/src/main/java/org/apache/commons/net/PrintCommandListener.java
+++ b/src/main/java/org/apache/commons/net/PrintCommandListener.java
@@ -162,15 +162,13 @@ public class PrintCommandListener implements ProtocolCommandListener {
if (CMD_PASS.equalsIgnoreCase(cmd) || CMD_USER.equalsIgnoreCase(cmd)) {
writer.print(cmd);
writer.println(HIDDEN_MARKER); // Don't bother with EOL marker for this!
+ } else if (CMD_LOGIN.equalsIgnoreCase(cmd)) { // IMAP
+ String msg = event.getMessage();
+ msg = msg.substring(0, msg.indexOf(CMD_LOGIN) + CMD_LOGIN.length());
+ writer.print(msg);
+ writer.println(HIDDEN_MARKER); // Don't bother with EOL marker for this!
} else {
- if (CMD_LOGIN.equalsIgnoreCase(cmd)) { // IMAP
- String msg = event.getMessage();
- msg = msg.substring(0, msg.indexOf(CMD_LOGIN) + CMD_LOGIN.length());
- writer.print(msg);
- writer.println(HIDDEN_MARKER); // Don't bother with EOL marker for this!
- } else {
- writer.print(getPrintableString(event.getMessage()));
- }
+ writer.print(getPrintableString(event.getMessage()));
}
} else {
writer.print(getPrintableString(event.getMessage()));
(commons-net) 08/09: Avoid NullPointerException in org.apache.commons.net.PrintCommandListener.org.apache.commons.net.PrintCommandListener.protocolCommandSent(ProtocolCommandEvent)
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 a2c748f1210ec9f9f7f7abb6482837c12cfaa1cb
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Thu Jul 17 07:55:07 2025 -0400
Avoid NullPointerException in
org.apache.commons.net.PrintCommandListener.org.apache.commons.net.PrintCommandListener.protocolCommandSent(ProtocolCommandEvent)
Avoid NullPointerException in
org.apache.commons.net.PrintCommandListener.org.apache.commons.net.PrintCommandListener.protocolReplyReceived(ProtocolCommandEvent)
---
src/changes/changes.xml | 2 ++
.../org/apache/commons/net/PrintCommandListener.java | 18 +++++++++++++-----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index cad58902..5a89871a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -94,6 +94,8 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary Gregory">Performance: NTFTPEntryParser.parseFTPEntry(String) doesn't need to parse timestamps if there is no name.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Improve error handling in org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createFileEntryParser(String, FTPClientConfig).</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Fail-fast in org.apache.commons.net.PrintCommandListener.PrintCommandListener(PrintWriter, boolean, char, boolean) if the PrintWriter is null.</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException in org.apache.commons.net.PrintCommandListener.org.apache.commons.net.PrintCommandListener.protocolCommandSent(ProtocolCommandEvent).</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Avoid NullPointerException in org.apache.commons.net.PrintCommandListener.org.apache.commons.net.PrintCommandListener.protocolReplyReceived(ProtocolCommandEvent).</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.net.nntp.Article#getChild().</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add org.apache.commons.net.nntp.Article#getNext().</action>
diff --git a/src/main/java/org/apache/commons/net/PrintCommandListener.java b/src/main/java/org/apache/commons/net/PrintCommandListener.java
index 318bc21e..423ea605 100644
--- a/src/main/java/org/apache/commons/net/PrintCommandListener.java
+++ b/src/main/java/org/apache/commons/net/PrintCommandListener.java
@@ -141,6 +141,14 @@ public class PrintCommandListener implements ProtocolCommandListener {
this.showDirection = showDirection;
}
+ private String getCommand(final ProtocolCommandEvent event) {
+ return Objects.toString(event.getCommand()).toUpperCase(Locale.ROOT);
+ }
+
+ private String getMessage(final ProtocolCommandEvent event) {
+ return Objects.toString(event.getMessage());
+ }
+
private String getPrintableString(final String msg) {
if (eolMarker == 0) {
return msg;
@@ -162,20 +170,20 @@ public class PrintCommandListener implements ProtocolCommandListener {
writer.print(DIRECTION_MARKER_SEND);
}
if (noLogin) {
- final String cmd = Objects.toString(event.getCommand()).toUpperCase(Locale.ROOT);
+ final String cmd = getCommand(event);
if (CMD_PASS.equals(cmd) || CMD_USER.equals(cmd)) {
writer.print(cmd);
writer.println(HIDDEN_MARKER); // Don't bother with EOL marker for this!
} else if (CMD_LOGIN.equals(cmd)) { // IMAP
- String msg = event.getMessage();
+ String msg = getMessage(event);
msg = msg.substring(0, msg.indexOf(CMD_LOGIN) + CMD_LOGIN.length());
writer.print(msg);
writer.println(HIDDEN_MARKER); // Don't bother with EOL marker for this!
} else {
- writer.print(getPrintableString(event.getMessage()));
+ writer.print(getPrintableString(getMessage(event)));
}
} else {
- writer.print(getPrintableString(event.getMessage()));
+ writer.print(getPrintableString(getMessage(event)));
}
writer.flush();
}
@@ -185,7 +193,7 @@ public class PrintCommandListener implements ProtocolCommandListener {
if (showDirection) {
writer.print(DIRECTION_MARKER_RECEIVE);
}
- final String message = event.getMessage();
+ final String message = getMessage(event);
final char last = message.charAt(message.length() - 1);
writer.print(message);
if (last != '\r' && last != '\n') {
(commons-net) 03/09: Camel case instance variable
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 62224d93b2cbf1e289a6fd4a1b10a9e46dc88020
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Thu Jul 17 07:38:36 2025 -0400
Camel case instance variable
---
src/main/java/org/apache/commons/net/PrintCommandListener.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/commons/net/PrintCommandListener.java b/src/main/java/org/apache/commons/net/PrintCommandListener.java
index 925e8887..71664f66 100644
--- a/src/main/java/org/apache/commons/net/PrintCommandListener.java
+++ b/src/main/java/org/apache/commons/net/PrintCommandListener.java
@@ -35,7 +35,7 @@ public class PrintCommandListener implements ProtocolCommandListener {
private static final String CMD_USER = "USER";
private static final String CMD_PASS = "PASS";
private final PrintWriter writer;
- private final boolean nologin;
+ private final boolean noLogin;
private final char eolMarker;
private final boolean directionMarker;
@@ -132,7 +132,7 @@ public class PrintCommandListener implements ProtocolCommandListener {
*/
public PrintCommandListener(final PrintWriter writer, final boolean suppressLogin, final char eolMarker, final boolean showDirection) {
this.writer = writer;
- this.nologin = suppressLogin;
+ this.noLogin = suppressLogin;
this.eolMarker = eolMarker;
this.directionMarker = showDirection;
}
@@ -157,7 +157,7 @@ public class PrintCommandListener implements ProtocolCommandListener {
if (directionMarker) {
writer.print("> ");
}
- if (nologin) {
+ if (noLogin) {
final String cmd = event.getCommand();
if (CMD_PASS.equalsIgnoreCase(cmd) || CMD_USER.equalsIgnoreCase(cmd)) {
writer.print(cmd);
(commons-net) 01/09: Extract constants
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 37bef9d123daf7daff1e9a3bfa3540340e1f6333
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Thu Jul 17 07:36:12 2025 -0400
Extract constants
---
.../java/org/apache/commons/net/PrintCommandListener.java | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/commons/net/PrintCommandListener.java b/src/main/java/org/apache/commons/net/PrintCommandListener.java
index 24f27726..b878b67a 100644
--- a/src/main/java/org/apache/commons/net/PrintCommandListener.java
+++ b/src/main/java/org/apache/commons/net/PrintCommandListener.java
@@ -30,6 +30,10 @@ import org.apache.commons.net.io.Util;
*/
public class PrintCommandListener implements ProtocolCommandListener {
+ private static final String HIDDEN_MARKER = " *******";
+ private static final String CMD_LOGIN = "LOGIN";
+ private static final String CMD_USER = "USER";
+ private static final String CMD_PASS = "PASS";
private final PrintWriter writer;
private final boolean nologin;
private final char eolMarker;
@@ -155,16 +159,15 @@ public class PrintCommandListener implements ProtocolCommandListener {
}
if (nologin) {
final String cmd = event.getCommand();
- if ("PASS".equalsIgnoreCase(cmd) || "USER".equalsIgnoreCase(cmd)) {
+ if (CMD_PASS.equalsIgnoreCase(cmd) || CMD_USER.equalsIgnoreCase(cmd)) {
writer.print(cmd);
- writer.println(" *******"); // Don't bother with EOL marker for this!
+ writer.println(HIDDEN_MARKER); // Don't bother with EOL marker for this!
} else {
- final String IMAP_LOGIN = "LOGIN";
- if (IMAP_LOGIN.equalsIgnoreCase(cmd)) { // IMAP
+ if (CMD_LOGIN.equalsIgnoreCase(cmd)) { // IMAP
String msg = event.getMessage();
- msg = msg.substring(0, msg.indexOf(IMAP_LOGIN) + IMAP_LOGIN.length());
+ msg = msg.substring(0, msg.indexOf(CMD_LOGIN) + CMD_LOGIN.length());
writer.print(msg);
- writer.println(" *******"); // Don't bother with EOL marker for this!
+ writer.println(HIDDEN_MARKER); // Don't bother with EOL marker for this!
} else {
writer.print(getPrintableString(event.getMessage()));
}
(commons-net) 04/09: Convert to upper case instead of cases-insensitive comparison x3
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 a75791565ba72b9169c67abff532b922be22da81
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Thu Jul 17 07:41:55 2025 -0400
Convert to upper case instead of cases-insensitive comparison x3
---
src/main/java/org/apache/commons/net/PrintCommandListener.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/commons/net/PrintCommandListener.java b/src/main/java/org/apache/commons/net/PrintCommandListener.java
index 71664f66..f21109e6 100644
--- a/src/main/java/org/apache/commons/net/PrintCommandListener.java
+++ b/src/main/java/org/apache/commons/net/PrintCommandListener.java
@@ -19,6 +19,8 @@ package org.apache.commons.net;
import java.io.PrintStream;
import java.io.PrintWriter;
+import java.util.Locale;
+import java.util.Objects;
import org.apache.commons.net.io.Util;
@@ -158,11 +160,11 @@ public class PrintCommandListener implements ProtocolCommandListener {
writer.print("> ");
}
if (noLogin) {
- final String cmd = event.getCommand();
- if (CMD_PASS.equalsIgnoreCase(cmd) || CMD_USER.equalsIgnoreCase(cmd)) {
+ final String cmd = Objects.toString(event.getCommand()).toUpperCase(Locale.ROOT);
+ if (CMD_PASS.equals(cmd) || CMD_USER.equals(cmd)) {
writer.print(cmd);
writer.println(HIDDEN_MARKER); // Don't bother with EOL marker for this!
- } else if (CMD_LOGIN.equalsIgnoreCase(cmd)) { // IMAP
+ } else if (CMD_LOGIN.equals(cmd)) { // IMAP
String msg = event.getMessage();
msg = msg.substring(0, msg.indexOf(CMD_LOGIN) + CMD_LOGIN.length());
writer.print(msg);
(commons-net) 06/09: Extract constants
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 526dce58400d35a90ea679f5fd43e99c81338b65
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Thu Jul 17 07:44:14 2025 -0400
Extract constants
---
src/main/java/org/apache/commons/net/PrintCommandListener.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/commons/net/PrintCommandListener.java b/src/main/java/org/apache/commons/net/PrintCommandListener.java
index 220e76b8..5ad6df25 100644
--- a/src/main/java/org/apache/commons/net/PrintCommandListener.java
+++ b/src/main/java/org/apache/commons/net/PrintCommandListener.java
@@ -32,6 +32,8 @@ import org.apache.commons.net.io.Util;
*/
public class PrintCommandListener implements ProtocolCommandListener {
+ private static final String DIRECTION_MARKER_RECEIVE = "< ";
+ private static final String DIRECTION_MARKER_SEND = "> ";
private static final String HIDDEN_MARKER = " *******";
private static final String CMD_LOGIN = "LOGIN";
private static final String CMD_USER = "USER";
@@ -157,7 +159,7 @@ public class PrintCommandListener implements ProtocolCommandListener {
@Override
public void protocolCommandSent(final ProtocolCommandEvent event) {
if (showDirection) {
- writer.print("> ");
+ writer.print(DIRECTION_MARKER_SEND);
}
if (noLogin) {
final String cmd = Objects.toString(event.getCommand()).toUpperCase(Locale.ROOT);
@@ -181,7 +183,7 @@ public class PrintCommandListener implements ProtocolCommandListener {
@Override
public void protocolReplyReceived(final ProtocolCommandEvent event) {
if (showDirection) {
- writer.print("< ");
+ writer.print(DIRECTION_MARKER_RECEIVE);
}
final String message = event.getMessage();
final char last = message.charAt(message.length() - 1);
(commons-net) 09/09: Merge branch 'master' of https://github.com/apache/commons-net.git
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 c94cda6e5e15914994e801e18e8f3c3849667063
Merge: a2c748f1 d794583e
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Thu Jul 17 07:55:13 2025 -0400
Merge branch 'master' of https://github.com/apache/commons-net.git
.../java/org/apache/commons/net/ftp/FTPClient.java | 7 ++-
.../commons/net/ftp/parser/UnixFTPEntryParser.java | 54 +++++++++-------------
2 files changed, 24 insertions(+), 37 deletions(-)