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:11 UTC
(commons-net) 07/09: Fail-fast in org.apache.commons.net.PrintCommandListener.PrintCommandListener(PrintWriter, boolean, char, boolean) if PrintWriter is null
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;