From 8c82429124d179c2c429815c6ec25b0402ba877d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Aug 2023 02:54:07 +0000 Subject: [PATCH 01/45] Bump github/codeql-action from 2.21.3 to 2.21.4 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.3 to 2.21.4. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/5b6282e01c62d02e720b81eb8a51204f527c3624...a09933a12a80f87b87005513f0abb1494c27a716) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 1b09e247b..cce187db1 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -57,7 +57,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@5b6282e01c62d02e720b81eb8a51204f527c3624 # v2.21.3 + uses: github/codeql-action/init@a09933a12a80f87b87005513f0abb1494c27a716 # v2.21.4 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -68,7 +68,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@5b6282e01c62d02e720b81eb8a51204f527c3624 # v2.21.3 + uses: github/codeql-action/autobuild@a09933a12a80f87b87005513f0abb1494c27a716 # v2.21.4 # ℹī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -82,4 +82,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@5b6282e01c62d02e720b81eb8a51204f527c3624 # v2.21.3 + uses: github/codeql-action/analyze@a09933a12a80f87b87005513f0abb1494c27a716 # v2.21.4 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 999dfca10..a96099e66 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -64,6 +64,6 @@ jobs: retention-days: 5 - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@5b6282e01c62d02e720b81eb8a51204f527c3624 # 2.21.3 + uses: github/codeql-action/upload-sarif@a09933a12a80f87b87005513f0abb1494c27a716 # 2.21.4 with: sarif_file: results.sarif From ee902fceaa8d96dc0bce0aaa8cac5ec2385109a4 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 19 Aug 2023 07:53:14 -0400 Subject: [PATCH 02/45] Better internal class name --- ...eTestFramework.java => AbstractFTPParseTest.java} | 4 ++-- .../ftp/parser/CompositeFTPParseTestFramework.java | 2 +- .../ftp/parser/EnterpriseUnixFTPEntryParserTest.java | 12 ++++++------ .../commons/net/ftp/parser/MLSxEntryParserTest.java | 2 +- .../net/ftp/parser/MVSFTPEntryParserTest.java | 4 ++-- .../net/ftp/parser/MacOsPeterFTPEntryParserTest.java | 2 +- .../commons/net/ftp/parser/NTFTPEntryParserTest.java | 6 +++--- .../net/ftp/parser/NetwareFTPEntryParserTest.java | 2 +- .../net/ftp/parser/OS2FTPEntryParserTest.java | 2 +- .../net/ftp/parser/OS400FTPEntryParserTest.java | 10 +++++----- .../net/ftp/parser/UnixFTPEntryParserTest.java | 2 +- .../net/ftp/parser/VMSFTPEntryParserTest.java | 2 +- ...act.java => AbstractTelnetOptionHandlerTest.java} | 2 +- .../commons/net/telnet/EchoOptionHandlerTest.java | 2 +- .../commons/net/telnet/SimpleOptionHandlerTest.java | 2 +- .../net/telnet/SuppressGAOptionHandlerTest.java | 2 +- .../net/telnet/TerminalTypeOptionHandlerTest.java | 2 +- .../net/telnet/WindowSizeOptionHandlerTest.java | 2 +- 18 files changed, 31 insertions(+), 31 deletions(-) rename src/test/java/org/apache/commons/net/ftp/parser/{FTPParseTestFramework.java => AbstractFTPParseTest.java} (98%) rename src/test/java/org/apache/commons/net/telnet/{TelnetOptionHandlerTestAbstract.java => AbstractTelnetOptionHandlerTest.java} (98%) diff --git a/src/test/java/org/apache/commons/net/ftp/parser/FTPParseTestFramework.java b/src/test/java/org/apache/commons/net/ftp/parser/AbstractFTPParseTest.java similarity index 98% rename from src/test/java/org/apache/commons/net/ftp/parser/FTPParseTestFramework.java rename to src/test/java/org/apache/commons/net/ftp/parser/AbstractFTPParseTest.java index 2fbba3abd..0975ed89f 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/FTPParseTestFramework.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/AbstractFTPParseTest.java @@ -28,7 +28,7 @@ /** */ -public abstract class FTPParseTestFramework extends TestCase { +public abstract class AbstractFTPParseTest extends TestCase { // associate Calendar unit ints with a readable string // MUST be listed least significant first, as the routine needs to // find the previous - less significant - entry @@ -50,7 +50,7 @@ protected enum CalendarUnit { /** * @see junit.framework.TestCase#TestCase(String) */ - public FTPParseTestFramework(final String name) { + public AbstractFTPParseTest(final String name) { super(name); } diff --git a/src/test/java/org/apache/commons/net/ftp/parser/CompositeFTPParseTestFramework.java b/src/test/java/org/apache/commons/net/ftp/parser/CompositeFTPParseTestFramework.java index 59e9723d7..836546a8c 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/CompositeFTPParseTestFramework.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/CompositeFTPParseTestFramework.java @@ -21,7 +21,7 @@ /** */ -public abstract class CompositeFTPParseTestFramework extends FTPParseTestFramework { +public abstract class CompositeFTPParseTestFramework extends AbstractFTPParseTest { public CompositeFTPParseTestFramework(final String name) { super(name); } diff --git a/src/test/java/org/apache/commons/net/ftp/parser/EnterpriseUnixFTPEntryParserTest.java b/src/test/java/org/apache/commons/net/ftp/parser/EnterpriseUnixFTPEntryParserTest.java index 0ab1bdb7e..4028a7482 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/EnterpriseUnixFTPEntryParserTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/EnterpriseUnixFTPEntryParserTest.java @@ -29,7 +29,7 @@ /** * Tests the EnterpriseUnixFTPEntryParser */ -public class EnterpriseUnixFTPEntryParserTest extends FTPParseTestFramework { +public class EnterpriseUnixFTPEntryParserTest extends AbstractFTPParseTest { private static final String[] BADSAMPLES = { "zrwxr-xr-x 2 root root 4096 Mar 2 15:13 zxbox", "dxrwr-xr-x 2 root root 4096 Aug 24 2001 zxjdbc", "drwxr-xr-x 2 root root 4096 Jam 4 00:03 zziplib", @@ -78,7 +78,7 @@ private void checkPermisions(final FTPFile dir) { } /** - * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getBadListing() + * @see org.apache.commons.net.ftp.parser.AbstractFTPParseTest#getBadListing() */ @Override protected String[] getBadListing() { @@ -86,7 +86,7 @@ protected String[] getBadListing() { } /** - * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getGoodListing() + * @see org.apache.commons.net.ftp.parser.AbstractFTPParseTest#getGoodListing() */ @Override protected String[] getGoodListing() { @@ -94,7 +94,7 @@ protected String[] getGoodListing() { } /** - * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getParser() + * @see org.apache.commons.net.ftp.parser.AbstractFTPParseTest#getParser() */ @Override protected FTPFileEntryParser getParser() { @@ -107,7 +107,7 @@ public void testDefaultPrecision() { } /** - * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnDirectory() + * @see org.apache.commons.net.ftp.parser.AbstractFTPParseTest#testParseFieldsOnDirectory() */ @Override public void testParseFieldsOnDirectory() throws Exception { @@ -115,7 +115,7 @@ public void testParseFieldsOnDirectory() throws Exception { } /** - * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnFile() + * @see org.apache.commons.net.ftp.parser.AbstractFTPParseTest#testParseFieldsOnFile() */ @Override public void testParseFieldsOnFile() throws Exception { diff --git a/src/test/java/org/apache/commons/net/ftp/parser/MLSxEntryParserTest.java b/src/test/java/org/apache/commons/net/ftp/parser/MLSxEntryParserTest.java index 01c2fe101..3cc807709 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/MLSxEntryParserTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/MLSxEntryParserTest.java @@ -21,7 +21,7 @@ /** */ -public class MLSxEntryParserTest extends FTPParseTestFramework { +public class MLSxEntryParserTest extends AbstractFTPParseTest { private static final String[] badsamples = { "Type=cdir;Modify=20141022065101;UNIX.mode=0775;/no/space", // no space between facts and name "Type=cdir;Modify=20141022065103;UNIX.mode=0775;", // no name or space diff --git a/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java b/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java index 5cd868d72..4b361e29e 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java @@ -26,7 +26,7 @@ /** * Test suite addapted to new MVSFTPEntryParser.java. */ -public class MVSFTPEntryParserTest extends FTPParseTestFramework { +public class MVSFTPEntryParserTest extends AbstractFTPParseTest { private static final String[] goodsamplesDatasetList = { /* Note, if the string begins with SAVE, the parsed entry is stored in the List saveftpfiles */ @@ -110,7 +110,7 @@ protected String[] getGoodListing() { } /** - * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getParser() + * @see org.apache.commons.net.ftp.parser.AbstractFTPParseTest#getParser() */ @Override protected FTPFileEntryParser getParser() { diff --git a/src/test/java/org/apache/commons/net/ftp/parser/MacOsPeterFTPEntryParserTest.java b/src/test/java/org/apache/commons/net/ftp/parser/MacOsPeterFTPEntryParserTest.java index 6aa6a4d2b..3dd88cd7e 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/MacOsPeterFTPEntryParserTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/MacOsPeterFTPEntryParserTest.java @@ -21,7 +21,7 @@ import org.apache.commons.net.ftp.FTPFile; import org.apache.commons.net.ftp.FTPFileEntryParser; -public class MacOsPeterFTPEntryParserTest extends FTPParseTestFramework { +public class MacOsPeterFTPEntryParserTest extends AbstractFTPParseTest { private static final String[] badsamples = { "drwxr-xr-x 123 folder 0 Jan 4 14:49 Steak", }; diff --git a/src/test/java/org/apache/commons/net/ftp/parser/NTFTPEntryParserTest.java b/src/test/java/org/apache/commons/net/ftp/parser/NTFTPEntryParserTest.java index 5db1de1e7..ebafc2045 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/NTFTPEntryParserTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/NTFTPEntryParserTest.java @@ -125,7 +125,7 @@ protected String[][] getGoodListings() { } /** - * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getParser() + * @see org.apache.commons.net.ftp.parser.AbstractFTPParseTest#getParser() */ @Override protected FTPFileEntryParser getParser() { @@ -202,7 +202,7 @@ private int testNET516(final String charset) throws Exception { } /** - * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnDirectory() + * @see org.apache.commons.net.ftp.parser.AbstractFTPParseTest#testParseFieldsOnDirectory() */ @Override public void testParseFieldsOnDirectory() throws Exception { @@ -222,7 +222,7 @@ public void testParseFieldsOnDirectory() throws Exception { } /** - * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnFile() + * @see org.apache.commons.net.ftp.parser.AbstractFTPParseTest#testParseFieldsOnFile() */ @Override public void testParseFieldsOnFile() throws Exception { diff --git a/src/test/java/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java b/src/test/java/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java index a41dfc62f..5f1406490 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java @@ -23,7 +23,7 @@ /** */ -public class NetwareFTPEntryParserTest extends FTPParseTestFramework { +public class NetwareFTPEntryParserTest extends AbstractFTPParseTest { private static final String[] badsamples = { "a [-----F--] SCION_SYS 512 Apr 13 23:52 SYS", "d [----AF--] 0 512 10-04-2001 _ADMIN" }; diff --git a/src/test/java/org/apache/commons/net/ftp/parser/OS2FTPEntryParserTest.java b/src/test/java/org/apache/commons/net/ftp/parser/OS2FTPEntryParserTest.java index af3bf2e57..da9d2d63d 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/OS2FTPEntryParserTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/OS2FTPEntryParserTest.java @@ -19,7 +19,7 @@ import org.apache.commons.net.ftp.FTPFile; import org.apache.commons.net.ftp.FTPFileEntryParser; -public class OS2FTPEntryParserTest extends FTPParseTestFramework { +public class OS2FTPEntryParserTest extends AbstractFTPParseTest { private static final String[] badsamples = { " DIR 12-30-97 12:32 jbrekke", " 0 rsa DIR 11-25-97 09:42 junk", " 0 dir 05-12-97 16:44 LANGUAGE", " 0 DIR 13-05-97 25:49 MPTN", diff --git a/src/test/java/org/apache/commons/net/ftp/parser/OS400FTPEntryParserTest.java b/src/test/java/org/apache/commons/net/ftp/parser/OS400FTPEntryParserTest.java index 07f473e23..b67b4f78f 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/OS400FTPEntryParserTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/OS400FTPEntryParserTest.java @@ -57,7 +57,7 @@ protected void doAdditionalGoodTests(final String test, final FTPFile f) { } /** - * @see FTPParseTestFramework#getBadListing() + * @see AbstractFTPParseTest#getBadListing() */ @Override protected String[][] getBadListings() { @@ -65,7 +65,7 @@ protected String[][] getBadListings() { } /** - * @see FTPParseTestFramework#getGoodListing() + * @see AbstractFTPParseTest#getGoodListing() */ @Override protected String[][] getGoodListings() { @@ -73,7 +73,7 @@ protected String[][] getGoodListings() { } /** - * @see FTPParseTestFramework#getParser() + * @see AbstractFTPParseTest#getParser() */ @Override protected FTPFileEntryParser getParser() { @@ -110,7 +110,7 @@ public void testNET573() { } /** - * @see FTPParseTestFramework#testParseFieldsOnDirectory() + * @see AbstractFTPParseTest#testParseFieldsOnDirectory() */ @Override public void testParseFieldsOnDirectory() throws Exception { @@ -134,7 +134,7 @@ public void testParseFieldsOnDirectory() throws Exception { } /** - * @see FTPParseTestFramework#testParseFieldsOnFile() + * @see AbstractFTPParseTest#testParseFieldsOnFile() */ @Override public void testParseFieldsOnFile() throws Exception { diff --git a/src/test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java b/src/test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java index da2884658..2dc1da96e 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java @@ -23,7 +23,7 @@ /** */ -public class UnixFTPEntryParserTest extends FTPParseTestFramework { +public class UnixFTPEntryParserTest extends AbstractFTPParseTest { private static final String[] badsamples = { "zrwxr-xr-x 2 root root 4096 Mar 2 15:13 zxbox", "dxrwr-xr-x 2 root root 4096 Aug 24 2001 zxjdbc", "drwxr-xr-x 2 root root 4096 Jam 4 00:03 zziplib", diff --git a/src/test/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java b/src/test/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java index e3afde28d..29be8edcd 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java @@ -25,7 +25,7 @@ /** */ -public class VMSFTPEntryParserTest extends FTPParseTestFramework { +public class VMSFTPEntryParserTest extends AbstractFTPParseTest { private static final String[] BAD_SAMPLES = { "1-JUN.LIS;2 9/9 JUN-2-1998 07:32:04 [GROUP,OWNER] (RWED,RWED,RWED,)", diff --git a/src/test/java/org/apache/commons/net/telnet/TelnetOptionHandlerTestAbstract.java b/src/test/java/org/apache/commons/net/telnet/AbstractTelnetOptionHandlerTest.java similarity index 98% rename from src/test/java/org/apache/commons/net/telnet/TelnetOptionHandlerTestAbstract.java rename to src/test/java/org/apache/commons/net/telnet/AbstractTelnetOptionHandlerTest.java index 272e26981..d7942b49f 100644 --- a/src/test/java/org/apache/commons/net/telnet/TelnetOptionHandlerTestAbstract.java +++ b/src/test/java/org/apache/commons/net/telnet/AbstractTelnetOptionHandlerTest.java @@ -22,7 +22,7 @@ * The TelnetOptionHandlerTest is the abstract class for testing TelnetOptionHandler. It can be used to derive the actual test classes for TelnetOptionHadler * derived classes, by adding creation of three new option handlers and testing of the specific subnegotiation behavior. */ -public abstract class TelnetOptionHandlerTestAbstract extends TestCase { +public abstract class AbstractTelnetOptionHandlerTest extends TestCase { TelnetOptionHandler opthand1; TelnetOptionHandler opthand2; TelnetOptionHandler opthand3; diff --git a/src/test/java/org/apache/commons/net/telnet/EchoOptionHandlerTest.java b/src/test/java/org/apache/commons/net/telnet/EchoOptionHandlerTest.java index be9b3680e..b2cb38617 100644 --- a/src/test/java/org/apache/commons/net/telnet/EchoOptionHandlerTest.java +++ b/src/test/java/org/apache/commons/net/telnet/EchoOptionHandlerTest.java @@ -19,7 +19,7 @@ /** * JUnit test class for EchoOptionHandler */ -public class EchoOptionHandlerTest extends TelnetOptionHandlerTestAbstract { +public class EchoOptionHandlerTest extends AbstractTelnetOptionHandlerTest { /** * setUp for the test. diff --git a/src/test/java/org/apache/commons/net/telnet/SimpleOptionHandlerTest.java b/src/test/java/org/apache/commons/net/telnet/SimpleOptionHandlerTest.java index a559f4729..e41b23cf1 100644 --- a/src/test/java/org/apache/commons/net/telnet/SimpleOptionHandlerTest.java +++ b/src/test/java/org/apache/commons/net/telnet/SimpleOptionHandlerTest.java @@ -19,7 +19,7 @@ /** * JUnit test class for SimpleOptionHandler */ -public class SimpleOptionHandlerTest extends TelnetOptionHandlerTestAbstract { +public class SimpleOptionHandlerTest extends AbstractTelnetOptionHandlerTest { /** * setUp for the test. */ diff --git a/src/test/java/org/apache/commons/net/telnet/SuppressGAOptionHandlerTest.java b/src/test/java/org/apache/commons/net/telnet/SuppressGAOptionHandlerTest.java index f1b8e7276..6f35a18fd 100644 --- a/src/test/java/org/apache/commons/net/telnet/SuppressGAOptionHandlerTest.java +++ b/src/test/java/org/apache/commons/net/telnet/SuppressGAOptionHandlerTest.java @@ -19,7 +19,7 @@ /** * JUnit test class for SuppressGAOptionHandler */ -public class SuppressGAOptionHandlerTest extends TelnetOptionHandlerTestAbstract { +public class SuppressGAOptionHandlerTest extends AbstractTelnetOptionHandlerTest { /** * setUp for the test. diff --git a/src/test/java/org/apache/commons/net/telnet/TerminalTypeOptionHandlerTest.java b/src/test/java/org/apache/commons/net/telnet/TerminalTypeOptionHandlerTest.java index 7859e48da..1a9d3e2a9 100644 --- a/src/test/java/org/apache/commons/net/telnet/TerminalTypeOptionHandlerTest.java +++ b/src/test/java/org/apache/commons/net/telnet/TerminalTypeOptionHandlerTest.java @@ -16,7 +16,7 @@ */ package org.apache.commons.net.telnet; -public class TerminalTypeOptionHandlerTest extends TelnetOptionHandlerTestAbstract { +public class TerminalTypeOptionHandlerTest extends AbstractTelnetOptionHandlerTest { /* * compares two arrays of int */ diff --git a/src/test/java/org/apache/commons/net/telnet/WindowSizeOptionHandlerTest.java b/src/test/java/org/apache/commons/net/telnet/WindowSizeOptionHandlerTest.java index 8fe0c7167..badc1b95b 100644 --- a/src/test/java/org/apache/commons/net/telnet/WindowSizeOptionHandlerTest.java +++ b/src/test/java/org/apache/commons/net/telnet/WindowSizeOptionHandlerTest.java @@ -19,7 +19,7 @@ /** * JUnit test class for TerminalTypeOptionHandler */ -public class WindowSizeOptionHandlerTest extends TelnetOptionHandlerTestAbstract { +public class WindowSizeOptionHandlerTest extends AbstractTelnetOptionHandlerTest { /** * compares two arrays of int */ From d47c87e7e7d95fa7ac2c6eda50b1a886ab306196 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 22 Aug 2023 10:13:19 -0400 Subject: [PATCH 03/45] Fix formatting --- .../commons/net/examples/ftp/ServerToServerFTP.java | 2 +- src/main/java/org/apache/commons/net/ftp/FTPClient.java | 8 ++++---- src/main/java/org/apache/commons/net/smtp/SMTPClient.java | 4 ++-- .../org/apache/commons/net/smtp/SimpleSMTPHeader.java | 4 ++-- .../org/apache/commons/net/telnet/TelnetClientTest.java | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/apache/commons/net/examples/ftp/ServerToServerFTP.java b/src/main/java/org/apache/commons/net/examples/ftp/ServerToServerFTP.java index 86631d3aa..ade654eb7 100644 --- a/src/main/java/org/apache/commons/net/examples/ftp/ServerToServerFTP.java +++ b/src/main/java/org/apache/commons/net/examples/ftp/ServerToServerFTP.java @@ -165,7 +165,7 @@ public static void main(final String[] args) { System.err.println("Couldn't initiate transfer. Check that file names are valid."); break __main; } - // if(ftp1.remoteRetrieve(file1) && ftp2.remoteStore(file2)) { + // if (ftp1.remoteRetrieve(file1) && ftp2.remoteStore(file2)) { // We have to fetch the positive completion reply. ftp1.completePendingCommand(); ftp2.completePendingCommand(); diff --git a/src/main/java/org/apache/commons/net/ftp/FTPClient.java b/src/main/java/org/apache/commons/net/ftp/FTPClient.java index 854719531..c169f808f 100644 --- a/src/main/java/org/apache/commons/net/ftp/FTPClient.java +++ b/src/main/java/org/apache/commons/net/ftp/FTPClient.java @@ -85,7 +85,7 @@ * // success. * reply = ftp.getReplyCode(); * - * if(!FTPReply.isPositiveCompletion(reply)) { + * if (!FTPReply.isPositiveCompletion(reply)) { * ftp.disconnect(); * System.err.println("FTP server refused connection."); * System.exit(1); @@ -96,7 +96,7 @@ * error = true; * e.printStackTrace(); * } finally { - * if(ftp.isConnected()) { + * if (ftp.isConnected()) { * try { * ftp.disconnect(); * } catch (IOException ioe) { @@ -1164,7 +1164,7 @@ public boolean changeWorkingDirectory(final String pathname) throws IOException * OutputStream output; * input = new FileInputStream("foobaz.txt"); * output = ftp.storeFileStream("foobar.txt") - * if(!FTPReply.isPositiveIntermediate(ftp.getReplyCode())) { + * if (!FTPReply.isPositiveIntermediate(ftp.getReplyCode())) { * input.close(); * output.close(); * ftp.logout(); @@ -1176,7 +1176,7 @@ public boolean changeWorkingDirectory(final String pathname) throws IOException * input.close(); * output.close(); * // Must call completePendingCommand() to finish command. - * if(!ftp.completePendingCommand()) { + * if (!ftp.completePendingCommand()) { * ftp.logout(); * ftp.disconnect(); * System.err.println("File transfer failed."); diff --git a/src/main/java/org/apache/commons/net/smtp/SMTPClient.java b/src/main/java/org/apache/commons/net/smtp/SMTPClient.java index 3fb05f195..b1541af30 100644 --- a/src/main/java/org/apache/commons/net/smtp/SMTPClient.java +++ b/src/main/java/org/apache/commons/net/smtp/SMTPClient.java @@ -40,7 +40,7 @@ * // success. * reply = client.getReplyCode(); * - * if(!SMTPReply.isPositiveCompletion(reply)) { + * if (!SMTPReply.isPositiveCompletion(reply)) { * client.disconnect(); * System.err.println("SMTP server refused connection."); * System.exit(1); @@ -49,7 +49,7 @@ * // Do useful stuff here. * ... * } catch (IOException e) { - * if(client.isConnected()) { + * if (client.isConnected()) { * try { * client.disconnect(); * } catch (IOException f) { diff --git a/src/main/java/org/apache/commons/net/smtp/SimpleSMTPHeader.java b/src/main/java/org/apache/commons/net/smtp/SimpleSMTPHeader.java index b5b79fe5d..f86b926de 100644 --- a/src/main/java/org/apache/commons/net/smtp/SimpleSMTPHeader.java +++ b/src/main/java/org/apache/commons/net/smtp/SimpleSMTPHeader.java @@ -30,7 +30,7 @@ * *
  * writer = client.sendMessageData();
- * if(writer == null) // failure
+ * if (writer == null) // failure
  *   return false;
  * header =
  *    new SimpleSMTPHeader("foobar@foo.com", "foo@bar.com" "Just testing");
@@ -39,7 +39,7 @@
  * writer.write(header.toString());
  * writer.write("This is just a test");
  * writer.close();
- * if(!client.completePendingCommand()) // failure
+ * if (!client.completePendingCommand()) // failure
  *   return false;
  * 
* diff --git a/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java b/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java index 3daa56dd8..3f119cd09 100644 --- a/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java +++ b/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java @@ -664,7 +664,7 @@ public void testSetReaderThread() throws Exception { read_ok = true; } - // if(is1.available() == 6) + // if (is1.available() == 6) // { int read = 0; int pos = 0; @@ -695,7 +695,7 @@ public void testSetReaderThread() throws Exception { System.arraycopy(tmp, 0, buffread1, pos, read); pos += read; } - // if(is2.available() == 6) + // if (is2.available() == 6) // { is2.read(buffread1); From d97a9399b2bd44d04f73e9e7bf7cb8bcf27dea51 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 23 Aug 2023 06:34:11 -0400 Subject: [PATCH 04/45] Inline single use local variable --- .../ftp/parser/DefaultFTPFileEntryParserFactoryTest.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java b/src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java index 60023143a..db5e4bdb8 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java @@ -96,8 +96,7 @@ public void testDefaultParserFactory() { factory.createFileEntryParser("org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory"); fail("Exception should have been thrown. \"DefaultFTPFileEntryParserFactory\" does not implement FTPFileEntryParser"); } catch (final ParserInitializationException pie) { - final Throwable root = pie.getCause(); - assertTrue(root instanceof ClassCastException); + assertTrue(pie.getCause() instanceof ClassCastException); } try { @@ -105,16 +104,14 @@ public void testDefaultParserFactory() { factory.createFileEntryParser("org.apache.commons.net.ftp.parser.FTPFileEntryParserFactory"); fail("ParserInitializationException should have been thrown."); } catch (final ParserInitializationException pie) { - final Throwable root = pie.getCause(); - assertTrue(root instanceof InstantiationException); + assertTrue(pie.getCause() instanceof InstantiationException); } try { // Class exists, but is abstract factory.createFileEntryParser("org.apache.commons.net.ftp.FTPFileEntryParserImpl"); fail("ParserInitializationException should have been thrown."); } catch (final ParserInitializationException pie) { - final Throwable root = pie.getCause(); - assertTrue(root instanceof InstantiationException); + assertTrue(pie.getCause() instanceof InstantiationException); } } From 0f17b1087a0d19dd8b21328b66c24767d738d66c Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 23 Aug 2023 06:44:16 -0400 Subject: [PATCH 05/45] Use assertThrows --- .../commons/net/ftp/FTPClientConfigTest.java | 17 ++------- .../DefaultFTPFileEntryParserFactoryTest.java | 9 ++--- .../parser/FTPTimestampParserImplTest.java | 16 ++------ .../commons/net/tftp/TFTPServerPathTest.java | 37 ++++++++++--------- 4 files changed, 30 insertions(+), 49 deletions(-) diff --git a/src/test/java/org/apache/commons/net/ftp/FTPClientConfigTest.java b/src/test/java/org/apache/commons/net/ftp/FTPClientConfigTest.java index 0ba88105b..fbba6b03d 100644 --- a/src/test/java/org/apache/commons/net/ftp/FTPClientConfigTest.java +++ b/src/test/java/org/apache/commons/net/ftp/FTPClientConfigTest.java @@ -16,6 +16,8 @@ */ package org.apache.commons.net.ftp; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.text.DateFormatSymbols; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -111,19 +113,8 @@ public void testGetDateFormatSymbols() { assertEquals("different.parser.same.date", d1, d2); - try { - sdf1.parse("hij 31, 2004"); - fail("should.have.failed.to.parse.weird"); - } catch (final ParseException px) { - // expected - } - try { - sdf2.parse("dec 31, 2004"); - fail("should.have.failed.to.parse.standard"); - } catch (final ParseException px) { - // expected - } - + assertThrows(ParseException.class, () -> sdf1.parse("hij 31, 2004")); + assertThrows(ParseException.class, () -> sdf2.parse("dec 31, 2004")); } public void testGetServerLanguageCode() { diff --git a/src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java b/src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java index db5e4bdb8..08c3df148 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java @@ -16,6 +16,8 @@ */ package org.apache.commons.net.ftp.parser; +import static org.junit.jupiter.api.Assertions.assertThrows; + import org.apache.commons.net.ftp.FTPClientConfig; import org.apache.commons.net.ftp.FTPFileEntryParser; @@ -118,12 +120,7 @@ public void testDefaultParserFactory() { public void testDefaultParserFactoryConfig() throws Exception { final DefaultFTPFileEntryParserFactory factory = new DefaultFTPFileEntryParserFactory(); - try { - factory.createFileEntryParser((FTPClientConfig) null); - fail("Expected NullPointerException"); - } catch (final NullPointerException npe) { - // expected - } + assertThrows(NullPointerException.class, () -> factory.createFileEntryParser((FTPClientConfig) null)); checkParserClass(factory, null, UnixFTPEntryParser.class); checkParserClass(factory, FTPClientConfig.SYST_OS400, OS400FTPEntryParser.class); diff --git a/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java b/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java index 7e3c7538d..37524ab43 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java @@ -16,6 +16,8 @@ */ package org.apache.commons.net.ftp.parser; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.text.Format; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -151,18 +153,8 @@ public void testFeb29NonLeapYear() { // Note: we use a known leap year for the target date to avoid rounding up final GregorianCalendar input = new GregorianCalendar(2000, Calendar.FEBRUARY, 29); final GregorianCalendar expected = new GregorianCalendar(1999, Calendar.FEBRUARY, 29); - try { - checkShortParse("Feb 29th 1999", server, input, expected, true); - fail("Should have failed to parse Feb 29th 1999"); - } catch (final ParseException pe) { - // expected - } - try { - checkShortParse("Feb 29th 1999", server, input, expected, false); - fail("Should have failed to parse Feb 29th 1999"); - } catch (final ParseException pe) { - // expected - } + assertThrows(ParseException.class, () -> checkShortParse("Feb 29th 1999", server, input, expected, true)); + assertThrows(ParseException.class, () -> checkShortParse("Feb 29th 1999", server, input, expected, false)); } // Lenient mode allows for dates up to 1 day in the future diff --git a/src/test/java/org/apache/commons/net/tftp/TFTPServerPathTest.java b/src/test/java/org/apache/commons/net/tftp/TFTPServerPathTest.java index f21c6ed09..972cd007f 100644 --- a/src/test/java/org/apache/commons/net/tftp/TFTPServerPathTest.java +++ b/src/test/java/org/apache/commons/net/tftp/TFTPServerPathTest.java @@ -17,6 +17,7 @@ package org.apache.commons.net.tftp; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; @@ -89,12 +90,12 @@ public void testReadOnly() throws IOException { out.delete(); - try (final FileInputStream fis = new FileInputStream(file)) { - tftp.sendFile(out.getName(), TFTP.BINARY_MODE, fis, "localhost", SERVER_PORT); - fail("Server allowed write"); - } catch (final IOException e) { - // expected path - } + assertThrows(IOException.class, () -> { + try (final FileInputStream fis = new FileInputStream(file)) { + tftp.sendFile(out.getName(), TFTP.BINARY_MODE, fis, "localhost", SERVER_PORT); + fail("Server allowed write"); + } + }); } finally { deleteFixture(file); deleteFixture(out); @@ -117,12 +118,12 @@ public void testWriteOnly() throws IOException { // check old failed runs assertFalse(out.exists(), () -> "Couldn't clear output location, deleted="); - try (final FileOutputStream output = new FileOutputStream(out)) { - tftp.receiveFile(file.getName(), TFTP.BINARY_MODE, output, "localhost", SERVER_PORT); - fail("Server allowed read"); - } catch (final IOException e) { - // expected path - } + assertThrows(IOException.class, () -> { + try (final FileOutputStream output = new FileOutputStream(out)) { + tftp.receiveFile(file.getName(), TFTP.BINARY_MODE, output, "localhost", SERVER_PORT); + fail("Server allowed read"); + } + }); out.delete(); try (final FileInputStream fis = new FileInputStream(file)) { @@ -152,12 +153,12 @@ public void testWriteOutsideHome() throws IOException { try { assertFalse(new File(serverDirectory, "../foo").exists(), "test construction error"); - try (final FileInputStream fis = new FileInputStream(file)) { - tftp.sendFile("../foo", TFTP.BINARY_MODE, fis, "localhost", SERVER_PORT); - fail("Server allowed write!"); - } catch (final IOException e) { - // expected path - } + assertThrows(IOException.class, () -> { + try (final FileInputStream fis = new FileInputStream(file)) { + tftp.sendFile("../foo", TFTP.BINARY_MODE, fis, "localhost", SERVER_PORT); + fail("Server allowed write!"); + } + }); assertFalse(new File(serverDirectory, "../foo").exists(), "file created when it should not have been"); From 5c871feadc81b1a3acfedb6c142b3d2fb8457b3f Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 23 Aug 2023 07:22:03 -0400 Subject: [PATCH 06/45] Use assertThrows --- .../commons/net/ftp/FTPClientConfigTest.java | 21 ++------ .../parser/FTPTimestampParserImplTest.java | 53 +++---------------- .../apache/commons/net/util/Base64Test.java | 14 +---- 3 files changed, 13 insertions(+), 75 deletions(-) diff --git a/src/test/java/org/apache/commons/net/ftp/FTPClientConfigTest.java b/src/test/java/org/apache/commons/net/ftp/FTPClientConfigTest.java index fbba6b03d..b5318190a 100644 --- a/src/test/java/org/apache/commons/net/ftp/FTPClientConfigTest.java +++ b/src/test/java/org/apache/commons/net/ftp/FTPClientConfigTest.java @@ -71,24 +71,9 @@ public void testFTPClientConfigStringStringStringStringStringString() { public void testGetDateFormatSymbols() { - try { - FTPClientConfig.getDateFormatSymbols(badDelim); - fail("bad delimiter"); - } catch (final IllegalArgumentException e) { - // should have failed - } - try { - FTPClientConfig.getDateFormatSymbols(tooLong); - fail("more than 12 months"); - } catch (final IllegalArgumentException e) { - // should have failed - } - try { - FTPClientConfig.getDateFormatSymbols(tooShort); - fail("fewer than 12 months"); - } catch (final IllegalArgumentException e) { - // should have failed - } + assertThrows(IllegalArgumentException.class, () -> FTPClientConfig.getDateFormatSymbols(badDelim), "bad delimiter"); + assertThrows(IllegalArgumentException.class, () -> FTPClientConfig.getDateFormatSymbols(tooLong), "more than 12 months"); + assertThrows(IllegalArgumentException.class, () -> FTPClientConfig.getDateFormatSymbols(tooShort), "fewer than 12 months"); DateFormatSymbols dfs2 = null; try { dfs2 = FTPClientConfig.getDateFormatSymbols(fakeLang); diff --git a/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java b/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java index 37524ab43..541474e4d 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java @@ -202,67 +202,30 @@ public void testParseJan01Lenient() throws Exception { checkShortParse("2008-1-1", now, target, true); } - public void testParser() { + public void testParser() throws ParseException { // This test requires an English Locale final Locale locale = Locale.getDefault(); try { Locale.setDefault(Locale.ENGLISH); final FTPTimestampParserImpl parser = new FTPTimestampParserImpl(); - try { - parser.parseTimestamp("feb 22 2002"); - } catch (final ParseException e) { - fail("failed.to.parse.default"); - } - try { - final Calendar c = parser.parseTimestamp("f\u00e9v 22 2002"); - fail("should.have.failed.to.parse.default, but was: " + c.getTime().toString()); - } catch (final ParseException e) { - // this is the success case - } + parser.parseTimestamp("feb 22 2002"); + assertThrows(ParseException.class, () -> parser.parseTimestamp("f\u00e9v 22 2002")); final FTPClientConfig config = new FTPClientConfig(); config.setDefaultDateFormatStr("d MMM yyyy"); config.setRecentDateFormatStr("d MMM HH:mm"); config.setServerLanguageCode("fr"); parser.configure(config); - try { - parser.parseTimestamp("d\u00e9c 22 2002"); - fail("incorrect.field.order"); - } catch (final ParseException e) { - // this is the success case - } + assertThrows(ParseException.class, () -> parser.parseTimestamp("d\u00e9c 22 2002"), "incorrect.field.order"); try { parser.parseTimestamp("22 d\u00e9c 2002"); } catch (final ParseException e) { fail("failed.to.parse.french"); } - - try { - parser.parseTimestamp("22 dec 2002"); - fail("incorrect.language"); - } catch (final ParseException e) { - // this is the success case - } - try { - parser.parseTimestamp("29 f\u00e9v 2002"); - fail("nonexistent.date"); - } catch (final ParseException e) { - // this is the success case - } - - try { - parser.parseTimestamp("22 ao\u00fb 30:02"); - fail("bad.hour"); - } catch (final ParseException e) { - // this is the success case - } - - try { - parser.parseTimestamp("22 ao\u00fb 20:74"); - fail("bad.minute"); - } catch (final ParseException e) { - // this is the success case - } + assertThrows(ParseException.class, () -> parser.parseTimestamp("22 dec 2002"), "incorrect.language"); + assertThrows(ParseException.class, () -> parser.parseTimestamp("29 f\u00e9v 2002"), "nonexistent.date"); + assertThrows(ParseException.class, () -> parser.parseTimestamp("22 ao\u00fb 30:02"), "bad.hour"); + assertThrows(ParseException.class, () -> parser.parseTimestamp("22 ao\u00fb 20:74"), "bad.minute"); try { parser.parseTimestamp("28 ao\u00fb 20:02"); } catch (final ParseException e) { diff --git a/src/test/java/org/apache/commons/net/util/Base64Test.java b/src/test/java/org/apache/commons/net/util/Base64Test.java index 984af904a..576fe00f5 100644 --- a/src/test/java/org/apache/commons/net/util/Base64Test.java +++ b/src/test/java/org/apache/commons/net/util/Base64Test.java @@ -157,24 +157,14 @@ public void testEncodeBase64ByteArrayBooleanBooleanInt() { encoded = Base64.encodeBase64(binaryData, false, false); assertNotNull(encoded); assertEquals(4, encoded.length); - try { - Base64.encodeBase64(binaryData, false, false, 3); - fail("Expected IllegalArgumentException"); - } catch (final IllegalArgumentException expected) { - // expected - } + assertThrows(IllegalArgumentException.class, () -> Base64.encodeBase64(binaryData, false, false, 3)); encoded = Base64.encodeBase64(binaryData, false, false, 4); // NET-483 assertNotNull(encoded); assertEquals(4, encoded.length); encoded = Base64.encodeBase64(binaryData, true, false); assertNotNull(encoded); assertEquals(6, encoded.length); // always adds trailer - try { - Base64.encodeBase64(binaryData, true, false, 5); - fail("Expected IllegalArgumentException"); - } catch (final IllegalArgumentException expected) { - // expected - } + assertThrows(IllegalArgumentException.class, () -> Base64.encodeBase64(binaryData, true, false, 5)); encoded = Base64.encodeBase64(binaryData, true, false, 6); assertNotNull(encoded); assertEquals(6, encoded.length); From 8a2999ede8e675afe87aad01bb18eb3b9c127487 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 23 Aug 2023 08:53:16 -0400 Subject: [PATCH 07/45] Normalize array type declarations --- .../net/examples/ftp/FTPClientExample.java | 6 +- .../net/examples/mail/POP3ExportMbox.java | 2 +- .../commons/net/examples/mail/POP3Mail.java | 2 +- .../net/examples/nntp/MessageThreading.java | 2 +- .../net/examples/ntp/SimpleNTPServer.java | 2 +- .../net/ftp/parser/MLSxEntryParser.java | 2 +- .../net/ftp/parser/VMSFTPEntryParser.java | 2 +- .../apache/commons/net/nntp/NNTPClient.java | 8 +- .../commons/net/telnet/TelnetCommand.java | 2 +- .../commons/net/telnet/TelnetOption.java | 2 +- .../net/telnet/TerminalTypeOptionHandler.java | 2 +- .../net/telnet/WindowSizeOptionHandler.java | 2 +- .../apache/commons/net/util/SubnetUtils.java | 2 +- .../apache/commons/net/SubnetUtilsTest.java | 46 +++++----- .../net/telnet/EchoOptionHandlerTest.java | 8 +- .../net/telnet/SimpleOptionHandlerTest.java | 8 +- .../telnet/SuppressGAOptionHandlerTest.java | 8 +- .../telnet/TelnetClientFunctionalTest.java | 2 +- .../commons/net/telnet/TelnetClientTest.java | 84 +++++++++---------- .../net/telnet/TelnetTestResponder.java | 2 +- .../telnet/TerminalTypeOptionHandlerTest.java | 14 ++-- .../telnet/WindowSizeOptionHandlerTest.java | 8 +- 22 files changed, 108 insertions(+), 108 deletions(-) diff --git a/src/main/java/org/apache/commons/net/examples/ftp/FTPClientExample.java b/src/main/java/org/apache/commons/net/examples/ftp/FTPClientExample.java index a322941cf..b26f8f1e4 100644 --- a/src/main/java/org/apache/commons/net/examples/ftp/FTPClientExample.java +++ b/src/main/java/org/apache/commons/net/examples/ftp/FTPClientExample.java @@ -182,7 +182,7 @@ public static void main(final String[] args) throws UnknownHostException { displayTimeZoneId = args[++base]; } else if (args[base].equals("-PrH")) { proxyHost = args[++base]; - final String parts[] = proxyHost.split(":"); + final String[] parts = proxyHost.split(":"); if (parts.length == 2) { proxyHost = parts[0]; proxyPort = Integer.parseInt(parts[1]); @@ -213,7 +213,7 @@ public static void main(final String[] args) throws UnknownHostException { String server = args[base++]; int port = 0; - final String parts[] = server.split(":"); + final String[] parts = server.split(":"); if (parts.length == 2) { server = parts[0]; port = Integer.parseInt(parts[1]); @@ -248,7 +248,7 @@ public static void main(final String[] args) throws UnknownHostException { } else if (protocol.equals("false")) { ftps = new FTPSClient(false); } else { - final String prot[] = protocol.split(","); + final String[] prot = protocol.split(","); if (prot.length == 1) { // Just protocol ftps = new FTPSClient(protocol); } else { // protocol,true|false diff --git a/src/main/java/org/apache/commons/net/examples/mail/POP3ExportMbox.java b/src/main/java/org/apache/commons/net/examples/mail/POP3ExportMbox.java index f9296912a..a47359145 100644 --- a/src/main/java/org/apache/commons/net/examples/mail/POP3ExportMbox.java +++ b/src/main/java/org/apache/commons/net/examples/mail/POP3ExportMbox.java @@ -62,7 +62,7 @@ public static void main(final String[] args) { System.exit(1); } - final String arg0[] = args[argIdx++].split(":"); + final String[] arg0 = args[argIdx++].split(":"); final String server = arg0[0]; final String username = args[argIdx++]; String password = args[argIdx++]; diff --git a/src/main/java/org/apache/commons/net/examples/mail/POP3Mail.java b/src/main/java/org/apache/commons/net/examples/mail/POP3Mail.java index e5f59fb60..5a60e4e1e 100644 --- a/src/main/java/org/apache/commons/net/examples/mail/POP3Mail.java +++ b/src/main/java/org/apache/commons/net/examples/mail/POP3Mail.java @@ -41,7 +41,7 @@ public static void main(final String[] args) { System.exit(1); } - final String arg0[] = args[0].split(":"); + final String[] arg0 = args[0].split(":"); final String server = arg0[0]; final String username = args[1]; String password = args[2]; diff --git a/src/main/java/org/apache/commons/net/examples/nntp/MessageThreading.java b/src/main/java/org/apache/commons/net/examples/nntp/MessageThreading.java index 5be1bdb3d..54a5653e3 100644 --- a/src/main/java/org/apache/commons/net/examples/nntp/MessageThreading.java +++ b/src/main/java/org/apache/commons/net/examples/nntp/MessageThreading.java @@ -54,7 +54,7 @@ public static void main(final String[] args) throws SocketException, IOException } } - final String fmt[] = client.listOverviewFmt(); + final String[] fmt = client.listOverviewFmt(); if (fmt != null) { System.out.println("LIST OVERVIEW.FMT:"); for (final String s : fmt) { diff --git a/src/main/java/org/apache/commons/net/examples/ntp/SimpleNTPServer.java b/src/main/java/org/apache/commons/net/examples/ntp/SimpleNTPServer.java index cd10bb534..36c2163a6 100644 --- a/src/main/java/org/apache/commons/net/examples/ntp/SimpleNTPServer.java +++ b/src/main/java/org/apache/commons/net/examples/ntp/SimpleNTPServer.java @@ -162,7 +162,7 @@ public boolean isStarted() { @Override public void run() { running = true; - final byte buffer[] = new byte[48]; + final byte[] buffer = new byte[48]; final DatagramPacket request = new DatagramPacket(buffer, buffer.length); do { try { diff --git a/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java index 6364780d5..0687b5ff9 100644 --- a/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java +++ b/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java @@ -194,7 +194,7 @@ public FTPFile parseFTPEntry(final String entry) { return null; // Invalid - no pathname } - final String parts[] = entry.split(" ", 2); // Path may contain space + final String[] parts = entry.split(" ", 2); // Path may contain space if (parts.length != 2 || parts[1].isEmpty()) { return null; // no space found or no file name } diff --git a/src/main/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java index a6ea27d3b..8aa75779b 100644 --- a/src/main/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java +++ b/src/main/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java @@ -126,7 +126,7 @@ public FTPFile parseFTPEntry(final String entry) { final String size = group(2); final String datestr = group(3) + " " + group(4); final String owner = group(5); - final String permissions[] = new String[3]; + final String[] permissions = new String[3]; permissions[0] = group(9); permissions[1] = group(10); permissions[2] = group(11); diff --git a/src/main/java/org/apache/commons/net/nntp/NNTPClient.java b/src/main/java/org/apache/commons/net/nntp/NNTPClient.java index 0bc67d4d8..a994b93f2 100644 --- a/src/main/java/org/apache/commons/net/nntp/NNTPClient.java +++ b/src/main/java/org/apache/commons/net/nntp/NNTPClient.java @@ -76,7 +76,7 @@ static Article parseArticleEntry(final String line) { final Article article = new Article(); article.setSubject(line); // in case parsing fails - final String parts[] = line.split("\t"); + final String[] parts = line.split("\t"); if (parts.length > 6) { int i = 0; try { @@ -99,7 +99,7 @@ static Article parseArticleEntry(final String line) { */ private static void parseGroupReply(final String reply, final NewsgroupInfo info) throws MalformedServerReplyException { - final String tokens[] = reply.split(" "); + final String[] tokens = reply.split(" "); if (tokens.length >= 5) { int i = 1; // Skip numeric response value try { @@ -124,7 +124,7 @@ private static void parseGroupReply(final String reply, final NewsgroupInfo info // Format: group last first p static NewsgroupInfo parseNewsgroupListEntry(final String entry) { - final String tokens[] = entry.split(" "); + final String[] tokens = entry.split(" "); if (tokens.length < 4) { return null; } @@ -561,7 +561,7 @@ public boolean logout() throws IOException { * @throws MalformedServerReplyException if response could not be parsed */ private void parseArticlePointer(final String reply, final ArticleInfo pointer) throws MalformedServerReplyException { - final String tokens[] = reply.split(" "); + final String[] tokens = reply.split(" "); if (tokens.length >= 3) { // OK, we can parset the line int i = 1; // skip reply code try { diff --git a/src/main/java/org/apache/commons/net/telnet/TelnetCommand.java b/src/main/java/org/apache/commons/net/telnet/TelnetCommand.java index cd1ae813a..e483d6acf 100644 --- a/src/main/java/org/apache/commons/net/telnet/TelnetCommand.java +++ b/src/main/java/org/apache/commons/net/telnet/TelnetCommand.java @@ -92,7 +92,7 @@ public final class TelnetCommand { public static final int SYNCH = 242; /** String representations of commands. */ - private static final String commandString[] = { "IAC", "DONT", "DO", "WONT", "WILL", "SB", "GA", "EL", "EC", "AYT", "AO", "IP", "BRK", "DMARK", "NOP", "SE", + private static final String[] commandString = { "IAC", "DONT", "DO", "WONT", "WILL", "SB", "GA", "EL", "EC", "AYT", "AO", "IP", "BRK", "DMARK", "NOP", "SE", "EOR", "ABORT", "SUSP", "EOF" }; private static final int FIRST_COMMAND = IAC; diff --git a/src/main/java/org/apache/commons/net/telnet/TelnetOption.java b/src/main/java/org/apache/commons/net/telnet/TelnetOption.java index 5fc64dfcf..9d85c461b 100644 --- a/src/main/java/org/apache/commons/net/telnet/TelnetOption.java +++ b/src/main/java/org/apache/commons/net/telnet/TelnetOption.java @@ -117,7 +117,7 @@ public class TelnetOption { private static final int FIRST_OPTION = BINARY; private static final int LAST_OPTION = EXTENDED_OPTIONS_LIST; - private static final String optionString[] = { "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", + private static final String[] optionString = { "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", "TACACS UID", "OUTPUT MARKING", "TTYLOC", "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", "ENCRYPT", "NEW-ENVIRON", "TN3270E", "XAUTH", "CHARSET", "RSP", diff --git a/src/main/java/org/apache/commons/net/telnet/TerminalTypeOptionHandler.java b/src/main/java/org/apache/commons/net/telnet/TerminalTypeOptionHandler.java index 64ab01b66..d0b91fff0 100644 --- a/src/main/java/org/apache/commons/net/telnet/TerminalTypeOptionHandler.java +++ b/src/main/java/org/apache/commons/net/telnet/TerminalTypeOptionHandler.java @@ -82,7 +82,7 @@ public TerminalTypeOptionHandler(final String termtype, final boolean initlocal, public int[] answerSubnegotiation(final int suboptionData[], final int suboptionLength) { if ((suboptionData != null) && (suboptionLength > 1) && (termType != null)) { if ((suboptionData[0] == TERMINAL_TYPE) && (suboptionData[1] == TERMINAL_TYPE_SEND)) { - final int response[] = new int[termType.length() + 2]; + final int[] response = new int[termType.length() + 2]; response[0] = TERMINAL_TYPE; response[1] = TERMINAL_TYPE_IS; diff --git a/src/main/java/org/apache/commons/net/telnet/WindowSizeOptionHandler.java b/src/main/java/org/apache/commons/net/telnet/WindowSizeOptionHandler.java index 68a35784a..f54746134 100644 --- a/src/main/java/org/apache/commons/net/telnet/WindowSizeOptionHandler.java +++ b/src/main/java/org/apache/commons/net/telnet/WindowSizeOptionHandler.java @@ -105,7 +105,7 @@ public int[] startSubnegotiationLocal() { // // allocate response array // - final int response[] = new int[nResponseSize]; + final int[] response = new int[nResponseSize]; // // Build response array. diff --git a/src/main/java/org/apache/commons/net/util/SubnetUtils.java b/src/main/java/org/apache/commons/net/util/SubnetUtils.java index c722d6a80..74606ea82 100644 --- a/src/main/java/org/apache/commons/net/util/SubnetUtils.java +++ b/src/main/java/org/apache/commons/net/util/SubnetUtils.java @@ -195,7 +195,7 @@ private long networkLong() { * Converts a packed integer address into a 4-element array */ private int[] toArray(final int val) { - final int ret[] = new int[4]; + final int[] ret = new int[4]; for (int j = 3; j >= 0; --j) { ret[j] |= val >>> 8 * (3 - j) & 0xff; } diff --git a/src/test/java/org/apache/commons/net/SubnetUtilsTest.java b/src/test/java/org/apache/commons/net/SubnetUtilsTest.java index bf8250b11..5decde149 100644 --- a/src/test/java/org/apache/commons/net/SubnetUtilsTest.java +++ b/src/test/java/org/apache/commons/net/SubnetUtilsTest.java @@ -341,15 +341,15 @@ public void testNext() { @Test public void testParseSimpleNetmask() { final String address = "192.168.0.1"; - final String masks[] = { "255.0.0.0", "255.255.0.0", "255.255.255.0", "255.255.255.248" }; - final String bcastAddresses[] = { "192.255.255.255", "192.168.255.255", "192.168.0.255", "192.168.0.7" }; - final String lowAddresses[] = { "192.0.0.1", "192.168.0.1", "192.168.0.1", "192.168.0.1" }; - final String highAddresses[] = { "192.255.255.254", "192.168.255.254", "192.168.0.254", "192.168.0.6" }; - final String nextAddresses[] = { "192.168.0.2", "192.168.0.2", "192.168.0.2", "192.168.0.2" }; - final String previousAddresses[] = { "192.168.0.0", "192.168.0.0", "192.168.0.0", "192.168.0.0" }; - final String networkAddresses[] = { "192.0.0.0", "192.168.0.0", "192.168.0.0", "192.168.0.0" }; - final String cidrSignatures[] = { "192.168.0.1/8", "192.168.0.1/16", "192.168.0.1/24", "192.168.0.1/29" }; - final int usableAddresses[] = { 16777214, 65534, 254, 6 }; + final String[] masks = { "255.0.0.0", "255.255.0.0", "255.255.255.0", "255.255.255.248" }; + final String[] bcastAddresses = { "192.255.255.255", "192.168.255.255", "192.168.0.255", "192.168.0.7" }; + final String[] lowAddresses = { "192.0.0.1", "192.168.0.1", "192.168.0.1", "192.168.0.1" }; + final String[] highAddresses = { "192.255.255.254", "192.168.255.254", "192.168.0.254", "192.168.0.6" }; + final String[] nextAddresses = { "192.168.0.2", "192.168.0.2", "192.168.0.2", "192.168.0.2" }; + final String[] previousAddresses = { "192.168.0.0", "192.168.0.0", "192.168.0.0", "192.168.0.0" }; + final String[] networkAddresses = { "192.0.0.0", "192.168.0.0", "192.168.0.0", "192.168.0.0" }; + final String[] cidrSignatures = { "192.168.0.1/8", "192.168.0.1/16", "192.168.0.1/24", "192.168.0.1/29" }; + final int[] usableAddresses = { 16777214, 65534, 254, 6 }; for (int i = 0; i < masks.length; ++i) { final SubnetUtils utils = new SubnetUtils(address, masks[i]); @@ -369,13 +369,13 @@ public void testParseSimpleNetmask() { @Test public void testParseSimpleNetmaskExclusive() { final String address = "192.168.15.7"; - final String masks[] = { "255.255.255.252", "255.255.255.254", "255.255.255.255" }; - final String bcast[] = { "192.168.15.7", "192.168.15.7", "192.168.15.7" }; - final String netwk[] = { "192.168.15.4", "192.168.15.6", "192.168.15.7" }; - final String lowAd[] = { "192.168.15.5", "0.0.0.0", "0.0.0.0" }; - final String highA[] = { "192.168.15.6", "0.0.0.0", "0.0.0.0" }; - final String cidrS[] = { "192.168.15.7/30", "192.168.15.7/31", "192.168.15.7/32" }; - final int usableAd[] = { 2, 0, 0 }; + final String[] masks = { "255.255.255.252", "255.255.255.254", "255.255.255.255" }; + final String[] bcast = { "192.168.15.7", "192.168.15.7", "192.168.15.7" }; + final String[] netwk = { "192.168.15.4", "192.168.15.6", "192.168.15.7" }; + final String[] lowAd = { "192.168.15.5", "0.0.0.0", "0.0.0.0" }; + final String[] highA = { "192.168.15.6", "0.0.0.0", "0.0.0.0" }; + final String[] cidrS = { "192.168.15.7/30", "192.168.15.7/31", "192.168.15.7/32" }; + final int[] usableAd = { 2, 0, 0 }; // low and high addresses don't exist for (int i = 0; i < masks.length; ++i) { @@ -394,13 +394,13 @@ public void testParseSimpleNetmaskExclusive() { @Test public void testParseSimpleNetmaskInclusive() { final String address = "192.168.15.7"; - final String masks[] = { "255.255.255.252", "255.255.255.254", "255.255.255.255" }; - final String bcast[] = { "192.168.15.7", "192.168.15.7", "192.168.15.7" }; - final String netwk[] = { "192.168.15.4", "192.168.15.6", "192.168.15.7" }; - final String lowAd[] = { "192.168.15.4", "192.168.15.6", "192.168.15.7" }; - final String highA[] = { "192.168.15.7", "192.168.15.7", "192.168.15.7" }; - final String cidrS[] = { "192.168.15.7/30", "192.168.15.7/31", "192.168.15.7/32" }; - final int usableAd[] = { 4, 2, 1 }; + final String[] masks = { "255.255.255.252", "255.255.255.254", "255.255.255.255" }; + final String[] bcast = { "192.168.15.7", "192.168.15.7", "192.168.15.7" }; + final String[] netwk = { "192.168.15.4", "192.168.15.6", "192.168.15.7" }; + final String[] lowAd = { "192.168.15.4", "192.168.15.6", "192.168.15.7" }; + final String[] highA = { "192.168.15.7", "192.168.15.7", "192.168.15.7" }; + final String[] cidrS = { "192.168.15.7/30", "192.168.15.7/31", "192.168.15.7/32" }; + final int[] usableAd = { 4, 2, 1 }; for (int i = 0; i < masks.length; ++i) { final SubnetUtils utils = new SubnetUtils(address, masks[i]); diff --git a/src/test/java/org/apache/commons/net/telnet/EchoOptionHandlerTest.java b/src/test/java/org/apache/commons/net/telnet/EchoOptionHandlerTest.java index b2cb38617..f547b2712 100644 --- a/src/test/java/org/apache/commons/net/telnet/EchoOptionHandlerTest.java +++ b/src/test/java/org/apache/commons/net/telnet/EchoOptionHandlerTest.java @@ -36,9 +36,9 @@ protected void setUp() { */ @Override public void testAnswerSubnegotiation() { - final int subn[] = { TelnetCommand.IAC, TelnetCommand.SB, TelnetOption.ECHO, 1, TelnetCommand.IAC, TelnetCommand.SE, }; + final int[] subn = { TelnetCommand.IAC, TelnetCommand.SB, TelnetOption.ECHO, 1, TelnetCommand.IAC, TelnetCommand.SE, }; - final int resp1[] = opthand1.answerSubnegotiation(subn, subn.length); + final int[] resp1 = opthand1.answerSubnegotiation(subn, subn.length); assertNull(resp1); } @@ -57,8 +57,8 @@ public void testConstructors() { */ @Override public void testStartSubnegotiation() { - final int resp1[] = opthand1.startSubnegotiationLocal(); - final int resp2[] = opthand1.startSubnegotiationRemote(); + final int[] resp1 = opthand1.startSubnegotiationLocal(); + final int[] resp2 = opthand1.startSubnegotiationRemote(); assertNull(resp1); assertNull(resp2); diff --git a/src/test/java/org/apache/commons/net/telnet/SimpleOptionHandlerTest.java b/src/test/java/org/apache/commons/net/telnet/SimpleOptionHandlerTest.java index e41b23cf1..74d62a96f 100644 --- a/src/test/java/org/apache/commons/net/telnet/SimpleOptionHandlerTest.java +++ b/src/test/java/org/apache/commons/net/telnet/SimpleOptionHandlerTest.java @@ -35,9 +35,9 @@ protected void setUp() { */ @Override public void testAnswerSubnegotiation() { - final int subn[] = { TelnetCommand.IAC, TelnetCommand.SB, 4, 1, TelnetCommand.IAC, TelnetCommand.SE, }; + final int[] subn = { TelnetCommand.IAC, TelnetCommand.SB, 4, 1, TelnetCommand.IAC, TelnetCommand.SE, }; - final int resp1[] = opthand1.answerSubnegotiation(subn, subn.length); + final int[] resp1 = opthand1.answerSubnegotiation(subn, subn.length); assertNull(resp1); } @@ -59,8 +59,8 @@ public void testConstructors() { @Override public void testStartSubnegotiation() { - final int resp1[] = opthand1.startSubnegotiationLocal(); - final int resp2[] = opthand1.startSubnegotiationRemote(); + final int[] resp1 = opthand1.startSubnegotiationLocal(); + final int[] resp2 = opthand1.startSubnegotiationRemote(); assertNull(resp1); assertNull(resp2); diff --git a/src/test/java/org/apache/commons/net/telnet/SuppressGAOptionHandlerTest.java b/src/test/java/org/apache/commons/net/telnet/SuppressGAOptionHandlerTest.java index 6f35a18fd..73c94025b 100644 --- a/src/test/java/org/apache/commons/net/telnet/SuppressGAOptionHandlerTest.java +++ b/src/test/java/org/apache/commons/net/telnet/SuppressGAOptionHandlerTest.java @@ -36,9 +36,9 @@ protected void setUp() { */ @Override public void testAnswerSubnegotiation() { - final int subn[] = { TelnetCommand.IAC, TelnetCommand.SB, TelnetOption.SUPPRESS_GO_AHEAD, 1, TelnetCommand.IAC, TelnetCommand.SE, }; + final int[] subn = { TelnetCommand.IAC, TelnetCommand.SB, TelnetOption.SUPPRESS_GO_AHEAD, 1, TelnetCommand.IAC, TelnetCommand.SE, }; - final int resp1[] = opthand1.answerSubnegotiation(subn, subn.length); + final int[] resp1 = opthand1.answerSubnegotiation(subn, subn.length); assertNull(resp1); } @@ -58,8 +58,8 @@ public void testConstructors() { @Override public void testStartSubnegotiation() { - final int resp1[] = opthand1.startSubnegotiationLocal(); - final int resp2[] = opthand1.startSubnegotiationRemote(); + final int[] resp1 = opthand1.startSubnegotiationLocal(); + final int[] resp2 = opthand1.startSubnegotiationRemote(); assertNull(resp1); assertNull(resp2); diff --git a/src/test/java/org/apache/commons/net/telnet/TelnetClientFunctionalTest.java b/src/test/java/org/apache/commons/net/telnet/TelnetClientFunctionalTest.java index a759391c7..28c006996 100644 --- a/src/test/java/org/apache/commons/net/telnet/TelnetClientFunctionalTest.java +++ b/src/test/java/org/apache/commons/net/telnet/TelnetClientFunctionalTest.java @@ -73,7 +73,7 @@ public void testFunctionalTest() throws Exception { * Helper method. waits for a string with timeout */ public boolean waitForString(final InputStream is, final String end, final long timeout) throws Exception { - final byte buffer[] = new byte[32]; + final byte[] buffer = new byte[32]; final long starttime = System.currentTimeMillis(); String readbytes = ""; diff --git a/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java b/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java index 3f119cd09..a95e21956 100644 --- a/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java +++ b/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java @@ -223,10 +223,10 @@ public void testAYT() throws Exception { boolean ayt_true_ok = false; boolean ayt_false_ok = false; - final byte AYT[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.AYT }; - final byte response[] = { (byte) '[', (byte) 'Y', (byte) 'e', (byte) 's', (byte) ']' }; - final String inputs[] = new String[1]; - final String outputs[] = new String[1]; + final byte[] AYT = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.AYT }; + final byte[] response = { (byte) '[', (byte) 'Y', (byte) 'e', (byte) 's', (byte) ']' }; + final String[] inputs = new String[1]; + final String[] outputs = new String[1]; inputs[0] = new String(AYT); outputs[0] = new String(response); @@ -261,11 +261,11 @@ public void testDeleteOptionHandler() throws Exception { boolean remove_invalid_ok1 = false; boolean remove_invalid_ok2 = false; - final byte buffread[] = new byte[6]; - final byte send[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.ECHO, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, + final byte[] buffread = new byte[6]; + final byte[] send = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.ECHO, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.SUPPRESS_GO_AHEAD, (byte) TelnetCommand.IAC, (byte) TelnetCommand.WILL, (byte) TelnetOption.SUPPRESS_GO_AHEAD }; - final byte expected[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) TelnetOption.SUPPRESS_GO_AHEAD, (byte) TelnetCommand.IAC, + final byte[] expected = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) TelnetOption.SUPPRESS_GO_AHEAD, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DONT, (byte) TelnetOption.SUPPRESS_GO_AHEAD }; final InputStream is = OPTIONS.server.getInputStream(); @@ -316,8 +316,8 @@ public void testInitial() throws Exception { boolean init2_ok = false; boolean add_invalid_ok1 = false; boolean add_invalid_ok2 = false; - final byte buffread2[] = new byte[9]; - final byte expected2[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WILL, (byte) TelnetOption.ECHO, (byte) TelnetCommand.IAC, + final byte[] buffread2 = new byte[9]; + final byte[] expected2 = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WILL, (byte) TelnetOption.ECHO, (byte) TelnetCommand.IAC, (byte) TelnetCommand.WILL, (byte) TelnetOption.SUPPRESS_GO_AHEAD, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.SUPPRESS_GO_AHEAD, }; @@ -375,7 +375,7 @@ public void testInitial() throws Exception { * test of max subnegotiation length */ public void testMaxSubnegotiationLength() throws Exception { - final byte send[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.SB, (byte) 99, (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5, (byte) 6, + final byte[] send = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.SB, (byte) 99, (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5, (byte) 6, (byte) 7, (byte) 8, (byte) 9, (byte) 10, (byte) 11, (byte) 12, (byte) 13, (byte) 14, (byte) 15, (byte) TelnetCommand.IAC, (byte) TelnetCommand.SE, }; @@ -418,15 +418,15 @@ public void testMaxSubnegotiationLength() throws Exception { * test of option negotiation notification */ public void testNotification() throws Exception { - final byte buffread1[] = new byte[6]; - final byte send1[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) 15, (byte) TelnetCommand.IAC, (byte) TelnetCommand.WILL, (byte) 15, }; + final byte[] buffread1 = new byte[6]; + final byte[] send1 = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) 15, (byte) TelnetCommand.IAC, (byte) TelnetCommand.WILL, (byte) 15, }; - final byte buffread2[] = new byte[9]; - final byte send2[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.TERMINAL_TYPE, (byte) TelnetCommand.IAC, + final byte[] buffread2 = new byte[9]; + final byte[] send2 = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.TERMINAL_TYPE, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DONT, (byte) TelnetOption.ECHO, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.SUPPRESS_GO_AHEAD, (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) TelnetOption.SUPPRESS_GO_AHEAD }; - final byte buffread2b[] = new byte[11]; + final byte[] buffread2b = new byte[11]; numdo = 0; numdont = 0; @@ -470,36 +470,36 @@ public void testNotification() throws Exception { */ public void testOptionNegotiation() throws Exception { boolean negotiation1_ok = false; - final byte buffread1[] = new byte[6]; - final byte send1[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) 15, (byte) TelnetCommand.IAC, (byte) TelnetCommand.WILL, (byte) 15, }; - final byte expected1[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) 15, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DONT, + final byte[] buffread1 = new byte[6]; + final byte[] send1 = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) 15, (byte) TelnetCommand.IAC, (byte) TelnetCommand.WILL, (byte) 15, }; + final byte[] expected1 = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) 15, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DONT, (byte) 15, }; boolean negotiation2_ok = false; - final byte buffread2[] = new byte[9]; - final byte send2[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.TERMINAL_TYPE, (byte) TelnetCommand.IAC, + final byte[] buffread2 = new byte[9]; + final byte[] send2 = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.TERMINAL_TYPE, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DONT, (byte) TelnetOption.ECHO, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.SUPPRESS_GO_AHEAD, (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) TelnetOption.SUPPRESS_GO_AHEAD }; - final byte expected2[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WILL, (byte) TelnetOption.TERMINAL_TYPE, (byte) TelnetCommand.IAC, + final byte[] expected2 = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WILL, (byte) TelnetOption.TERMINAL_TYPE, (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) TelnetOption.ECHO, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DONT, (byte) TelnetOption.SUPPRESS_GO_AHEAD }; - final byte buffread2b[] = new byte[11]; - final byte send2b[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.SB, (byte) TelnetOption.TERMINAL_TYPE, (byte) 1, (byte) TelnetCommand.IAC, + final byte[] buffread2b = new byte[11]; + final byte[] send2b = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.SB, (byte) TelnetOption.TERMINAL_TYPE, (byte) 1, (byte) TelnetCommand.IAC, (byte) TelnetCommand.SE, }; - final byte expected2b[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.SB, (byte) TelnetOption.TERMINAL_TYPE, (byte) 0, (byte) 'V', (byte) 'T', + final byte[] expected2b = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.SB, (byte) TelnetOption.TERMINAL_TYPE, (byte) 0, (byte) 'V', (byte) 'T', (byte) '1', (byte) '0', (byte) '0', (byte) TelnetCommand.IAC, (byte) TelnetCommand.SE, }; boolean negotiation3_ok = false; - final byte buffread3[] = new byte[6]; - final byte send3[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.TERMINAL_TYPE, (byte) TelnetCommand.IAC, + final byte[] buffread3 = new byte[6]; + final byte[] send3 = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.TERMINAL_TYPE, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.SUPPRESS_GO_AHEAD }; - final byte expected3[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WILL, (byte) TelnetOption.TERMINAL_TYPE, (byte) TelnetCommand.IAC, + final byte[] expected3 = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WILL, (byte) TelnetOption.TERMINAL_TYPE, (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) TelnetOption.SUPPRESS_GO_AHEAD }; - final byte buffread3b[] = new byte[10]; - final byte send3b[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.SB, (byte) TelnetOption.TERMINAL_TYPE, (byte) 1, (byte) TelnetCommand.IAC, + final byte[] buffread3b = new byte[10]; + final byte[] send3b = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.SB, (byte) TelnetOption.TERMINAL_TYPE, (byte) 1, (byte) TelnetCommand.IAC, (byte) TelnetCommand.SE, }; - final byte expected3b[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.SB, (byte) TelnetOption.TERMINAL_TYPE, (byte) 0, (byte) 'A', (byte) 'N', + final byte[] expected3b = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.SB, (byte) TelnetOption.TERMINAL_TYPE, (byte) 0, (byte) 'A', (byte) 'N', (byte) 'S', (byte) 'I', (byte) TelnetCommand.IAC, (byte) TelnetCommand.SE, }; final InputStream is1 = STANDARD.server.getInputStream(); @@ -594,15 +594,15 @@ public void testOptionNegotiation() throws Exception { public void testOptionRenegotiation() throws Exception { boolean negotiation1_ok = false; - final byte buffread[] = new byte[6]; - final byte send[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.ECHO, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DONT, + final byte[] buffread = new byte[6]; + final byte[] send = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) TelnetOption.ECHO, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DONT, (byte) TelnetOption.SUPPRESS_GO_AHEAD, (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) TelnetOption.SUPPRESS_GO_AHEAD }; - final byte expected[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) TelnetOption.SUPPRESS_GO_AHEAD, (byte) TelnetCommand.IAC, + final byte[] expected = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) TelnetOption.SUPPRESS_GO_AHEAD, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DONT, (byte) TelnetOption.SUPPRESS_GO_AHEAD }; - final byte buffread2[] = new byte[3]; - final byte send2[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DONT, (byte) TelnetOption.ECHO, }; - final byte expected2[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) TelnetOption.ECHO, }; + final byte[] buffread2 = new byte[3]; + final byte[] send2 = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DONT, (byte) TelnetOption.ECHO, }; + final byte[] expected2 = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) TelnetOption.ECHO, }; final InputStream is = OPTIONS.server.getInputStream(); final OutputStream os = OPTIONS.server.getOutputStream(); @@ -643,9 +643,9 @@ public void testSetReaderThread() throws Exception { boolean negotiation1_ok = false; boolean negotiation2_ok = false; boolean read_ok = false; - final byte buffread1[] = new byte[6]; - final byte send1[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) 15, (byte) TelnetCommand.IAC, (byte) TelnetCommand.WILL, (byte) 15, }; - final byte expected1[] = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) 15, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DONT, + final byte[] buffread1 = new byte[6]; + final byte[] send1 = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.DO, (byte) 15, (byte) TelnetCommand.IAC, (byte) TelnetCommand.WILL, (byte) 15, }; + final byte[] expected1 = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.WONT, (byte) 15, (byte) TelnetCommand.IAC, (byte) TelnetCommand.DONT, (byte) 15, }; final InputStream is1 = NOREAD.server.getInputStream(); @@ -718,8 +718,8 @@ public void testSpy() throws Exception { boolean test1spy_ok = false; boolean test2spy_ok = false; boolean stopspy_ok = false; - final byte expected1[] = { (byte) 't', (byte) 'e', (byte) 's', (byte) 't', (byte) '1' }; - final byte expected2[] = { (byte) 't', (byte) 'e', (byte) 's', (byte) 't', (byte) '2' }; + final byte[] expected1 = { (byte) 't', (byte) 'e', (byte) 's', (byte) 't', (byte) '1' }; + final byte[] expected2 = { (byte) 't', (byte) 'e', (byte) 's', (byte) 't', (byte) '2' }; try (final PipedOutputStream po = new PipedOutputStream(); final PipedInputStream pi = new PipedInputStream(po)) { @@ -732,7 +732,7 @@ public void testSpy() throws Exception { os.flush(); Thread.sleep(1000); - final byte buffer[] = new byte[5]; + final byte[] buffer = new byte[5]; if (pi.available() == 5) { pi.read(buffer); diff --git a/src/test/java/org/apache/commons/net/telnet/TelnetTestResponder.java b/src/test/java/org/apache/commons/net/telnet/TelnetTestResponder.java index 5910fb1f0..79f8cb8d3 100644 --- a/src/test/java/org/apache/commons/net/telnet/TelnetTestResponder.java +++ b/src/test/java/org/apache/commons/net/telnet/TelnetTestResponder.java @@ -56,7 +56,7 @@ public TelnetTestResponder(final InputStream is, final OutputStream os, final St @Override public void run() { boolean result = false; - final byte buffer[] = new byte[32]; + final byte[] buffer = new byte[32]; final long starttime = System.currentTimeMillis(); try { diff --git a/src/test/java/org/apache/commons/net/telnet/TerminalTypeOptionHandlerTest.java b/src/test/java/org/apache/commons/net/telnet/TerminalTypeOptionHandlerTest.java index 1a9d3e2a9..e8de47149 100644 --- a/src/test/java/org/apache/commons/net/telnet/TerminalTypeOptionHandlerTest.java +++ b/src/test/java/org/apache/commons/net/telnet/TerminalTypeOptionHandlerTest.java @@ -45,14 +45,14 @@ protected void setUp() { */ @Override public void testAnswerSubnegotiation() { - final int subn[] = { TelnetOption.TERMINAL_TYPE, 1 }; + final int[] subn = { TelnetOption.TERMINAL_TYPE, 1 }; - final int expected1[] = { TelnetOption.TERMINAL_TYPE, 0, 'V', 'T', '1', '0', '0' }; + final int[] expected1 = { TelnetOption.TERMINAL_TYPE, 0, 'V', 'T', '1', '0', '0' }; - final int expected2[] = { TelnetOption.TERMINAL_TYPE, 0, 'A', 'N', 'S', 'I' }; + final int[] expected2 = { TelnetOption.TERMINAL_TYPE, 0, 'A', 'N', 'S', 'I' }; - final int resp1[] = opthand1.answerSubnegotiation(subn, subn.length); - final int resp2[] = opthand2.answerSubnegotiation(subn, subn.length); + final int[] resp1 = opthand1.answerSubnegotiation(subn, subn.length); + final int[] resp2 = opthand2.answerSubnegotiation(subn, subn.length); assertTrue(equalInts(resp1, expected1)); assertTrue(equalInts(resp2, expected2)); @@ -70,8 +70,8 @@ public void testConstructors() { @Override public void testStartSubnegotiation() { - final int resp1[] = opthand1.startSubnegotiationLocal(); - final int resp2[] = opthand1.startSubnegotiationRemote(); + final int[] resp1 = opthand1.startSubnegotiationLocal(); + final int[] resp2 = opthand1.startSubnegotiationRemote(); assertNull(resp1); assertNull(resp2); diff --git a/src/test/java/org/apache/commons/net/telnet/WindowSizeOptionHandlerTest.java b/src/test/java/org/apache/commons/net/telnet/WindowSizeOptionHandlerTest.java index badc1b95b..c94924319 100644 --- a/src/test/java/org/apache/commons/net/telnet/WindowSizeOptionHandlerTest.java +++ b/src/test/java/org/apache/commons/net/telnet/WindowSizeOptionHandlerTest.java @@ -45,11 +45,11 @@ protected void setUp() { */ @Override public void testAnswerSubnegotiation() { - final int subn[] = { TelnetOption.WINDOW_SIZE, 24, 80 }; + final int[] subn = { TelnetOption.WINDOW_SIZE, 24, 80 }; - final int resp1[] = opthand1.answerSubnegotiation(subn, subn.length); - final int resp2[] = opthand2.answerSubnegotiation(subn, subn.length); - final int resp3[] = opthand3.answerSubnegotiation(subn, subn.length); + final int[] resp1 = opthand1.answerSubnegotiation(subn, subn.length); + final int[] resp2 = opthand2.answerSubnegotiation(subn, subn.length); + final int[] resp3 = opthand3.answerSubnegotiation(subn, subn.length); assertNull(resp1); assertNull(resp2); From 80638cd445be0e0aa7d78126756e25c57ebc6593 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Wed, 23 Aug 2023 07:51:58 -0700 Subject: [PATCH 08/45] Use `assertThrows` in test --- .../org/apache/commons/net/SubnetUtilsTest.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/test/java/org/apache/commons/net/SubnetUtilsTest.java b/src/test/java/org/apache/commons/net/SubnetUtilsTest.java index 5decde149..85b0c60d9 100644 --- a/src/test/java/org/apache/commons/net/SubnetUtilsTest.java +++ b/src/test/java/org/apache/commons/net/SubnetUtilsTest.java @@ -24,7 +24,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; import org.apache.commons.net.util.SubnetUtils; import org.apache.commons.net.util.SubnetUtils.SubnetInfo; @@ -275,23 +274,13 @@ public void testNET521() { info = utils.getInfo(); assertEquals("0.0.0.0", info.getNetmask()); assertEquals(4294967296L, info.getAddressCountLong()); - try { - info.getAddressCount(); - fail("Expected RuntimeException"); - } catch (final RuntimeException expected) { - // ignored - } + assertThrows(RuntimeException.class, info::getAddressCount); utils = new SubnetUtils("128.0.0.0/1"); utils.setInclusiveHostCount(true); info = utils.getInfo(); assertEquals("128.0.0.0", info.getNetmask()); assertEquals(2147483648L, info.getAddressCountLong()); - try { - info.getAddressCount(); - fail("Expected RuntimeException"); - } catch (final RuntimeException expected) { - // ignored - } + assertThrows(RuntimeException.class, info::getAddressCount); // if we exclude the broadcast and network addresses, the count is less than Integer.MAX_VALUE utils.setInclusiveHostCount(false); info = utils.getInfo(); From b73016d0a624af51d7c5a947afacb07967b861a1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 02:40:31 +0000 Subject: [PATCH 09/45] Bump actions/checkout from 3.5.3 to 3.6.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/c85c95e3d7251135ab7dc9ce3241c5835cc595a9...f43a0e5ff2bd294095638e18286ca9a3d1956744) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/maven.yml | 2 +- .github/workflows/maven_adhoc.yml | 2 +- .github/workflows/scorecards-analysis.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index cce187db1..954d9eb6b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -45,7 +45,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: persist-credentials: false - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index a55c9beae..56904c6fb 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -29,7 +29,7 @@ jobs: java: [ 8 ] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: persist-credentials: false - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index f88d9eab9..61e4320d0 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -43,7 +43,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: persist-credentials: false - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 diff --git a/.github/workflows/maven_adhoc.yml b/.github/workflows/maven_adhoc.yml index 09eaebb75..596fc8e1a 100644 --- a/.github/workflows/maven_adhoc.yml +++ b/.github/workflows/maven_adhoc.yml @@ -25,7 +25,7 @@ jobs: timeout-minutes: 7 runs-on: windows-latest steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: persist-credentials: false - name: Set up JDK diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index a96099e66..f97d3d3e1 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -40,7 +40,7 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: persist-credentials: false From fa4c5d404060ce1bc834c0a4d62a522bea2c6a4c Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 30 Aug 2023 14:15:47 -0400 Subject: [PATCH 10/45] Bump commons-parent from 59 to 61 --- pom.xml | 2 +- src/changes/changes.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 15a29ba70..4985517fb 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ org.apache.commons commons-parent - 59 + 61 commons-net diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 6787a61da..911d12242 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -147,7 +147,7 @@ The type attribute can be add,update,fix,remove. - Bump commons-parent from 54 to 59 #132, #137, #153. + Bump commons-parent from 54 to 61 #132, #137, #153. Bump commons-io from 2.11.0 to 2.13.0. From 2d335ac901f4fb859f7e97ab79c3e6e5579ce8e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 02:49:24 +0000 Subject: [PATCH 11/45] Bump github/codeql-action from 2.21.4 to 2.21.5 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.4 to 2.21.5. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/a09933a12a80f87b87005513f0abb1494c27a716...00e563ead9f72a8461b24876bee2d0c2e8bd2ee8) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 954d9eb6b..305ed872a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -57,7 +57,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@a09933a12a80f87b87005513f0abb1494c27a716 # v2.21.4 + uses: github/codeql-action/init@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # v2.21.5 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -68,7 +68,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@a09933a12a80f87b87005513f0abb1494c27a716 # v2.21.4 + uses: github/codeql-action/autobuild@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # v2.21.5 # ℹī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -82,4 +82,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@a09933a12a80f87b87005513f0abb1494c27a716 # v2.21.4 + uses: github/codeql-action/analyze@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # v2.21.5 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index f97d3d3e1..47677f3c1 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -64,6 +64,6 @@ jobs: retention-days: 5 - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@a09933a12a80f87b87005513f0abb1494c27a716 # 2.21.4 + uses: github/codeql-action/upload-sarif@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # 2.21.5 with: sarif_file: results.sarif From 1d22800f0c4c85cdef7d794dcfbc99e48d6447b1 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 1 Sep 2023 11:15:07 -0400 Subject: [PATCH 12/45] Update DTD --- checkstyle.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checkstyle.xml b/checkstyle.xml index a34cbfc10..e3c1173bc 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -17,8 +17,8 @@ limitations under the License. --> + "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" + "https://checkstyle.org/dtds/configuration_1_3.dtd"> From ae1d8a78b711ad879dcaad598640d35dd325f27a Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Thu, 7 Sep 2023 09:22:24 -0400 Subject: [PATCH 13/45] Bump commons-parent from 61 to 62 --- pom.xml | 2 +- src/changes/changes.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4985517fb..30deb8ff6 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ org.apache.commons commons-parent - 61 + 62 commons-net diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 911d12242..7259d5a47 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -147,7 +147,7 @@ The type attribute can be add,update,fix,remove. - Bump commons-parent from 54 to 61 #132, #137, #153. + Bump commons-parent from 54 to 62 #132, #137, #153. Bump commons-io from 2.11.0 to 2.13.0. From da45f3e5c38a91f520a0674c5f637fbaf29f470e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Sep 2023 02:47:22 +0000 Subject: [PATCH 14/45] Bump actions/cache from 3.3.1 to 3.3.2 Bumps [actions/cache](https://github.com/actions/cache) from 3.3.1 to 3.3.2. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8...704facf57e6136b1bc63b828d79edcd491f0ee84) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/maven.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 305ed872a..6c3a7c3c4 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -48,7 +48,7 @@ jobs: uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: persist-credentials: false - - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 + - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 56904c6fb..9f9243c05 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -32,7 +32,7 @@ jobs: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: persist-credentials: false - - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 + - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 61e4320d0..5013a3401 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -46,7 +46,7 @@ jobs: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: persist-credentials: false - - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 + - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} From a281c69c500a92fbfe7559c2d1ba33fdbc9ce10f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Sep 2023 02:47:26 +0000 Subject: [PATCH 15/45] Bump actions/upload-artifact from 3.1.2 to 3.1.3 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.1.2 to 3.1.3. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/0b7f8abb1508181956e8e162db84b466c27e18ce...a8a3f3ad30e3422c9c7b888a15615d19a852ae32) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/scorecards-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 47677f3c1..7e06526fa 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -57,7 +57,7 @@ jobs: publish_results: true - name: "Upload artifact" - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # 3.1.0 + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # 3.1.0 with: name: SARIF file path: results.sarif From 2344f5d6bcd2dd76749307e46cd3c43bc61c0fb1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Sep 2023 02:47:30 +0000 Subject: [PATCH 16/45] Bump actions/checkout from 3.6.0 to 4.0.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.6.0 to 4.0.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/f43a0e5ff2bd294095638e18286ca9a3d1956744...3df4ab11eba7bda6032a0b82a6bb43b11571feac) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/maven.yml | 2 +- .github/workflows/maven_adhoc.yml | 2 +- .github/workflows/scorecards-analysis.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 305ed872a..1336bc0c2 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -45,7 +45,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 with: persist-credentials: false - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 56904c6fb..2efde3cf0 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -29,7 +29,7 @@ jobs: java: [ 8 ] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 with: persist-credentials: false - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 61e4320d0..f3ad1ec44 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -43,7 +43,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 with: persist-credentials: false - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 diff --git a/.github/workflows/maven_adhoc.yml b/.github/workflows/maven_adhoc.yml index 596fc8e1a..02071f6d8 100644 --- a/.github/workflows/maven_adhoc.yml +++ b/.github/workflows/maven_adhoc.yml @@ -25,7 +25,7 @@ jobs: timeout-minutes: 7 runs-on: windows-latest steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 with: persist-credentials: false - name: Set up JDK diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 47677f3c1..98d5414bd 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -40,7 +40,7 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 with: persist-credentials: false From b6f858a08e71b06704c89d25b9a26677b43cd887 Mon Sep 17 00:00:00 2001 From: haegar9766 <144672114+haegar9766@users.noreply.github.com> Date: Mon, 11 Sep 2023 14:59:14 +0200 Subject: [PATCH 17/45] Add files via upload RECFM (record format) of an MVS dataset is not a relevant information about a dataset. Therefore it should be ignored "static final String FILE_LIST_REGEX". Further in method "parseFileList(final String entry)" also migrated and archived datasets should be considered --- .../net/ftp/parser/MVSFTPEntryParser.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java index 6bfbc5d82..d916c7e22 100644 --- a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java +++ b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java @@ -60,7 +60,7 @@ public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl { "\\S+\\s+" + // extents -ignored // If the values are too large, the fields may be merged (NET-639) "(?:\\S+\\s+)?" + // used - ignored - "(?:F|FB|V|VB|U)\\s+" + // recfm - F[B], V[B], U + "\\S+\\s+" + // recfm - ignored "\\S+\\s+" + // logical record length -ignored "\\S+\\s+" + // block size - ignored "(PS|PO|PO-E)\\s+" + // Dataset organisation. Many exist @@ -239,18 +239,20 @@ protected FTPClientConfig getDefaultConfiguration() { } /** - * Parse entries representing a dataset list. Only datasets with DSORG PS or PO or PO-E and with RECFM F[B], V[B], U will be parsed. + * Parse entries representing a dataset list. *

- * Format of ZOS/MVS file list: 1 2 3 4 5 6 7 8 9 10 Volume Unit Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname B10142 3390 2006/03/20 2 31 F 80 80 PS - * MDI.OKL.WORK ARCHIVE Not Direct Access Device KJ.IOP998.ERROR.PL.UNITTEST B1N231 3390 2006/03/20 1 15 VB 256 27998 PO PLU B1N231 3390 2006/03/20 1 15 VB - * 256 27998 PO-E PLB + * Format of ZOS/MVS file list: 1 2 3 4 5 6 7 8 9 10 + * Volume Unit Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname + * B10142 3390 2006/03/20 2 31 F 80 80 PS MDI.OKL.WORK + * ARCHIVE Not Direct Access Device KJ.IOP998.ERROR.PL.UNITTEST + * B1N231 3390 2006/03/20 1 15 VB 256 27998 PO PLU + * B1N231 3390 2006/03/20 1 15 VB 256 27998 PO-E PLB + * Migrated HLQ.DATASET.NAME *

* ----------------------------------- Group within Regex [1] Volume [2] Unit [3] Referred [4] Ext: number of extents [5] Used [6] Recfm: Record format [7] * Lrecl: Logical record length [8] BlkSz: Block size [9] Dsorg: Dataset organisation. Many exists but only support: PS, PO, PO-E [10] Dsname: Dataset name *

- * Note: When volume is ARCHIVE, it means the dataset is stored somewhere in a tape archive. These entries are currently not supported by this parser. - * A null value is returned. - * + * * @param entry zosDirectoryEntry * @return null: entry was not parsed. */ @@ -275,6 +277,20 @@ private FTPFile parseFileList(final String entry) { return file; } + if (entry.startsWith("Migrated") || entry.startsWith("ARCHIVE")) { + // Type of file is unknown for migrated datasets + final FTPFile file = new FTPFile(); + file.setRawListing(entry); + file.setType(FTPFile.UNKNOWN_TYPE); + + if (entry.startsWith("Migrated")) + file.setName(entry.split("\\s+")[1]); + else + file.setName(entry.split("\\s+")[5]); + + return file; + } + return null; } From 0d35962b103062521b8c69e2fb83dd34eed3a741 Mon Sep 17 00:00:00 2001 From: haegar9766 <144672114+haegar9766@users.noreply.github.com> Date: Tue, 12 Sep 2023 09:28:16 +0200 Subject: [PATCH 18/45] ARCIVE instead of ARCHIVE is correct --- .../apache/commons/net/ftp/parser/MVSFTPEntryParser.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java index d916c7e22..9df63b614 100644 --- a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java +++ b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java @@ -193,7 +193,7 @@ public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl { * * Other notes =========== * - * The file system supports automatically backup and retrieval of datasets. If a file is backed up, the ftp LIST command will return: ARCHIVE Not Direct + * The file system supports automatically backup and retrieval of datasets. If a file is backed up, the ftp LIST command will return: ARCIVE Not Direct * Access Device KJ.IOP998.ERROR.PL.UNITTEST * * @@ -244,7 +244,7 @@ protected FTPClientConfig getDefaultConfiguration() { * Format of ZOS/MVS file list: 1 2 3 4 5 6 7 8 9 10 * Volume Unit Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname * B10142 3390 2006/03/20 2 31 F 80 80 PS MDI.OKL.WORK - * ARCHIVE Not Direct Access Device KJ.IOP998.ERROR.PL.UNITTEST + * ARCIVE Not Direct Access Device KJ.IOP998.ERROR.PL.UNITTEST * B1N231 3390 2006/03/20 1 15 VB 256 27998 PO PLU * B1N231 3390 2006/03/20 1 15 VB 256 27998 PO-E PLB * Migrated HLQ.DATASET.NAME @@ -277,7 +277,7 @@ private FTPFile parseFileList(final String entry) { return file; } - if (entry.startsWith("Migrated") || entry.startsWith("ARCHIVE")) { + if (entry.startsWith("Migrated") || entry.startsWith("ARCIVE")) { // Type of file is unknown for migrated datasets final FTPFile file = new FTPFile(); file.setRawListing(entry); From b582aa23c59b3e992ab11b3b38813902da939a4e Mon Sep 17 00:00:00 2001 From: haegar9766 <144672114+haegar9766@users.noreply.github.com> Date: Tue, 12 Sep 2023 09:31:44 +0200 Subject: [PATCH 19/45] Add additional ftp return strings Additional ftp return strings for migrated datasets and datasets with recfm containing ASA (e.g. FBA) --- .../net/ftp/parser/MVSFTPEntryParserTest.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java b/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java index 4b361e29e..b46e7d43e 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java @@ -34,14 +34,22 @@ public class MVSFTPEntryParserTest extends AbstractFTPParseTest { "SAVE00 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.RPTBM023.D061704", "SAVE01 3390 2004/06/23 1 1 FB 128 6144 PO INCOMING.RPTBM024.D061704", "SAVE02 3390 2004/06/23 1 1 FB 128 6144 PO-E INCOMING.RPTBM025.D061704", - "PSMLC1 3390 2005/04/04 1 1 VB 27994 27998 PS file3.I", "PSMLB9 3390 2005/04/04 1 1 VB 27994 27998 PS file4.I.BU", - "PSMLB6 3390 2005/04/05 1 1 VB 27994 27998 PS file3.I.BU", "PSMLC6 3390 2005/04/05 1 1 VB 27994 27998 PS file6.I", - "PSMLB7 3390 2005/04/04 1 1 VB 27994 27998 PS file7.O", "PSMLC6 3390 2005/04/05 1 1 VB 27994 27998 PS file7.O.BU", + "PSMLC1 3390 2005/04/04 1 1 VB 27994 27998 PS file3.I", + "PSMLB9 3390 2005/04/04 1 1 VB 27994 27998 PS file4.I.BU", + "PSMLB6 3390 2005/04/05 1 1 VB 27994 27998 PS file3.I.BU", + "PSMLC6 3390 2005/04/05 1 1 VB 27994 27998 PS file6.I", + "PSMLB7 3390 2005/04/04 1 1 VB 27994 27998 PS file7.O", + "PSMLC6 3390 2005/04/05 1 1 VB 27994 27998 PS file7.O.BU", "FPFS49 3390 2004/06/23 1 1 FB 128 6144 PO-E INCOMING.RPTBM026.D061704", "FPFS41 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.RPTBM056.D061704", "FPFS25 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.WTM204.D061704", "PEX26F 3390 2017/07/03 115807 FB 29600 29600 PS INCOMING.FIN.D170630.T160630", - "VVVVVV 3390 2020/04/18 1 60 U 32760 32760 PO NAME" }; + "VVVVVV 3390 2020/04/18 1 60 U 32760 32760 PO NAME", + "TST017 3390 2023/09/08 2 59 FBA 133 32718 PO NAME", + "TST063 3390 2023/09/11 1 1 VBA 133 27930 PS NAME", + "Migrated NAME", + "ARCIVE Not Direct Access Device NAME" + }; private static final String[] goodsamplesMemberList = { /* Note, if the string begins with SAVE, the parsed entry is stored in the List saveftpfiles */ From 4fc77b5f17d1b32d6cfbec04e1bf4b063d2bdb7a Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 12 Sep 2023 07:55:10 -0400 Subject: [PATCH 20/45] Update Javadoc link --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 30deb8ff6..aa7399465 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ Supported protocols include: Echo, Finger, FTP, NNTP, NTP, POP3(S), SMTP(S), Tel 1.8 1.8 - ${commons.javadoc7.java.link} + ${commons.javadoc8.java.link} net org.apache.commons.net NET From c5efbb490d1e6767f7a4c8eb1bbd7cac1c5fb082 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 12 Sep 2023 08:07:20 -0400 Subject: [PATCH 21/45] Fix Jaavdoc warnings --- .../org/apache/commons/net/smtp/SMTP.java | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/src/main/java/org/apache/commons/net/smtp/SMTP.java b/src/main/java/org/apache/commons/net/smtp/SMTP.java index 79660ed34..72c8b23ef 100644 --- a/src/main/java/org/apache/commons/net/smtp/SMTP.java +++ b/src/main/java/org/apache/commons/net/smtp/SMTP.java @@ -120,7 +120,6 @@ protected void _connectAction_() throws IOException { /** * A convenience method to send the SMTP DATA command to the server, receive the reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -135,7 +134,6 @@ public int data() throws IOException { /** * Closes the connection to the SMTP server and sets to null some internal data so that the memory may be reclaimed by the garbage collector. The reply text * and code information from the last command is voided so that the memory it used may be reclaimed. - *

* * @throws IOException If an error occurs while disconnecting. */ @@ -151,7 +149,6 @@ public void disconnect() throws IOException { /** * A convenience method to send the SMTP VRFY command to the server, receive the reply, and return the reply code. - *

* * @param name The name to expand. * @return The reply code received from the server. @@ -176,7 +173,6 @@ protected ProtocolCommandSupport getCommandSupport() { * Fetches a reply from the SMTP server and returns the integer reply code. After calling this method, the actual reply text can be accessed from either * calling {@link #getReplyString getReplyString } or {@link #getReplyStrings getReplyStrings }. Only use this method if you are implementing your own SMTP * client or if you need to fetch a secondary response from the SMTP server. - *

* * @return The integer value of the reply code of the fetched SMTP reply. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -243,7 +239,6 @@ public int getReply() throws IOException { /** * Returns the integer value of the reply code of the last SMTP reply. You will usually only use this method after you connect to the SMTP server to check * that the connection was successful since connect is of type void. - *

* * @return The integer value of the reply code of the last SMTP reply. */ @@ -253,7 +248,6 @@ public int getReplyCode() { /** * Returns the entire text of the last SMTP server response exactly as it was received, including all end of line markers in NETASCII format. - *

* * @return The entire text from the last SMTP response as a String. */ @@ -290,7 +284,6 @@ public String[] getReplyStrings() { /** * A convenience method to send the SMTP HELO command to the server, receive the reply, and return the reply code. - *

* * @param hostname The hostname of the sender. * @return The reply code received from the server. @@ -305,7 +298,6 @@ public int helo(final String hostname) throws IOException { /** * A convenience method to send the SMTP HELP command to the server, receive the reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -319,7 +311,6 @@ public int help() throws IOException { /** * A convenience method to send the SMTP HELP command to the server, receive the reply, and return the reply code. - *

* * @param command The command name on which to request help. * @return The reply code received from the server. @@ -334,7 +325,6 @@ public int help(final String command) throws IOException { /** * A convenience method to send the SMTP MAIL command to the server, receive the reply, and return the reply code. - *

* * @param reversePath The reverse path. * @return The reply code received from the server. @@ -349,7 +339,6 @@ public int mail(final String reversePath) throws IOException { /** * A convenience method to send the SMTP NOOP command to the server, receive the reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -363,7 +352,6 @@ public int noop() throws IOException { /** * A convenience method to send the SMTP QUIT command to the server, receive the reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -377,7 +365,6 @@ public int quit() throws IOException { /** * A convenience method to send the SMTP RCPT command to the server, receive the reply, and return the reply code. - *

* * @param forwardPath The forward path. * @return The reply code received from the server. @@ -404,7 +391,6 @@ public void removeProtocolCommandistener(final org.apache.commons.net.ProtocolCo /** * A convenience method to send the SMTP RSET command to the server, receive the reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -418,7 +404,6 @@ public int rset() throws IOException { /** * A convenience method to send the SMTP SAML command to the server, receive the reply, and return the reply code. - *

* * @param reversePath The reverse path. * @return The reply code received from the server. @@ -433,7 +418,6 @@ public int saml(final String reversePath) throws IOException { /** * A convenience method to send the SMTP SEND command to the server, receive the reply, and return the reply code. - *

* * @param reversePath The reverse path. * @return The reply code received from the server. @@ -449,7 +433,6 @@ public int send(final String reversePath) throws IOException { /** * Sends an SMTP command with no arguments to the server, waits for a reply and returns the numerical response code. After invocation, for more detailed * information, the actual reply text can be accessed by calling {@link #getReplyString getReplyString } or {@link #getReplyStrings getReplyStrings }. - *

* * @param command The SMTPCommand constant corresponding to the SMTP command to send. * @return The integer value of the SMTP reply code returned by the server in response to the command. @@ -465,7 +448,6 @@ public int sendCommand(final int command) throws IOException { /** * Sends an SMTP command to the server, waits for a reply and returns the numerical response code. After invocation, for more detailed information, the * actual reply text can be accessed by calling {@link #getReplyString getReplyString } or {@link #getReplyStrings getReplyStrings }. - *

* * @param command The SMTPCommand constant corresponding to the SMTP command to send. * @param args The arguments to the SMTP command. If this parameter is set to null, then the command is sent with no argument. @@ -494,7 +476,6 @@ private int sendCommand(final int command, final String args, final boolean incl /** * Sends an SMTP command with no arguments to the server, waits for a reply and returns the numerical response code. After invocation, for more detailed * information, the actual reply text can be accessed by calling {@link #getReplyString getReplyString } or {@link #getReplyStrings getReplyStrings }. - *

* * @param command The text representation of the SMTP command to send. * @return The integer value of the SMTP reply code returned by the server in response to the command. @@ -510,7 +491,6 @@ public int sendCommand(final String command) throws IOException { /** * Sends an SMTP command to the server, waits for a reply and returns the numerical response code. After invocation, for more detailed information, the * actual reply text can be accessed by calling {@link #getReplyString getReplyString } or {@link #getReplyStrings getReplyStrings }. - *

* * @param command The text representation of the SMTP command to send. * @param args The arguments to the SMTP command. If this parameter is set to null, then the command is sent with no argument. @@ -557,7 +537,6 @@ private int sendCommand(final String command, final String args, final boolean i /** * A convenience method to send the SMTP SOML command to the server, receive the reply, and return the reply code. - *

* * @param reversePath The reverse path. * @return The reply code received from the server. @@ -572,7 +551,6 @@ public int soml(final String reversePath) throws IOException { /** * A convenience method to send the SMTP TURN command to the server, receive the reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -586,7 +564,6 @@ public int turn() throws IOException { /** * A convenience method to send the SMTP VRFY command to the server, receive the reply, and return the reply code. - *

* * @param user The user address to verify. * @return The reply code received from the server. From b664572a20fd2bb9338a20bf06dcfde3090f0dc1 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 12 Sep 2023 08:10:01 -0400 Subject: [PATCH 22/45] Fix Jaavdoc warnings --- .../apache/commons/net/nntp/NNTPClient.java | 57 +++++++------------ 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/src/main/java/org/apache/commons/net/nntp/NNTPClient.java b/src/main/java/org/apache/commons/net/nntp/NNTPClient.java index a994b93f2..81c52de03 100644 --- a/src/main/java/org/apache/commons/net/nntp/NNTPClient.java +++ b/src/main/java/org/apache/commons/net/nntp/NNTPClient.java @@ -47,11 +47,13 @@ * {@link org.apache.commons.net.nntp.NNTP#disconnect disconnect() } to properly clean up the system resources used by NNTP. Before disconnecting, you may check * the last reply code and text with {@link org.apache.commons.net.nntp.NNTP#getReplyCode getReplyCode } and * {@link org.apache.commons.net.nntp.NNTP#getReplyString getReplyString }. + *

*

* Rather than list it separately for each method, we mention here that every method communicating with the server and throwing an IOException can also throw a * {@link org.apache.commons.net.MalformedServerReplyException} , which is a subclass of IOException. A MalformedServerReplyException will be thrown when the * reply received from the server deviates enough from the protocol specification that it cannot be interpreted in a useful manner despite attempts to be as * lenient as possible. + *

* * @see NNTP * @see NNTPConnectionClosedException @@ -188,7 +190,6 @@ private ArticleInfo ap2ai(@SuppressWarnings("deprecation") final ArticlePointer /** * Log into a news server by sending the AUTHINFO USER/AUTHINFO PASS command sequence. This is usually sent in response to a 480 reply code from the NNTP * server. - *

* * @param username a valid username * @param password the corresponding password @@ -215,7 +216,7 @@ public boolean authenticate(final String username, final String password) throws * method to receive the completion reply from the server and verify the success of the entire transaction. *

* For example - * + *

*
      * writer = client.postArticle();
      * if (writer == null) // failure
@@ -228,7 +229,6 @@ public boolean authenticate(final String username, final String password) throws
      * if (!client.completePendingCommand()) // failure
      *     return false;
      * 
- *

* * @return True if successfully completed, false if not. * @throws NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -250,7 +250,6 @@ public Writer forwardArticle(final String articleId) throws IOException { /** * Return article headers for all articles between lowArticleNumber and highArticleNumber, inclusively, using the XOVER command. - *

* * @param lowArticleNumber low * @param highArticleNumber high @@ -271,7 +270,6 @@ public Iterable

iterateArticleInfo(final long lowArticleNumber, final l * List all new articles added to the NNTP server since a particular date subject to the conditions of the specified query. If no new news is found, * no entries will be returned. This uses the "NEWNEWS" command. You must add at least one newsgroup to the query, else the command will fail. * Each String which is returned is a unique message identifier including the enclosing < and >. - *

* * @param query The query restricting how to search for new news. You must add at least one newsgroup to the query. * @return An iterator of String instances containing the unique message identifiers for each new article added to the NNTP server. If no new news is found, @@ -292,7 +290,6 @@ public Iterable iterateNewNews(final NewGroupsOrNewsQuery query) throws /** * List all new newsgroups added to the NNTP server since a particular date subject to the conditions of the specified query. If no new newsgroups were * added, no entries will be returned. This uses the "NEWGROUPS" command. - *

* * @param query The query restricting how to search for new newsgroups. * @return An iterable of Strings containing the raw information for each new newsgroup added to the NNTP server. If no newsgroups were added, no entries @@ -313,7 +310,6 @@ public Iterable iterateNewNewsgroupListing(final NewGroupsOrNewsQuery qu /** * List all new newsgroups added to the NNTP server since a particular date subject to the conditions of the specified query. If no new newsgroups were * added, no entries will be returned. This uses the "NEWGROUPS" command. - *

* * @param query The query restricting how to search for new newsgroups. * @return An iterable of NewsgroupInfo instances containing the information for each new newsgroup added to the NNTP server. If no newsgroups were added, @@ -330,7 +326,6 @@ public Iterable iterateNewNewsgroups(final NewGroupsOrNewsQuery q /** * List all newsgroups served by the NNTP server. If no newsgroups are served, no entries will be returned. The method uses the "LIST" command. - *

* * @return An iterable of NewsgroupInfo instances containing the information for each newsgroup served by the NNTP server. If no newsgroups are served, no * entries will be returned. @@ -349,7 +344,6 @@ public Iterable iterateNewsgroupListing() throws IOException { /** * List the newsgroups that match a given pattern. Uses the "LIST ACTIVE" command. - *

* * @param wildmat a pseudo-regex pattern (cf. RFC 2980) * @return An iterable of Strings containing the raw information for each newsgroup served by the NNTP server corresponding to the supplied pattern. If no @@ -366,7 +360,6 @@ public Iterable iterateNewsgroupListing(final String wildmat) throws IOE /** * List all newsgroups served by the NNTP server. If no newsgroups are served, no entries will be returned. The method uses the "LIST" command. - *

* * @return An iterable of Strings containing the raw information for each newsgroup served by the NNTP server. If no newsgroups are served, no entries will * be returned. @@ -382,7 +375,6 @@ public Iterable iterateNewsgroups() throws IOException { /** * List the newsgroups that match a given pattern. Uses the "LIST ACTIVE" command. - *

* * @param wildmat a pseudo-regex pattern (cf. RFC 2980) * @return An iterable NewsgroupInfo instances containing the information for each newsgroup served by the NNTP server corresponding to the supplied @@ -396,7 +388,6 @@ public Iterable iterateNewsgroups(final String wildmat) throws IO /** * List the command help from the server. - *

* * @return The sever help information. * @throws NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -419,7 +410,6 @@ public String listHelp() throws IOException { * List all new articles added to the NNTP server since a particular date subject to the conditions of the specified query. If no new news is found, a * zero length array will be returned. If the command fails, null will be returned. You must add at least one newsgroup to the query, else the command will * fail. Each String in the returned array is a unique message identifier including the enclosing < and >. This uses the "NEWNEWS" command. - *

* * @param query The query restricting how to search for new news. You must add at least one newsgroup to the query. * @return An array of String instances containing the unique message identifiers for each new article added to the NNTP server. If no new news is found, a @@ -459,7 +449,6 @@ public String[] listNewNews(final NewGroupsOrNewsQuery query) throws IOException /** * List all new newsgroups added to the NNTP server since a particular date subject to the conditions of the specified query. If no new newsgroups were * added, a zero length array will be returned. If the command fails, null will be returned. This uses the "NEWGROUPS" command. - *

* * @param query The query restricting how to search for new newsgroups. * @return An array of NewsgroupInfo instances containing the information for each new newsgroup added to the NNTP server. If no newsgroups were added, a @@ -482,7 +471,6 @@ public NewsgroupInfo[] listNewNewsgroups(final NewGroupsOrNewsQuery query) throw /** * List all newsgroups served by the NNTP server. If no newsgroups are served, a zero length array will be returned. If the command fails, null will be * returned. The method uses the "LIST" command. - *

* * @return An array of NewsgroupInfo instances containing the information for each newsgroup served by the NNTP server. If no newsgroups are served, a zero * length array will be returned. If the command fails, null will be returned. @@ -503,7 +491,6 @@ public NewsgroupInfo[] listNewsgroups() throws IOException { /** * List the newsgroups that match a given pattern. Uses the "LIST ACTIVE" command. - *

* * @param wildmat a pseudo-regex pattern (cf. RFC 2980) * @return An array of NewsgroupInfo instances containing the information for each newsgroup served by the NNTP server corresponding to the supplied @@ -543,7 +530,6 @@ public String[] listOverviewFmt() throws IOException { /** * Logs out of the news server gracefully by sending the QUIT command. However, you must still disconnect from the server before you can open a new * connection. - *

* * @return True if successfully completed, false if not. * @throws IOException If an I/O error occurs while either sending a command to the server or receiving a reply from the server. @@ -586,15 +572,17 @@ private void parseArticlePointer(final String reply, final ArticleInfo pointer) * The NNTP protocol uses the same stream for issuing commands as it does for returning results. Therefore, the returned Writer actually writes directly to * the NNTP connection. After you close the writer, you can execute new commands. If you do not follow these requirements your program will not work * properly. + *

*

* Different NNTP servers will require different header formats, but you can use the provided {@link org.apache.commons.net.nntp.SimpleNNTPHeader} class to * construct the bare minimum acceptable header for most newsreaders. To construct more complicated headers you should refer to RFC 822. When the Java Mail * API is finalized, you will be able to use it to compose fully compliant Internet text messages. The DotTerminatedMessageWriter takes care of doubling * line-leading dots and ending the message with a single dot upon closing, so all you have to worry about is writing the header and the message. + *

*

* Upon closing the returned Writer, you need to call {@link #completePendingCommand completePendingCommand() } to finalize the posting and verify its * success or failure from the server reply. - *

+ *

* * @return A DotTerminatedMessageWriter to which the article (including header) can be written. Returns null if the command fails. * @throws IOException If an I/O error occurs while either sending a command to the server or receiving a reply from the server. @@ -716,12 +704,13 @@ public BufferedReader retrieveArticle(final long articleNumber) throws IOExcepti * servers do not correctly follow the RFC 977 reply format. *

* A DotTerminatedMessageReader is returned from which the article can be read. If the article does not exist, null is returned. + *

*

* You must not issue any commands to the NNTP server (i.e., call any other methods) until you finish reading the message from the returned BufferedReader * instance. The NNTP protocol uses the same stream for issuing commands as it does for returning results. Therefore, the returned BufferedReader actually * reads directly from the NNTP connection. After the end of message has been reached, new commands can be executed and their replies read. If you do not * follow these requirements, your program will not work properly. - *

+ *

* * @param articleNumber The number of the article to retrieve. * @param pointer A parameter through which to return the article's number and unique id. The articleId field cannot always be trusted because of @@ -754,12 +743,13 @@ public Reader retrieveArticle(final String articleId) throws IOException { * cannot always be trusted because some NNTP servers do not correctly follow the RFC 977 reply format. *

* A DotTerminatedMessageReader is returned from which the article can be read. If the article does not exist, null is returned. + *

*

* You must not issue any commands to the NNTP server (i.e., call any other methods) until you finish reading the message from the returned BufferedReader * instance. The NNTP protocol uses the same stream for issuing commands as it does for returning results. Therefore, the returned BufferedReader actually * reads directly from the NNTP connection. After the end of message has been reached, new commands can be executed and their replies read. If you do not * follow these requirements, your program will not work properly. - *

+ *

* * @param articleId The unique article identifier of the article to retrieve. If this parameter is null, the currently selected article is retrieved. * @param pointer A parameter through which to return the article's number and unique id. The articleId field cannot always be trusted because of server @@ -844,12 +834,13 @@ public BufferedReader retrieveArticleBody(final long articleNumber) throws IOExc * some NNTP servers do not correctly follow the RFC 977 reply format. *

* A DotTerminatedMessageReader is returned from which the article can be read. If the article does not exist, null is returned. + *

*

* You must not issue any commands to the NNTP server (i.e., call any other methods) until you finish reading the message from the returned BufferedReader * instance. The NNTP protocol uses the same stream for issuing commands as it does for returning results. Therefore, the returned BufferedReader actually * reads directly from the NNTP connection. After the end of message has been reached, new commands can be executed and their replies read. If you do not * follow these requirements, your program will not work properly. - *

+ *

* * @param articleNumber The number of the article whose body is being retrieved. * @param pointer A parameter through which to return the article's number and unique id. The articleId field cannot always be trusted because of @@ -882,12 +873,13 @@ public Reader retrieveArticleBody(final String articleId) throws IOException { * cannot always be trusted because some NNTP servers do not correctly follow the RFC 977 reply format. *

* A DotTerminatedMessageReader is returned from which the article can be read. If the article does not exist, null is returned. + *

*

* You must not issue any commands to the NNTP server (i.e., call any other methods) until you finish reading the message from the returned BufferedReader * instance. The NNTP protocol uses the same stream for issuing commands as it does for returning results. Therefore, the returned BufferedReader actually * reads directly from the NNTP connection. After the end of message has been reached, new commands can be executed and their replies read. If you do not * follow these requirements, your program will not work properly. - *

+ *

* * @param articleId The unique article identifier of the article whose body is being retrieved. If this parameter is null, the body of the currently * selected article is retrieved. @@ -973,12 +965,13 @@ public BufferedReader retrieveArticleHeader(final long articleNumber) throws IOE * some NNTP servers do not correctly follow the RFC 977 reply format. *

* A DotTerminatedMessageReader is returned from which the article can be read. If the article does not exist, null is returned. + *

*

* You must not issue any commands to the NNTP server (i.e., call any other methods) until you finish reading the message from the returned BufferedReader * instance. The NNTP protocol uses the same stream for issuing commands as it does for returning results. Therefore, the returned BufferedReader actually * reads directly from the NNTP connection. After the end of message has been reached, new commands can be executed and their replies read. If you do not * follow these requirements, your program will not work properly. - *

+ *

* * @param articleNumber The number of the article whose header is being retrieved. * @param pointer A parameter through which to return the article's number and unique id. The articleId field cannot always be trusted because of @@ -1011,12 +1004,13 @@ public Reader retrieveArticleHeader(final String articleId) throws IOException { * cannot always be trusted because some NNTP servers do not correctly follow the RFC 977 reply format. *

* A DotTerminatedMessageReader is returned from which the article can be read. If the article does not exist, null is returned. + *

*

* You must not issue any commands to the NNTP server (i.e., call any other methods) until you finish reading the message from the returned BufferedReader * instance. The NNTP protocol uses the same stream for issuing commands as it does for returning results. Therefore, the returned BufferedReader actually * reads directly from the NNTP connection. After the end of message has been reached, new commands can be executed and their replies read. If you do not * follow these requirements, your program will not work properly. - *

+ *

* * @param articleId The unique article identifier of the article whose header is being retrieved. If this parameter is null, the header of the currently * selected article is retrieved. @@ -1074,7 +1068,6 @@ public Reader retrieveArticleInfo(final int lowArticleNumber, final int highArti /** * Return article headers for a specified post. - *

* * @param articleNumber the article to retrieve headers for * @return a DotTerminatedReader if successful, null otherwise @@ -1086,7 +1079,6 @@ public BufferedReader retrieveArticleInfo(final long articleNumber) throws IOExc /** * Return article headers for all articles between lowArticleNumber and highArticleNumber, inclusively. Uses the XOVER command. - *

* * @param lowArticleNumber low number * @param highArticleNumber high number @@ -1101,7 +1093,6 @@ public BufferedReader retrieveArticleInfo(final long lowArticleNumber, final lon * Private implementation of XOVER functionality. * * See {@link NNTP#xover} for legal agument formats. Alternatively, read RFC 2980 :-) - *

* * @param articleRange * @return Returns a DotTerminatedMessageReader if successful, null otherwise @@ -1127,9 +1118,6 @@ public Reader retrieveHeader(final String a, final int b) throws IOException { return retrieveHeader(a, (long) b); } - // DEPRECATED METHODS - for API compatibility only - DO NOT USE - // ============================================================ - /** * @param header the header * @param lowArticleNumber to fetch @@ -1172,9 +1160,9 @@ public BufferedReader retrieveHeader(final String header, final long lowArticleN /** * Private implementation of XHDR functionality. - * - * See {@link NNTP#xhdr} for legal argument formats. Alternatively, read RFC 1036. *

+ * See {@link NNTP#xhdr} for legal argument formats. Alternatively, read RFC 1036. + *

* * @param header * @param articleRange @@ -1256,7 +1244,6 @@ public boolean selectArticle(final long articleNumber) throws IOException { * Select an article in the currently selected newsgroup by its number. and return its article number and id through the pointer parameter. This is achieved * through the STAT command. According to RFC 977, this WILL set the current article pointer on the server. Use this command to select an article before * retrieving it, or to obtain an article's unique identifier given its number. - *

* * @param articleNumber The number of the article to select from the currently selected newsgroup. * @param pointer A parameter through which to return the article's number and unique id. Although the articleId field cannot always be trusted @@ -1295,7 +1282,6 @@ public boolean selectArticle(final String articleId) throws IOException { * Select an article by its unique identifier (including enclosing < and >) and return its article number and id through the pointer parameter. This * is achieved through the STAT command. According to RFC 977, this will NOT set the current article pointer on the server. To do that, you must reference * the article by its number. - *

* * @param articleId The unique article identifier of the article that is being selectedd. If this parameter is null, the body of the current article is * selected @@ -1354,7 +1340,6 @@ public boolean selectNewsgroup(final String newsgroup) throws IOException { /** * Select the specified newsgroup to be the target of for future article retrieval and posting operations. Also return the newsgroup information contained * in the server reply through the info parameter. - *

* * @param newsgroup The newsgroup to select. * @param info A parameter through which the newsgroup information of the selected newsgroup contained in the server reply is returned. Set this to @@ -1391,7 +1376,6 @@ public boolean selectNextArticle() throws IOException { * Select the article following the currently selected article in the currently selected newsgroup and return its number and unique id through the pointer * parameter. Because of deviating server implementations, the articleId information cannot be trusted. To obtain the article identifier, issue a * selectArticle(pointer.articleNumber, pointer) immediately afterward. - *

* * @param pointer A parameter through which to return the article's number and unique id. The articleId field cannot always be trusted because of server * deviations from RFC 977 reply formats. You may set this parameter to null if you do not desire to retrieve the returned article @@ -1445,7 +1429,6 @@ public boolean selectPreviousArticle() throws IOException { * Select the article preceding the currently selected article in the currently selected newsgroup and return its number and unique id through the pointer * parameter. Because of deviating server implementations, the articleId information cannot be trusted. To obtain the article identifier, issue a * selectArticle(pointer.articleNumber, pointer) immediately afterward. - *

* * @param pointer A parameter through which to return the article's number and unique id. The articleId field cannot always be trusted because of server * deviations from RFC 977 reply formats. You may set this parameter to null if you do not desire to retrieve the returned article From ae1e7116fc6ff1e691ab2e6b13a4daab57564e5a Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 12 Sep 2023 08:11:15 -0400 Subject: [PATCH 23/45] Fix Jaavdoc warnings --- .../org/apache/commons/net/nntp/NNTP.java | 39 +------------------ 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/src/main/java/org/apache/commons/net/nntp/NNTP.java b/src/main/java/org/apache/commons/net/nntp/NNTP.java index 24a27df77..c6875d69d 100644 --- a/src/main/java/org/apache/commons/net/nntp/NNTP.java +++ b/src/main/java/org/apache/commons/net/nntp/NNTP.java @@ -45,11 +45,13 @@ * {@link org.apache.commons.net.nntp.NNTPConnectionClosedException} , you must disconnect the connection with {@link #disconnect disconnect() } to properly * clean up the system resources used by NNTP. Before disconnecting, you may check the last reply code and text with {@link #getReplyCode getReplyCode } and * {@link #getReplyString getReplyString }. + *

*

* Rather than list it separately for each method, we mention here that every method communicating with the server and throwing an IOException can also throw a * {@link org.apache.commons.net.MalformedServerReplyException} , which is a subclass of IOException. A MalformedServerReplyException will be thrown when the * reply received from the server deviates enough from the protocol specification that it cannot be interpreted in a useful manner despite attempts to be as * lenient as possible. + *

* * @see NNTPClient * @see NNTPConnectionClosedException @@ -115,7 +117,6 @@ protected void _connectAction_() throws IOException { /** * A convenience method to send the NNTP ARTICLE command to the server, receive the initial reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -140,7 +141,6 @@ public int article(final int a) throws IOException { /** * A convenience method to send the NNTP ARTICLE command to the server, receive the initial reply, and return the reply code. - *

* * @param articleNumber The number of the article to request from the currently selected newsgroup. * @return The reply code received from the server. @@ -155,7 +155,6 @@ public int article(final long articleNumber) throws IOException { /** * A convenience method to send the NNTP ARTICLE command to the server, receive the initial reply, and return the reply code. - *

* * @param messageId The message identifier of the requested article, including the encapsulating < and > characters. * @return The reply code received from the server. @@ -171,7 +170,6 @@ public int article(final String messageId) throws IOException { /** * A convenience method to send the AUTHINFO PASS command to the server, receive the reply, and return the reply code. If this step is required, it should * immediately follow the AUTHINFO USER command (See RFC 2980) - *

* * @param password a valid password. * @return The reply code received from the server. The server should return a 281 or 502 for this command. @@ -203,7 +201,6 @@ public int authinfoUser(final String username) throws IOException { /** * A convenience method to send the NNTP BODY command to the server, receive the initial reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -228,7 +225,6 @@ public int body(final int a) throws IOException { /** * A convenience method to send the NNTP BODY command to the server, receive the initial reply, and return the reply code. - *

* * @param articleNumber The number of the article to request from the currently selected newsgroup. * @return The reply code received from the server. @@ -243,7 +239,6 @@ public int body(final long articleNumber) throws IOException { /** * A convenience method to send the NNTP BODY command to the server, receive the initial reply, and return the reply code. - *

* * @param messageId The message identifier of the requested article, including the encapsulating < and > characters. * @return The reply code received from the server. @@ -259,7 +254,6 @@ public int body(final String messageId) throws IOException { /** * Closes the connection to the NNTP server and sets to null some internal data so that the memory may be reclaimed by the garbage collector. The reply text * and code information from the last command is voided so that the memory it used may be reclaimed. - *

* * @throws IOException If an error occurs while disconnecting. */ @@ -284,7 +278,6 @@ protected ProtocolCommandSupport getCommandSupport() { * Fetches a reply from the NNTP server and returns the integer reply code. After calling this method, the actual reply text can be accessed from * {@link #getReplyString getReplyString }. Only use this method if you are implementing your own NNTP client or if you need to fetch a secondary response * from the NNTP server. - *

* * @return The integer value of the reply code of the fetched NNTP reply. in response to the command. * @throws NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -322,7 +315,6 @@ public int getReply() throws IOException { /** * Returns the integer value of the reply code of the last NNTP reply. You will usually only use this method after you connect to the NNTP server to check * that the connection was successful since connect is of type void. - *

* * @return The integer value of the reply code of the last NNTP reply. */ @@ -332,7 +324,6 @@ public int getReplyCode() { /** * Returns the entire text of the last NNTP server response exactly as it was received, not including the end of line marker. - *

* * @return The entire text from the last NNTP response as a String. */ @@ -342,7 +333,6 @@ public String getReplyString() { /** * A convenience method to send the NNTP GROUP command to the server, receive the reply, and return the reply code. - *

* * @param newsgroup The name of the newsgroup to select. * @return The reply code received from the server. @@ -357,7 +347,6 @@ public int group(final String newsgroup) throws IOException { /** * A convenience method to send the NNTP HEAD command to the server, receive the initial reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -382,7 +371,6 @@ public int head(final int a) throws IOException { /** * A convenience method to send the NNTP HEAD command to the server, receive the initial reply, and return the reply code. - *

* * @param articleNumber The number of the article to request from the currently selected newsgroup. * @return The reply code received from the server. @@ -397,7 +385,6 @@ public int head(final long articleNumber) throws IOException { /** * A convenience method to send the NNTP HEAD command to the server, receive the initial reply, and return the reply code. - *

* * @param messageId The message identifier of the requested article, including the encapsulating < and > characters. * @return The reply code received from the server. @@ -412,7 +399,6 @@ public int head(final String messageId) throws IOException { /** * A convenience method to send the NNTP HELP command to the server, receive the reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -426,7 +412,6 @@ public int help() throws IOException { /** * A convenience method to send the NNTP IHAVE command to the server, receive the reply, and return the reply code. - *

* * @param messageId The article identifier, including the encapsulating < and > characters. * @return The reply code received from the server. @@ -441,7 +426,6 @@ public int ihave(final String messageId) throws IOException { /** * Indicates whether or not the client is allowed to post articles to the server it is currently connected to. - *

* * @return True if the client can post articles to the server, false otherwise. */ @@ -451,7 +435,6 @@ public boolean isAllowedToPost() { /** * A convenience method to send the NNTP LAST command to the server, receive the reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -465,7 +448,6 @@ public int last() throws IOException { /** * A convenience method to send the NNTP LIST command to the server, receive the reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -479,7 +461,6 @@ public int list() throws IOException { /** * A convenience wrapper for the extended LIST command that takes an argument, allowing us to selectively list multiple groups. - *

* * @param wildmat A wildmat (pseudo-regex) pattern. See RFC 2980 for details. * @return the reply code received from the server. @@ -493,7 +474,6 @@ public int listActive(final String wildmat) throws IOException { /** * A convenience method to send the "NEWGROUPS" command to the server, receive the reply, and return the reply code. - *

* * @param date The date after which to check for new groups. Date format is YYMMDD * @param time The time after which to check for new groups. Time format is HHMMSS using a 24-hour clock. @@ -528,7 +508,6 @@ public int newgroups(final String date, final String time, final boolean GMT, fi /** * A convenience method to send the "NEWNEWS" command to the server, receive the reply, and return the reply code. - *

* * @param newsgroups A comma-separated list of newsgroups to check for new news. * @param date The date after which to check for new news. Date format is YYMMDD @@ -566,7 +545,6 @@ public int newnews(final String newsgroups, final String date, final String time /** * A convenience method to send the NNTP NEXT command to the server, receive the reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -580,7 +558,6 @@ public int next() throws IOException { /** * A convenience method to send the NNTP POST command to the server, receive the reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -594,7 +571,6 @@ public int post() throws IOException { /** * A convenience method to send the NNTP QUIT command to the server, receive the reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -609,7 +585,6 @@ public int quit() throws IOException { /** * Sends an NNTP command with no arguments to the server, waits for a reply and returns the numerical response code. After invocation, for more detailed * information, the actual reply text can be accessed by calling {@link #getReplyString getReplyString }. - *

* * @param command The NNTPCommand constant corresponding to the NNTP command to send. * @return The integer value of the NNTP reply code returned by the server in response to the command. in response to the command. @@ -625,7 +600,6 @@ public int sendCommand(final int command) throws IOException { /** * Sends an NNTP command to the server, waits for a reply and returns the numerical response code. After invocation, for more detailed information, the * actual reply text can be accessed by calling {@link #getReplyString getReplyString }. - *

* * @param command The NNTPCommand constant corresponding to the NNTP command to send. * @param args The arguments to the NNTP command. If this parameter is set to null, then the command is sent with no argument. @@ -642,7 +616,6 @@ public int sendCommand(final int command, final String args) throws IOException /** * Sends an NNTP command with no arguments to the server, waits for a reply and returns the numerical response code. After invocation, for more detailed * information, the actual reply text can be accessed by calling {@link #getReplyString getReplyString }. - *

* * @param command The text representation of the NNTP command to send. * @return The integer value of the NNTP reply code returned by the server in response to the command. in response to the command. @@ -658,7 +631,6 @@ public int sendCommand(final String command) throws IOException { /** * Sends an NNTP command to the server, waits for a reply and returns the numerical response code. After invocation, for more detailed information, the * actual reply text can be accessed by calling {@link #getReplyString getReplyString }. - *

* * @param command The text representation of the NNTP command to send. * @param args The arguments to the NNTP command. If this parameter is set to null, then the command is sent with no argument. @@ -689,7 +661,6 @@ public int sendCommand(final String command, final String args) throws IOExcepti /** * A convenience method to send the NNTP STAT command to the server, receive the initial reply, and return the reply code. - *

* * @return The reply code received from the server. * @throws NNTPConnectionClosedException If the NNTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -701,8 +672,6 @@ public int stat() throws IOException { return sendCommand(NNTPCommand.STAT); } - // DEPRECATED METHODS - for API compatibility only - DO NOT USE - /** * @param a article number * @return number @@ -716,7 +685,6 @@ public int stat(final int a) throws IOException { /** * A convenience method to send the NNTP STAT command to the server, receive the initial reply, and return the reply code. - *

* * @param articleNumber The number of the article to request from the currently selected newsgroup. * @return The reply code received from the server. @@ -731,7 +699,6 @@ public int stat(final long articleNumber) throws IOException { /** * A convenience method to send the NNTP STAT command to the server, receive the initial reply, and return the reply code. - *

* * @param messageId The message identifier of the requested article, including the encapsulating < and > characters. * @return The reply code received from the server. @@ -746,7 +713,6 @@ public int stat(final String messageId) throws IOException { /** * A convenience method to send the NNTP XHDR command to the server, receive the reply, and return the reply code. - *

* * @param header a String naming a header line (e.g., "subject"). See RFC-1036 for a list of valid header lines. * @param selectedArticles a String representation of the range of article headers required. This may be an article number, or a range of article numbers in @@ -767,7 +733,6 @@ public int xhdr(final String header, final String selectedArticles) throws IOExc /** * A convenience method to send the NNTP XOVER command to the server, receive the reply, and return the reply code. - *

* * @param selectedArticles a String representation of the range of article headers required. This may be an article number, or a range of article numbers in * the form "XXXX-YYYY", where XXXX and YYYY are valid article numbers in the current group. It also may be of the form "XXX-", From 8137d9da29329c2f2a74c892ffc0a8aaaca289d0 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 12 Sep 2023 08:13:47 -0400 Subject: [PATCH 24/45] Fix Jaavdoc warnings --- .../java/org/apache/commons/net/pop3/ExtendedPOP3Client.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/apache/commons/net/pop3/ExtendedPOP3Client.java b/src/main/java/org/apache/commons/net/pop3/ExtendedPOP3Client.java index 94632ee24..6b796a4b3 100644 --- a/src/main/java/org/apache/commons/net/pop3/ExtendedPOP3Client.java +++ b/src/main/java/org/apache/commons/net/pop3/ExtendedPOP3Client.java @@ -70,7 +70,6 @@ public ExtendedPOP3Client() throws NoSuchAlgorithmException { /** * Authenticate to the POP3 server by sending the AUTH command with the selected mechanism, using the given username and the given password. - *

* * @param method the {@link AUTH_METHOD} to use * @param username the username From ce3449b4db452c87ead9a5da02210e314eaba42a Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 12 Sep 2023 08:14:02 -0400 Subject: [PATCH 25/45] Fix Jaavdoc warnings --- .../java/org/apache/commons/net/telnet/EchoOptionHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/apache/commons/net/telnet/EchoOptionHandler.java b/src/main/java/org/apache/commons/net/telnet/EchoOptionHandler.java index 7bd197fce..b17331bc3 100644 --- a/src/main/java/org/apache/commons/net/telnet/EchoOptionHandler.java +++ b/src/main/java/org/apache/commons/net/telnet/EchoOptionHandler.java @@ -31,7 +31,6 @@ public EchoOptionHandler() { /** * Constructor for the EchoOptionHandler. Allows defining desired initial setting for local/remote activation of this option and behavior in case a * local/remote activation request for this option is received. - *

* * @param initlocal - if set to true, a WILL is sent upon connection. * @param initremote - if set to true, a DO is sent upon connection. From 4063b37abba9ea42637d7f1d8b83a90e21310bfb Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 12 Sep 2023 08:14:59 -0400 Subject: [PATCH 26/45] Fix Jaavdoc warnings --- .../net/telnet/TelnetOptionHandler.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java b/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java index bd7de0a38..33da4afa3 100644 --- a/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java +++ b/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java @@ -21,6 +21,7 @@ * The TelnetOptionHandler class is the base class to be used for implementing handlers for telnet options. *

* TelnetOptionHandler implements basic option handling functionality and defines abstract methods that must be implemented to define subnegotiation behavior. + *

*/ public abstract class TelnetOptionHandler { /** @@ -61,7 +62,6 @@ public abstract class TelnetOptionHandler { /** * Constructor for the TelnetOptionHandler. Allows defining desired initial setting for local/remote activation of this option and behavior in case a * local/remote activation request for this option is received. - *

* * @param optcode - Option code. * @param initlocal - if set to true, a {@code WILL} is sent upon connection. @@ -82,7 +82,7 @@ public TelnetOptionHandler(final int optcode, final boolean initlocal, final boo *

* This implementation returns null, and must be overridden by the actual TelnetOptionHandler to specify which response must be sent for the subnegotiation * request. - *

+ *

* * @param suboptionData - the sequence received, without IAC SB & IAC SE * @param suboptionLength - the length of data in suboption_data @@ -95,7 +95,6 @@ public int[] answerSubnegotiation(final int suboptionData[], final int suboption /** * Returns a boolean indicating whether to accept a DO request coming from the other end. - *

* * @return true if a {@code DO} request shall be accepted. */ @@ -105,7 +104,6 @@ public boolean getAcceptLocal() { /** * Returns a boolean indicating whether to accept a WILL request coming from the other end. - *

* * @return true if a {@code WILL} request shall be accepted. */ @@ -115,7 +113,6 @@ public boolean getAcceptRemote() { /** * Returns a boolean indicating whether a {@code DO} request sent to the other side has been acknowledged. - *

* * @return true if a {@code DO} sent to the other side has been acknowledged. */ @@ -125,7 +122,6 @@ boolean getDo() { /** * Returns a boolean indicating whether to send a WILL request to the other end upon connection. - *

* * @return true if a {@code WILL} request shall be sent upon connection. */ @@ -135,7 +131,6 @@ public boolean getInitLocal() { /** * Returns a boolean indicating whether to send a DO request to the other end upon connection. - *

* * @return true if a {@code DO} request shall be sent upon connection. */ @@ -145,7 +140,6 @@ public boolean getInitRemote() { /** * Returns the option code for this option. - *

* * @return Option code. */ @@ -155,7 +149,6 @@ public int getOptionCode() { /** * Returns a boolean indicating whether a {@code WILL} request sent to the other side has been acknowledged. - *

* * @return true if a {@code WILL} sent to the other side has been acknowledged. */ @@ -165,7 +158,6 @@ boolean getWill() { /** * Set behavior of the option for DO requests coming from the other end. - *

* * @param accept - if true, subsequent DO requests will be accepted. */ @@ -175,7 +167,6 @@ public void setAcceptLocal(final boolean accept) { /** * Set behavior of the option for {@code WILL} requests coming from the other end. - *

* * @param accept - if true, subsequent {@code WILL} requests will be accepted. */ @@ -185,7 +176,6 @@ public void setAcceptRemote(final boolean accept) { /** * Tells this option whether a {@code DO} request sent to the other side has been acknowledged (invoked by TelnetClient). - *

* * @param state - if true, a {@code DO} request has been acknowledged. */ @@ -195,7 +185,6 @@ void setDo(final boolean state) { /** * Tells this option whether to send a {@code WILL} request upon connection. - *

* * @param init - if true, a {@code WILL} request will be sent upon subsequent connections. */ @@ -205,7 +194,6 @@ public void setInitLocal(final boolean init) { /** * Tells this option whether to send a {@code DO} request upon connection. - *

* * @param init - if true, a {@code DO} request will be sent upon subsequent connections. */ @@ -215,7 +203,6 @@ public void setInitRemote(final boolean init) { /** * Tells this option whether a {@code WILL} request sent to the other side has been acknowledged (invoked by TelnetClient). - *

* * @param state - if true, a {@code WILL} request has been acknowledged. */ @@ -229,6 +216,7 @@ void setWill(final boolean state) { *

* This implementation returns null, and must be overriden by the actual TelnetOptionHandler to specify which response must be sent for the subnegotiation * request. + *

* * @return subnegotiation sequence to be sent by TelnetClient. TelnetClient will add IAC SB & IAC SE. null means no subnegotiation. */ @@ -242,6 +230,7 @@ public int[] startSubnegotiationLocal() { *

* This implementation returns null, and must be overridden by the actual TelnetOptionHandler to specify which response must be sent for the subnegotiation * request. + *

* * @return subnegotiation sequence to be sent by TelnetClient. TelnetClient will add IAC SB & IAC SE. null means no subnegotiation. */ From f8a6cde1757ddf394bb68aa1daa8804bd95de749 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 12 Sep 2023 08:15:55 -0400 Subject: [PATCH 27/45] Normalize Javadoc --- .../net/telnet/TelnetOptionHandler.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java b/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java index 33da4afa3..b70d8ff80 100644 --- a/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java +++ b/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java @@ -94,7 +94,7 @@ public int[] answerSubnegotiation(final int suboptionData[], final int suboption } /** - * Returns a boolean indicating whether to accept a DO request coming from the other end. + * Gets a boolean indicating whether to accept a DO request coming from the other end. * * @return true if a {@code DO} request shall be accepted. */ @@ -103,7 +103,7 @@ public boolean getAcceptLocal() { } /** - * Returns a boolean indicating whether to accept a WILL request coming from the other end. + * Gets a boolean indicating whether to accept a WILL request coming from the other end. * * @return true if a {@code WILL} request shall be accepted. */ @@ -112,7 +112,7 @@ public boolean getAcceptRemote() { } /** - * Returns a boolean indicating whether a {@code DO} request sent to the other side has been acknowledged. + * Gets a boolean indicating whether a {@code DO} request sent to the other side has been acknowledged. * * @return true if a {@code DO} sent to the other side has been acknowledged. */ @@ -121,7 +121,7 @@ boolean getDo() { } /** - * Returns a boolean indicating whether to send a WILL request to the other end upon connection. + * Gets a boolean indicating whether to send a WILL request to the other end upon connection. * * @return true if a {@code WILL} request shall be sent upon connection. */ @@ -130,7 +130,7 @@ public boolean getInitLocal() { } /** - * Returns a boolean indicating whether to send a DO request to the other end upon connection. + * Gets a boolean indicating whether to send a DO request to the other end upon connection. * * @return true if a {@code DO} request shall be sent upon connection. */ @@ -139,7 +139,7 @@ public boolean getInitRemote() { } /** - * Returns the option code for this option. + * Gets the option code for this option. * * @return Option code. */ @@ -148,7 +148,7 @@ public int getOptionCode() { } /** - * Returns a boolean indicating whether a {@code WILL} request sent to the other side has been acknowledged. + * Gets a boolean indicating whether a {@code WILL} request sent to the other side has been acknowledged. * * @return true if a {@code WILL} sent to the other side has been acknowledged. */ @@ -157,7 +157,7 @@ boolean getWill() { } /** - * Set behavior of the option for DO requests coming from the other end. + * Sets behavior of the option for DO requests coming from the other end. * * @param accept - if true, subsequent DO requests will be accepted. */ @@ -166,7 +166,7 @@ public void setAcceptLocal(final boolean accept) { } /** - * Set behavior of the option for {@code WILL} requests coming from the other end. + * Sets behavior of the option for {@code WILL} requests coming from the other end. * * @param accept - if true, subsequent {@code WILL} requests will be accepted. */ @@ -175,7 +175,7 @@ public void setAcceptRemote(final boolean accept) { } /** - * Tells this option whether a {@code DO} request sent to the other side has been acknowledged (invoked by TelnetClient). + * Sets this option whether a {@code DO} request sent to the other side has been acknowledged (invoked by TelnetClient). * * @param state - if true, a {@code DO} request has been acknowledged. */ @@ -184,7 +184,7 @@ void setDo(final boolean state) { } /** - * Tells this option whether to send a {@code WILL} request upon connection. + * Sets this option whether to send a {@code WILL} request upon connection. * * @param init - if true, a {@code WILL} request will be sent upon subsequent connections. */ @@ -193,7 +193,7 @@ public void setInitLocal(final boolean init) { } /** - * Tells this option whether to send a {@code DO} request upon connection. + * Sets this option whether to send a {@code DO} request upon connection. * * @param init - if true, a {@code DO} request will be sent upon subsequent connections. */ @@ -202,7 +202,7 @@ public void setInitRemote(final boolean init) { } /** - * Tells this option whether a {@code WILL} request sent to the other side has been acknowledged (invoked by TelnetClient). + * Sets this option whether a {@code WILL} request sent to the other side has been acknowledged (invoked by TelnetClient). * * @param state - if true, a {@code WILL} request has been acknowledged. */ From 0c721b992b6a3ad7a9a47a1e43074ec0eadb2abc Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 12 Sep 2023 08:16:42 -0400 Subject: [PATCH 28/45] Fix Jaavdoc warnings Remove junk comment --- .../apache/commons/net/smtp/AuthenticatingSMTPClient.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java b/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java index 9148cc699..81959c782 100644 --- a/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java +++ b/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java @@ -217,7 +217,6 @@ private String convertToHexString(final byte[] a) { /** * A convenience method to send the ESMTP EHLO command to the server, receive the reply, and return the reply code. - *

* * @param hostname The hostname of the sender. * @return The reply code received from the server. @@ -232,7 +231,6 @@ public int ehlo(final String hostname) throws IOException { /** * Login to the ESMTP server by sending the EHLO command with the client hostname as an argument. Before performing any mail commands, you must first login. - *

* * @return True if successfully completed, false if not. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -256,7 +254,6 @@ public boolean elogin() throws IOException { /** * Login to the ESMTP server by sending the EHLO command with the given hostname as an argument. Before performing any mail commands, you must first login. - *

* * @param hostname The hostname with which to greet the SMTP server. * @return True if successfully completed, false if not. @@ -282,5 +279,3 @@ public int[] getEnhancedReplyCode() { return res; } } - -/* kate: indent-width 4; replace-tabs on; */ From 4cfed14f390d7207148c429de95d9bdfecda3b3e Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 12 Sep 2023 08:18:00 -0400 Subject: [PATCH 29/45] Fix Javadoc warnings --- .../apache/commons/net/smtp/SMTPClient.java | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/apache/commons/net/smtp/SMTPClient.java b/src/main/java/org/apache/commons/net/smtp/SMTPClient.java index b1541af30..cb9d4647f 100644 --- a/src/main/java/org/apache/commons/net/smtp/SMTPClient.java +++ b/src/main/java/org/apache/commons/net/smtp/SMTPClient.java @@ -67,6 +67,7 @@ * reply from the SMTP server and false on a reply resulting in an error condition or failure. The methods returning a value other than boolean return a value * containing the higher level data produced by the SMTP command, or null if a reply resulted in an error condition or failure. If you want to access the exact * SMTP reply code causing a success or failure, you must call {@link org.apache.commons.net.smtp.SMTP#getReplyCode getReplyCode } after a success or failure. + *

*

* You should keep in mind that the SMTP server may choose to prematurely close a connection for various reasons. The SMTPClient class will detect a premature * SMTP server connection closing when it receives a {@link org.apache.commons.net.smtp.SMTPReply#SERVICE_NOT_AVAILABLE SMTPReply.SERVICE_NOT_AVAILABLE } @@ -77,11 +78,13 @@ * clean up the system resources used by SMTPClient. Before disconnecting, you may check the last reply code and text with * {@link org.apache.commons.net.smtp.SMTP#getReplyCode getReplyCode }, {@link org.apache.commons.net.smtp.SMTP#getReplyString getReplyString }, and * {@link org.apache.commons.net.smtp.SMTP#getReplyStrings getReplyStrings}. + *

*

* Rather than list it separately for each method, we mention here that every method communicating with the server and throwing an IOException can also throw a * {@link org.apache.commons.net.MalformedServerReplyException} , which is a subclass of IOException. A MalformedServerReplyException will be thrown when the * reply received from the server deviates enough from the protocol specification that it cannot be interpreted in a useful manner despite attempts to be as * lenient as possible. + *

* * @see SMTP * @see SimpleSMTPHeader @@ -111,7 +114,6 @@ public SMTPClient(final String encoding) { /** * Add a recipient for a message using the SMTP RCPT command, specifying a forward relay path. The sender must be set first before any recipients may be * specified, otherwise the mail server will reject your commands. - *

* * @param path The forward relay path pointing to the recipient. * @return True if successfully completed, false if not. @@ -127,7 +129,6 @@ public boolean addRecipient(final RelayPath path) throws IOException { /** * Add a recipient for a message using the SMTP RCPT command, the recipient's email address. The sender must be set first before any recipients may be * specified, otherwise the mail server will reject your commands. - *

* * @param address The recipient's email address. * @return True if successfully completed, false if not. @@ -146,7 +147,7 @@ public boolean addRecipient(final String address) throws IOException { * code completes its actions, it must call this method to receive the completion reply from the server and verify the success of the entire transaction. *

* For example, - * + *

*
      * writer = client.sendMessageData();
      * if (writer == null) // failure
@@ -158,7 +159,6 @@ public boolean addRecipient(final String address) throws IOException {
      * if (!client.completePendingCommand()) // failure
      *     return false;
      * 
- *

* * @return True if successfully completed, false if not. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -172,7 +172,6 @@ public boolean completePendingCommand() throws IOException { /** * Fetches the system help information from the server and returns the full string. - *

* * @return The system help string obtained from the server. null if the information could not be obtained. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -189,7 +188,6 @@ public String listHelp() throws IOException { /** * Fetches the help information for a given command from the server and returns the full string. - *

* * @param command The command on which to ask for help. * @return The command help string obtained from the server. null if the information could not be obtained. @@ -208,7 +206,6 @@ public String listHelp(final String command) throws IOException { /** * Login to the SMTP server by sending the {@code HELO} command with the client hostname as an argument. * Before performing any mail commands, you must first log in. - *

* * @return True if successfully completed, false if not. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -233,7 +230,6 @@ public boolean login() throws IOException { /** * Login to the SMTP server by sending the {@code HELO} command with the given hostname as an argument. * Before performing any mail commands, you must first log in. - *

* * @param hostname The hostname with which to greet the SMTP server. * @return True if successfully completed, false if not. @@ -248,7 +244,6 @@ public boolean login(final String hostname) throws IOException { /** * Logout of the SMTP server by sending the QUIT command. - *

* * @return True if successfully completed, false if not. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -262,7 +257,6 @@ public boolean logout() throws IOException { /** * Aborts the current mail transaction, resetting all server stored sender, recipient, and mail data, cleaning all buffers and tables. - *

* * @return True if successfully completed, false if not. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -282,15 +276,17 @@ public boolean reset() throws IOException { * The SMTP protocol uses the same stream for issuing commands as it does for returning results. Therefore, the returned Writer actually writes directly to * the SMTP connection. After you close the writer, you can execute new commands. If you do not follow these requirements your program will not work * properly. + *

*

* You can use the provided {@link org.apache.commons.net.smtp.SimpleSMTPHeader} class to construct a bare minimum header. To construct more complicated * headers you should refer to RFC 5322. When the Java Mail API is finalized, you will be able to use it to compose fully compliant Internet text messages. * The DotTerminatedMessageWriter takes care of doubling line-leading dots and ending the message with a single dot upon closing, so all you have to worry * about is writing the header and the message. + *

*

* Upon closing the returned Writer, you need to call {@link #completePendingCommand completePendingCommand() } to finalize the transaction and verify its * success or failure from the server reply. - *

+ *

* * @return A DotTerminatedMessageWriter to which the message (including header) can be written. Returns null if the command fails. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -309,7 +305,6 @@ public Writer sendMessageData() throws IOException { /** * Sends a NOOP command to the SMTP server. This is useful for preventing server timeouts. - *

* * @return True if successfully completed, false if not. * @throws SMTPConnectionClosedException If the SMTP server prematurely closes the connection as a result of the client being idle or some other reason @@ -325,7 +320,6 @@ public boolean sendNoOp() throws IOException { * A convenience method for sending short messages. This method fetches the Writer returned by {@link #sendMessageData sendMessageData() } and writes the * specified String to it. After writing the message, this method calls {@link #completePendingCommand completePendingCommand() } to finalize the * transaction and returns its success or failure. - *

* * @param message The short email message to send. This must include the headers and the body, but not the trailing "." * @return True if successfully completed, false if not. @@ -351,7 +345,6 @@ public boolean sendShortMessageData(final String message) throws IOException { * A convenience method for a sending short email without having to explicitly set the sender and recipient(s). This method sets the sender and recipient * using {@link #setSender setSender } and {@link #addRecipient addRecipient }, and then sends the message using {@link #sendShortMessageData * sendShortMessageData }. - *

* * @param sender The email address of the sender. * @param recipient The email address of the recipient. @@ -381,7 +374,7 @@ public boolean sendSimpleMessage(final String sender, final String recipient, fi *

* Note that the method ignores failures when calling {@link #addRecipient(String) addRecipient} so long as at least one call succeeds. If no recipients can * be successfully added then the method will fail (and does not attempt to send the message) - *

+ *

* * @param sender The email address of the sender. * @param recipients An array of recipient email addresses. @@ -416,7 +409,6 @@ public boolean sendSimpleMessage(final String sender, final String[] recipients, /** * Set the sender of a message using the SMTP MAIL command, specifying a reverse relay path. The sender must be set first before any recipients may be * specified, otherwise the mail server will reject your commands. - *

* * @param path The reverse relay path pointing back to the sender. * @return True if successfully completed, false if not. @@ -432,7 +424,6 @@ public boolean setSender(final RelayPath path) throws IOException { /** * Set the sender of a message using the SMTP MAIL command, specifying the sender's email address. The sender must be set first before any recipients may be * specified, otherwise the mail server will reject your commands. - *

* * @param address The sender's email address. * @return True if successfully completed, false if not. @@ -447,7 +438,6 @@ public boolean setSender(final String address) throws IOException { /** * Verify that a username or email address is valid, i.e., that mail can be delivered to that mailbox on the server. - *

* * @param username The username or email address to validate. * @return True if the username is valid, false if not. From 8c15d2d60b251d82f68337ebea405990d44d508a Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 12 Sep 2023 08:18:58 -0400 Subject: [PATCH 30/45] Fix Javadoc warnings --- .../java/org/apache/commons/net/telnet/TelnetOptionHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java b/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java index b70d8ff80..3648847ee 100644 --- a/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java +++ b/src/main/java/org/apache/commons/net/telnet/TelnetOptionHandler.java @@ -86,7 +86,6 @@ public TelnetOptionHandler(final int optcode, final boolean initlocal, final boo * * @param suboptionData - the sequence received, without IAC SB & IAC SE * @param suboptionLength - the length of data in suboption_data - *

* @return response to be sent to the subnegotiation sequence. TelnetClient will add IAC SB & IAC SE. null means no response */ public int[] answerSubnegotiation(final int suboptionData[], final int suboptionLength) { From 10932e92a88dd8f5a6f55edcea6c921b774da373 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 12 Sep 2023 08:19:21 -0400 Subject: [PATCH 31/45] Fix Javadoc warnings --- src/main/java/org/apache/commons/net/smtp/SMTP.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/apache/commons/net/smtp/SMTP.java b/src/main/java/org/apache/commons/net/smtp/SMTP.java index 72c8b23ef..a242c7361 100644 --- a/src/main/java/org/apache/commons/net/smtp/SMTP.java +++ b/src/main/java/org/apache/commons/net/smtp/SMTP.java @@ -274,7 +274,6 @@ public String getReplyString() { /** * Returns the lines of text from the last SMTP server response as an array of strings, one entry per line. The end of line markers of each are stripped * from each line. - *

* * @return The lines of text from the last SMTP response as an array. */ From 484516410e98dec9e8417052ae9258446e7f64fa Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 12 Sep 2023 08:19:44 -0400 Subject: [PATCH 32/45] Fix Javadoc warnings --- src/main/java/org/apache/commons/net/nntp/NNTPClient.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/org/apache/commons/net/nntp/NNTPClient.java b/src/main/java/org/apache/commons/net/nntp/NNTPClient.java index 81c52de03..593636690 100644 --- a/src/main/java/org/apache/commons/net/nntp/NNTPClient.java +++ b/src/main/java/org/apache/commons/net/nntp/NNTPClient.java @@ -1133,7 +1133,6 @@ public Reader retrieveHeader(final String header, final int lowArticleNumber, fi /** * Return an article header for a specified post. - *

* * @param header the header to retrieve * @param articleNumber the article to retrieve the header for @@ -1146,7 +1145,6 @@ public BufferedReader retrieveHeader(final String header, final long articleNumb /** * Return an article header for all articles between lowArticleNumber and highArticleNumber, inclusively. - *

* * @param header the header * @param lowArticleNumber to fetch From e62a020f217c0b7d4b3f68ec2d6d2bca32de6428 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 12 Sep 2023 08:21:23 -0400 Subject: [PATCH 33/45] Fix Javadoc warnings --- src/main/java/org/apache/commons/net/nntp/NNTP.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/apache/commons/net/nntp/NNTP.java b/src/main/java/org/apache/commons/net/nntp/NNTP.java index c6875d69d..6e6402b4f 100644 --- a/src/main/java/org/apache/commons/net/nntp/NNTP.java +++ b/src/main/java/org/apache/commons/net/nntp/NNTP.java @@ -185,7 +185,6 @@ public int authinfoPass(final String password) throws IOException { /** * A convenience method to send the AUTHINFO USER command to the server, receive the reply, and return the reply code. (See RFC 2980) - *

* * @param username A valid username. * @return The reply code received from the server. The server should return a 381 or 281 for this command. From d8358120953d83b0e70c4e7a2add52fd068abfdb Mon Sep 17 00:00:00 2001 From: haegar9766 <144672114+haegar9766@users.noreply.github.com> Date: Wed, 13 Sep 2023 05:16:24 +0000 Subject: [PATCH 34/45] Fix coding errors (e.g. missing "{}" after if) --- .../apache/commons/net/ftp/parser/MVSFTPEntryParser.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java index 9df63b614..c3d2aac4e 100644 --- a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java +++ b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java @@ -252,7 +252,7 @@ protected FTPClientConfig getDefaultConfiguration() { * ----------------------------------- Group within Regex [1] Volume [2] Unit [3] Referred [4] Ext: number of extents [5] Used [6] Recfm: Record format [7] * Lrecl: Logical record length [8] BlkSz: Block size [9] Dsorg: Dataset organisation. Many exists but only support: PS, PO, PO-E [10] Dsname: Dataset name *

- * + * * @param entry zosDirectoryEntry * @return null: entry was not parsed. */ @@ -277,8 +277,8 @@ private FTPFile parseFileList(final String entry) { return file; } - if (entry.startsWith("Migrated") || entry.startsWith("ARCIVE")) { - // Type of file is unknown for migrated datasets + if (entry.startsWith("Migrated") || entry.startsWith("ARCIVE")) { + // Type of file is unknown for migrated datasets final FTPFile file = new FTPFile(); file.setRawListing(entry); file.setType(FTPFile.UNKNOWN_TYPE); From c4003ffa8b68e4f42ed8fc592a07b38aed100dd7 Mon Sep 17 00:00:00 2001 From: haegar9766 <144672114+haegar9766@users.noreply.github.com> Date: Wed, 13 Sep 2023 05:19:54 +0000 Subject: [PATCH 35/45] Fix coding errors (e.g. missing "{}" after if) --- .../commons/net/ftp/parser/MVSFTPEntryParser.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java index c3d2aac4e..bc46a338f 100644 --- a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java +++ b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java @@ -278,18 +278,18 @@ private FTPFile parseFileList(final String entry) { } if (entry.startsWith("Migrated") || entry.startsWith("ARCIVE")) { - // Type of file is unknown for migrated datasets + // Type of file is unknown for migrated datasets final FTPFile file = new FTPFile(); file.setRawListing(entry); file.setType(FTPFile.UNKNOWN_TYPE); - - if (entry.startsWith("Migrated")) - file.setName(entry.split("\\s+")[1]); - else - file.setName(entry.split("\\s+")[5]); + if (entry.startsWith("Migrated")) { + file.setName(entry.split("\\s+")[1]); + } else { + file.setName(entry.split("\\s+")[5]); + } return file; - } + } return null; } From f8e3850540fa43a14564cc6208c1bf1ff49e69a3 Mon Sep 17 00:00:00 2001 From: haegar9766 <144672114+haegar9766@users.noreply.github.com> Date: Wed, 13 Sep 2023 05:32:00 +0000 Subject: [PATCH 36/45] fix code indentation --- .../org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java index bc46a338f..1e26bd3fa 100644 --- a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java +++ b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java @@ -288,8 +288,9 @@ private FTPFile parseFileList(final String entry) { } else { file.setName(entry.split("\\s+")[5]); } + return file; - } + } return null; } From 213496234ea0c96f0caeef587022fd497427f68d Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 13 Sep 2023 09:30:34 -0400 Subject: [PATCH 37/45] Change Class "org.apache.commons.net.ftp.parser.MVSFTPEntryParser" to support more datasets #182 - Javadoc - Simplify - Don't scan entry twice --- src/changes/changes.xml | 3 ++ .../net/ftp/parser/MVSFTPEntryParser.java | 33 +++++++------------ 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 7259d5a47..af119f7ee 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -145,6 +145,9 @@ The type attribute can be add,update,fix,remove. Javadoc for FtpClient.setControlKeepAliveReplyTimeout(Duration) says timeout is in milliseconds. + + Change class org.apache.commons.net.ftp.parser.MVSFTPEntryParser to support more datasets #182. + Bump commons-parent from 54 to 62 #132, #137, #153. diff --git a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java index 1e26bd3fa..2af22bec6 100644 --- a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java +++ b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java @@ -213,17 +213,10 @@ public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl { * scheduler DB2 is used to interact with a DB2 subsystem * * This parser supports SEQ and JES. - * - * - * - * - * - * */ /** * The sole constructor for a MVSFTPEntryParser object. - * */ public MVSFTPEntryParser() { super(""); // note the regex is set in preParse. @@ -239,8 +232,8 @@ protected FTPClientConfig getDefaultConfiguration() { } /** - * Parse entries representing a dataset list. - *

+ * Parses entries representing a dataset list. + *

      * Format of ZOS/MVS file list: 1 2 3 4 5 6 7 8 9 10
      * Volume Unit Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname
      * B10142 3390 2006/03/20 2 31 F 80 80 PS MDI.OKL.WORK
@@ -248,10 +241,11 @@ protected FTPClientConfig getDefaultConfiguration() {
      * B1N231 3390 2006/03/20 1 15 VB 256 27998 PO PLU
      * B1N231 3390 2006/03/20 1 15 VB 256 27998 PO-E PLB
      * Migrated                                                HLQ.DATASET.NAME
-     * 

+ *

+ *
      * ----------------------------------- Group within Regex [1] Volume [2] Unit [3] Referred [4] Ext: number of extents [5] Used [6] Recfm: Record format [7]
      * Lrecl: Logical record length [8] BlkSz: Block size [9] Dsorg: Dataset organisation. Many exists but only support: PS, PO, PO-E [10] Dsname: Dataset name
-     * 

+ *

* * @param entry zosDirectoryEntry * @return null: entry was not parsed. @@ -277,18 +271,13 @@ private FTPFile parseFileList(final String entry) { return file; } - if (entry.startsWith("Migrated") || entry.startsWith("ARCIVE")) { + final boolean migrated = entry.startsWith("Migrated"); + if (migrated || entry.startsWith("ARCIVE")) { // Type of file is unknown for migrated datasets final FTPFile file = new FTPFile(); file.setRawListing(entry); file.setType(FTPFile.UNKNOWN_TYPE); - - if (entry.startsWith("Migrated")) { - file.setName(entry.split("\\s+")[1]); - } else { - file.setName(entry.split("\\s+")[5]); - } - + file.setName(entry.split("\\s+")[migrated ? 1 : 5]); return file; } @@ -397,7 +386,7 @@ private FTPFile parseJeslevel2List(final String entry) { } /** - * Parse entries within a partitioned dataset. + * Parses entries within a partitioned dataset. * * Format of a memberlist within a PDS: * @@ -454,7 +443,7 @@ private FTPFile parseMemberList(final String entry) { } /** - * preParse is called as part of the interface. Per definition, it is called before the parsing takes place. Three kinds of lists are recognized: + * Pre-parses is called as part of the interface. Per definition, it is called before the parsing takes place. Three kinds of lists are recognized: *
    *
  • z/OS-MVS File lists,
  • *
  • z/OS-MVS Member lists,
  • @@ -497,7 +486,7 @@ public List preParse(final List orig) { } /** - * Explicitly set the type of listing being processed. + * Sets the type of listing being processed. * * @param type The listing type. */ From 9e2dee88f65fcddbf04f6eb194c66a22c7bba77e Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 13 Sep 2023 09:33:11 -0400 Subject: [PATCH 38/45] Refactor commons private code --- .../net/ftp/parser/MVSFTPEntryParser.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java index 2af22bec6..13601e595 100644 --- a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java +++ b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java @@ -333,18 +333,7 @@ public FTPFile parseFTPEntry(final String entry) { * @return null: entry was not parsed. */ private FTPFile parseJeslevel1List(final String entry) { - if (matches(entry)) { - final FTPFile file = new FTPFile(); - if (group(3).equalsIgnoreCase("OUTPUT")) { - file.setRawListing(entry); - final String name = group(2); /* Job Number, used by GET */ - file.setName(name); - file.setType(FTPFile.FILE_TYPE); - return file; - } - } - - return null; + return parseJeslevelList(entry, 3); } /** @@ -371,9 +360,13 @@ private FTPFile parseJeslevel1List(final String entry) { * @return null: entry was not parsed. */ private FTPFile parseJeslevel2List(final String entry) { + return parseJeslevelList(entry, 4); + } + + private FTPFile parseJeslevelList(final String entry, final int matchNum) { if (matches(entry)) { final FTPFile file = new FTPFile(); - if (group(4).equalsIgnoreCase("OUTPUT")) { + if (group(matchNum).equalsIgnoreCase("OUTPUT")) { file.setRawListing(entry); final String name = group(2); /* Job Number, used by GET */ file.setName(name); @@ -381,7 +374,6 @@ private FTPFile parseJeslevel2List(final String entry) { return file; } } - return null; } From fbb4bcaed58326f232cddca53a4b34580afa211a Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 13 Sep 2023 09:33:31 -0400 Subject: [PATCH 39/45] Better param name --- .../commons/net/ftp/parser/RegexFTPFileEntryParserImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/net/ftp/parser/RegexFTPFileEntryParserImpl.java b/src/main/java/org/apache/commons/net/ftp/parser/RegexFTPFileEntryParserImpl.java index b39b12d31..93b6803a7 100644 --- a/src/main/java/org/apache/commons/net/ftp/parser/RegexFTPFileEntryParserImpl.java +++ b/src/main/java/org/apache/commons/net/ftp/parser/RegexFTPFileEntryParserImpl.java @@ -122,15 +122,15 @@ public String getGroupsAsString() { /** * Convenience method delegates to the internal MatchResult's group() method. * - * @param matchnum match group number to be retrieved + * @param matchNum match group number to be retrieved * * @return the content of the matchnum'th group of the internal match or null if this method is called without a match having been made. */ - public String group(final int matchnum) { + public String group(final int matchNum) { if (this.result == null) { return null; } - return this.result.group(matchnum); + return this.result.group(matchNum); } /** From 67fcb7d1ba45550feb8fa1bb6b8307cdcc9e2cba Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 13 Sep 2023 09:35:54 -0400 Subject: [PATCH 40/45] Remove noisy parens --- src/test/java/org/apache/commons/net/tftp/TFTPServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/apache/commons/net/tftp/TFTPServer.java b/src/test/java/org/apache/commons/net/tftp/TFTPServer.java index 6aefe01f7..c6fc2efec 100644 --- a/src/test/java/org/apache/commons/net/tftp/TFTPServer.java +++ b/src/test/java/org/apache/commons/net/tftp/TFTPServer.java @@ -523,7 +523,7 @@ public TFTPServer(final File serverReadDirectory, final File serverWriteDirector InetAddress inetAddress = null; if (localiface != null) { final Enumeration ifaddrs = localiface.getInetAddresses(); - if ((ifaddrs != null) && ifaddrs.hasMoreElements()) { + if (ifaddrs != null && ifaddrs.hasMoreElements()) { inetAddress = ifaddrs.nextElement(); } } From 529d45b1f0c5fc7e21fbd2c8db851288bbd5d61f Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 13 Sep 2023 09:43:06 -0400 Subject: [PATCH 41/45] Remove noisy parens and trailing whitespace --- .../net/examples/mail/IMAPExportMbox.java | 2 +- .../net/examples/mail/IMAPImportMbox.java | 2 +- .../org/apache/commons/net/ftp/FTPClient.java | 14 +++++++------- .../apache/commons/net/ftp/FTPHTTPClient.java | 2 +- .../org/apache/commons/net/ftp/FTPSClient.java | 6 +++--- .../net/ftp/parser/FTPTimestampParserImpl.java | 2 +- .../ftp/parser/MacOsPeterFTPEntryParser.java | 4 ++-- .../net/ftp/parser/OS400FTPEntryParser.java | 2 +- .../parser/VMSVersioningFTPEntryParser.java | 4 ++-- .../org/apache/commons/net/nntp/Article.java | 8 ++++---- .../apache/commons/net/nntp/NNTPClient.java | 2 +- .../org/apache/commons/net/nntp/Threader.java | 18 +++++++++--------- .../org/apache/commons/net/ntp/NtpUtils.java | 6 +++--- .../org/apache/commons/net/telnet/Telnet.java | 4 ++-- .../net/telnet/TerminalTypeOptionHandler.java | 4 ++-- .../commons/net/tftp/TFTPDataPacket.java | 2 +- .../net/ftp/parser/MVSFTPEntryParserTest.java | 2 +- .../net/telnet/TelnetClientFunctionalTest.java | 6 +++--- .../commons/net/tftp/TFTPServerPathTest.java | 4 ++-- 19 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/main/java/org/apache/commons/net/examples/mail/IMAPExportMbox.java b/src/main/java/org/apache/commons/net/examples/mail/IMAPExportMbox.java index 562baeb45..ae0599e34 100644 --- a/src/main/java/org/apache/commons/net/examples/mail/IMAPExportMbox.java +++ b/src/main/java/org/apache/commons/net/examples/mail/IMAPExportMbox.java @@ -377,7 +377,7 @@ public void protocolReplyReceived(final ProtocolCommandEvent event) { while (true) { final boolean ok = imap.fetch(sequenceSet, itemNames); // If the fetch failed, can we retry? - if (ok || (retryWaitSecs <= 0) || (mboxListener == null) || !checkSequence) { + if (ok || retryWaitSecs <= 0 || mboxListener == null || !checkSequence) { break; } final String replyString = imap.getReplyString(); // includes EOL diff --git a/src/main/java/org/apache/commons/net/examples/mail/IMAPImportMbox.java b/src/main/java/org/apache/commons/net/examples/mail/IMAPImportMbox.java index 875e483be..3c12ee0cb 100644 --- a/src/main/java/org/apache/commons/net/examples/mail/IMAPImportMbox.java +++ b/src/main/java/org/apache/commons/net/examples/mail/IMAPImportMbox.java @@ -201,7 +201,7 @@ private static boolean startsWith(final String input, final Pattern pat) { * @return true if the message is wanted */ private static boolean wanted(final int msgNum, final String line, final BitSet msgNums, final List contains) { - return (msgNums.isEmpty() && contains.isEmpty()) // no selectors + return msgNums.isEmpty() && contains.isEmpty() // no selectors || msgNums.get(msgNum) // matches message number || listContains(contains, line); // contains string } diff --git a/src/main/java/org/apache/commons/net/ftp/FTPClient.java b/src/main/java/org/apache/commons/net/ftp/FTPClient.java index c169f808f..4a743ddfa 100644 --- a/src/main/java/org/apache/commons/net/ftp/FTPClient.java +++ b/src/main/java/org/apache/commons/net/ftp/FTPClient.java @@ -697,7 +697,7 @@ protected Socket _openDataConnection_(final String command, final String arg) th return null; } - if ((restartOffset > 0) && !restart(restartOffset)) { + if (restartOffset > 0 && !restart(restartOffset)) { return null; } @@ -768,7 +768,7 @@ protected Socket _openDataConnection_(final String command, final String arg) th } socket.connect(new InetSocketAddress(passiveHost, passivePort), connectTimeout); - if ((restartOffset > 0) && !restart(restartOffset)) { + if (restartOffset > 0 && !restart(restartOffset)) { socket.close(); return null; } @@ -800,7 +800,7 @@ protected void _parseExtendedPassiveModeReply(String reply) throws MalformedServ final char delim3 = reply.charAt(2); final char delim4 = reply.charAt(reply.length() - 1); - if ((delim1 != delim2) || (delim2 != delim3) || (delim3 != delim4)) { + if (delim1 != delim2 || delim2 != delim3 || delim3 != delim4) { throw new MalformedServerReplyException("Could not parse extended passive host information.\nServer Reply: " + reply); } @@ -834,7 +834,7 @@ protected void _parsePassiveModeReply(final String reply) throws MalformedServer try { final int oct1 = Integer.parseInt(m.group(2)); final int oct2 = Integer.parseInt(m.group(3)); - pasvPort = (oct1 << 8) | oct2; + pasvPort = oct1 << 8 | oct2; } catch (final NumberFormatException e) { throw new MalformedServerReplyException("Could not parse passive port information.\nServer Reply: " + reply); } @@ -1211,7 +1211,7 @@ void createParser(final String parserKey) throws IOException { // We cache the value to avoid creation of a new object every // time a file listing is generated. // Note: we don't check against a null parserKey (NET-544) - if (entryParser == null || (parserKey != null && !entryParserKey.equals(parserKey))) { + if (entryParser == null || parserKey != null && !entryParserKey.equals(parserKey)) { if (null != parserKey) { // if a parser key was supplied in the parameters, // use that to create the parser @@ -2646,7 +2646,7 @@ public String printWorkingDirectory() throws IOException { public boolean reinitialize() throws IOException { rein(); - if (FTPReply.isPositiveCompletion(_replyCode) || (FTPReply.isPositivePreliminary(_replyCode) && FTPReply.isPositiveCompletion(getReply()))) { + if (FTPReply.isPositiveCompletion(_replyCode) || FTPReply.isPositivePreliminary(_replyCode) && FTPReply.isPositiveCompletion(getReply())) { initDefaults(); @@ -3137,7 +3137,7 @@ public void setListHiddenFiles(final boolean listHiddenFiles) { * @see http://tools.ietf.org/html/draft-somers-ftp-mfxx-04 */ public boolean setModificationTime(final String pathname, final String timeval) throws IOException { - return (FTPReply.isPositiveCompletion(mfmt(pathname, timeval))); + return FTPReply.isPositiveCompletion(mfmt(pathname, timeval)); } /** diff --git a/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java b/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java index f9703fdd9..c1da541c4 100644 --- a/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java +++ b/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java @@ -214,7 +214,7 @@ private BufferedReader tunnelHandshake(final String host, final int port, final String code; final String resp = response.get(0); - if (!resp.startsWith("HTTP/") || (resp.length() < 12)) { + if (!resp.startsWith("HTTP/") || resp.length() < 12) { throw new IOException("Invalid response from proxy: " + resp); } code = resp.substring(9, 12); diff --git a/src/main/java/org/apache/commons/net/ftp/FTPSClient.java b/src/main/java/org/apache/commons/net/ftp/FTPSClient.java index b2fc0ab43..a0c92ba3b 100644 --- a/src/main/java/org/apache/commons/net/ftp/FTPSClient.java +++ b/src/main/java/org/apache/commons/net/ftp/FTPSClient.java @@ -714,7 +714,7 @@ private Socket openDataSecureConnection(final String command, final String arg) return null; } - if ((getRestartOffset() > 0) && !restart(getRestartOffset())) { + if (getRestartOffset() > 0 && !restart(getRestartOffset())) { return null; } @@ -795,7 +795,7 @@ private Socket openDataSecureConnection(final String command, final String arg) sslSocket = context.getSocketFactory().createSocket(socket, getPassiveHost(), getPassivePort(), true); } - if ((getRestartOffset() > 0) && !restart(getRestartOffset())) { + if (getRestartOffset() > 0 && !restart(getRestartOffset())) { closeSockets(socket, sslSocket); return null; } @@ -1025,7 +1025,7 @@ protected void sslNegotiation() throws IOException { _controlInput_ = new BufferedReader(new InputStreamReader(socket.getInputStream(), getControlEncoding())); _controlOutput_ = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), getControlEncoding())); - if (isClientMode && (hostnameVerifier != null && !hostnameVerifier.verify(_hostname_, socket.getSession()))) { + if (isClientMode && hostnameVerifier != null && !hostnameVerifier.verify(_hostname_, socket.getSession())) { throw new SSLHandshakeException("Hostname doesn't match certificate"); } } diff --git a/src/main/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java b/src/main/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java index 496ae981c..516be6fb2 100644 --- a/src/main/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java +++ b/src/main/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java @@ -308,7 +308,7 @@ public Calendar parseTimestamp(final String timestampStr, final Calendar serverT // a valid year (e.g. 22:04 will parse as 22 A.D.) // so could mistakenly confuse an hour with a year, // if we don't insist on full length parsing. - if ((parsed == null) || (pp.getIndex() != timestampStr.length())) { + if (parsed == null || pp.getIndex() != timestampStr.length()) { throw new ParseException("Timestamp '" + timestampStr + "' could not be parsed using a server time of " + serverTime.getTime().toString(), pp.getErrorIndex()); } diff --git a/src/main/java/org/apache/commons/net/ftp/parser/MacOsPeterFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/MacOsPeterFTPEntryParser.java index 89e99f992..7b72a4aa4 100644 --- a/src/main/java/org/apache/commons/net/ftp/parser/MacOsPeterFTPEntryParser.java +++ b/src/main/java/org/apache/commons/net/ftp/parser/MacOsPeterFTPEntryParser.java @@ -152,8 +152,8 @@ public FTPFile parseFTPEntry(final String entry) { int g = 4; for (int access = 0; access < 3; access++, g += 4) { // Use != '-' to avoid having to check for suid and sticky bits - file.setPermission(access, FTPFile.READ_PERMISSION, (!group(g).equals("-"))); - file.setPermission(access, FTPFile.WRITE_PERMISSION, (!group(g + 1).equals("-"))); + file.setPermission(access, FTPFile.READ_PERMISSION, !group(g).equals("-")); + file.setPermission(access, FTPFile.WRITE_PERMISSION, !group(g + 1).equals("-")); final String execPerm = group(g + 2); file.setPermission(access, FTPFile.EXECUTE_PERMISSION, !execPerm.equals("-") && !Character.isUpperCase(execPerm.charAt(0))); diff --git a/src/main/java/org/apache/commons/net/ftp/parser/OS400FTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/OS400FTPEntryParser.java index 7320886ea..e5e9e3747 100644 --- a/src/main/java/org/apache/commons/net/ftp/parser/OS400FTPEntryParser.java +++ b/src/main/java/org/apache/commons/net/ftp/parser/OS400FTPEntryParser.java @@ -325,7 +325,7 @@ public FTPFile parseFTPEntry(final String entry) { // file. // Save files are a special type of files which are used // to save objects, e.g. for backups. - if ((name == null) || !name.toUpperCase(Locale.ROOT).endsWith(".SAVF")) { + if (name == null || !name.toUpperCase(Locale.ROOT).endsWith(".SAVF")) { return null; } mustScanForPathSeparator = false; diff --git a/src/main/java/org/apache/commons/net/ftp/parser/VMSVersioningFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/VMSVersioningFTPEntryParser.java index 3dd78e9a1..71a2af140 100644 --- a/src/main/java/org/apache/commons/net/ftp/parser/VMSVersioningFTPEntryParser.java +++ b/src/main/java/org/apache/commons/net/ftp/parser/VMSVersioningFTPEntryParser.java @@ -103,7 +103,7 @@ public List preParse(final List original) { final String version = result.group(2); final Integer nv = Integer.valueOf(version); final Integer existing = existingEntries.get(name); - if ((null != existing) && (nv.intValue() < existing.intValue())) { + if (null != existing && nv.intValue() < existing.intValue()) { iter.remove(); // removes older version from original list. continue; } @@ -125,7 +125,7 @@ public List preParse(final List original) { final String version = result.group(2); final int nv = Integer.parseInt(version); final Integer existing = existingEntries.get(name); - if ((null != existing) && (nv < existing.intValue())) { + if (null != existing && nv < existing.intValue()) { iter.remove(); // removes older version from original list. } } diff --git a/src/main/java/org/apache/commons/net/nntp/Article.java b/src/main/java/org/apache/commons/net/nntp/Article.java index 8418af76b..1c274dc63 100644 --- a/src/main/java/org/apache/commons/net/nntp/Article.java +++ b/src/main/java/org/apache/commons/net/nntp/Article.java @@ -161,7 +161,7 @@ public String getSubject() { @Override public boolean isDummy() { - return (articleNumber == -1); + return articleNumber == -1; } @Override @@ -246,13 +246,13 @@ private void simplifySubject() { start++; } - if (start < (len - 2) && (subject.charAt(start) == 'r' || subject.charAt(start) == 'R') + if (start < len - 2 && (subject.charAt(start) == 'r' || subject.charAt(start) == 'R') && (subject.charAt(start + 1) == 'e' || subject.charAt(start + 1) == 'E')) { if (subject.charAt(start + 2) == ':') { start += 3; // Skip "Re:" done = false; - } else if (start < (len - 2) && (subject.charAt(start + 2) == '[' || subject.charAt(start + 2) == '(')) { + } else if (start < len - 2 && (subject.charAt(start + 2) == '[' || subject.charAt(start + 2) == '(')) { int i = start + 3; @@ -260,7 +260,7 @@ private void simplifySubject() { i++; } - if (i < (len - 1) && (subject.charAt(i) == ']' || subject.charAt(i) == ')') && subject.charAt(i + 1) == ':') { + if (i < len - 1 && (subject.charAt(i) == ']' || subject.charAt(i) == ')') && subject.charAt(i + 1) == ':') { start = i + 2; done = false; } diff --git a/src/main/java/org/apache/commons/net/nntp/NNTPClient.java b/src/main/java/org/apache/commons/net/nntp/NNTPClient.java index 593636690..471400fcd 100644 --- a/src/main/java/org/apache/commons/net/nntp/NNTPClient.java +++ b/src/main/java/org/apache/commons/net/nntp/NNTPClient.java @@ -141,7 +141,7 @@ static NewsgroupInfo parseNewsgroupListEntry(final String entry) { final long firstNum = Long.parseLong(tokens[i++]); result.setFirstArticle(firstNum); result.setLastArticle(lastNum); - if ((firstNum == 0) && (lastNum == 0)) { + if (firstNum == 0 && lastNum == 0) { result.setArticleCount(0); } else { result.setArticleCount(lastNum - firstNum + 1); diff --git a/src/main/java/org/apache/commons/net/nntp/Threader.java b/src/main/java/org/apache/commons/net/nntp/Threader.java index 9c11c68d6..8f1a0b406 100644 --- a/src/main/java/org/apache/commons/net/nntp/Threader.java +++ b/src/main/java/org/apache/commons/net/nntp/Threader.java @@ -46,7 +46,7 @@ private void buildContainer(final Threadable threadable, final HashMap"; + id = ""; container = null; } else { // The container just contained a forward reference to this message, so let's @@ -79,7 +79,7 @@ private void buildContainer(final Threadable threadable, final HashMap make this message a child of old c.parent = old; c.next = old.child; @@ -296,9 +296,9 @@ private void gatherSubjects(final NntpThreadContainer root) { */ private void pruneEmptyContainers(final NntpThreadContainer parent) { NntpThreadContainer container, prev, next; - for (prev = null, container = parent.child, next = container.next; container != null; prev = container, container = next, next = (container == null + for (prev = null, container = parent.child, next = container.next; container != null; prev = container, container = next, next = container == null ? null - : container.next)) { + : container.next) { // Is it empty and without any children? If so,delete it if (container.threadable == null && container.child == null) { @@ -393,7 +393,7 @@ public Threadable thread(final Iterable messages) { } } - final Threadable result = (root.child == null ? null : root.child.threadable); + final Threadable result = root.child == null ? null : root.child.threadable; root.flush(); return result; diff --git a/src/main/java/org/apache/commons/net/ntp/NtpUtils.java b/src/main/java/org/apache/commons/net/ntp/NtpUtils.java index 4280e0b3d..3981a0f48 100644 --- a/src/main/java/org/apache/commons/net/ntp/NtpUtils.java +++ b/src/main/java/org/apache/commons/net/ntp/NtpUtils.java @@ -29,7 +29,7 @@ public final class NtpUtils { * @return the raw IP address in a string format. */ public static String getHostAddress(final int address) { - return ((address >>> 24) & 0xFF) + "." + ((address >>> 16) & 0xFF) + "." + ((address >>> 8) & 0xFF) + "." + ((address >>> 0) & 0xFF); + return (address >>> 24 & 0xFF) + "." + (address >>> 16 & 0xFF) + "." + (address >>> 8 & 0xFF) + "." + (address >>> 0 & 0xFF); } /** @@ -68,7 +68,7 @@ public static String getModeName(final int mode) { * @return the packet reference id (as IP address) in "%d.%d.%d.%d" format. */ public static String getRefAddress(final NtpV3Packet packet) { - final int address = (packet == null) ? 0 : packet.getReferenceId(); + final int address = packet == null ? 0 : packet.getReferenceId(); return getHostAddress(address); } @@ -90,7 +90,7 @@ public static String getReferenceClock(final NtpV3Packet message) { final StringBuilder buf = new StringBuilder(4); // start at highest-order byte (0x4c434c00 -> LCL) for (int shiftBits = 24; shiftBits >= 0; shiftBits -= 8) { - final char c = (char) ((refId >>> shiftBits) & 0xff); + final char c = (char) (refId >>> shiftBits & 0xff); if (c == 0) { // 0-terminated ASCII string break; } diff --git a/src/main/java/org/apache/commons/net/telnet/Telnet.java b/src/main/java/org/apache/commons/net/telnet/Telnet.java index c198ff4c3..f4177aa94 100644 --- a/src/main/java/org/apache/commons/net/telnet/Telnet.java +++ b/src/main/java/org/apache/commons/net/telnet/Telnet.java @@ -822,7 +822,7 @@ void setDo(final int option) throws IOException { options[option] |= DO_MASK; /* open TelnetOptionHandler functionality (start) */ - if (requestedDo(option) && (optionHandlers[option] != null)) { + if (requestedDo(option) && optionHandlers[option] != null) { optionHandlers[option].setDo(true); final int[] subneg = optionHandlers[option].startSubnegotiationRemote(); @@ -895,7 +895,7 @@ void setWill(final int option) throws IOException { options[option] |= WILL_MASK; /* open TelnetOptionHandler functionality (start) */ - if (requestedWill(option) && (optionHandlers[option] != null)) { + if (requestedWill(option) && optionHandlers[option] != null) { optionHandlers[option].setWill(true); final int[] subneg = optionHandlers[option].startSubnegotiationLocal(); diff --git a/src/main/java/org/apache/commons/net/telnet/TerminalTypeOptionHandler.java b/src/main/java/org/apache/commons/net/telnet/TerminalTypeOptionHandler.java index d0b91fff0..d02daf86c 100644 --- a/src/main/java/org/apache/commons/net/telnet/TerminalTypeOptionHandler.java +++ b/src/main/java/org/apache/commons/net/telnet/TerminalTypeOptionHandler.java @@ -80,8 +80,8 @@ public TerminalTypeOptionHandler(final String termtype, final boolean initlocal, */ @Override public int[] answerSubnegotiation(final int suboptionData[], final int suboptionLength) { - if ((suboptionData != null) && (suboptionLength > 1) && (termType != null)) { - if ((suboptionData[0] == TERMINAL_TYPE) && (suboptionData[1] == TERMINAL_TYPE_SEND)) { + if (suboptionData != null && suboptionLength > 1 && termType != null) { + if (suboptionData[0] == TERMINAL_TYPE && suboptionData[1] == TERMINAL_TYPE_SEND) { final int[] response = new int[termType.length() + 2]; response[0] = TERMINAL_TYPE; diff --git a/src/main/java/org/apache/commons/net/tftp/TFTPDataPacket.java b/src/main/java/org/apache/commons/net/tftp/TFTPDataPacket.java index 2a1c7477a..32ba24c2d 100644 --- a/src/main/java/org/apache/commons/net/tftp/TFTPDataPacket.java +++ b/src/main/java/org/apache/commons/net/tftp/TFTPDataPacket.java @@ -69,7 +69,7 @@ public final class TFTPDataPacket extends TFTPPacket { throw new TFTPPacketException("TFTP operator code does not match type."); } - this.blockNumber = (((this.data[2] & 0xff) << 8) | (this.data[3] & 0xff)); + this.blockNumber = (this.data[2] & 0xff) << 8 | this.data[3] & 0xff; this.length = datagram.getLength() - 4; diff --git a/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java b/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java index b46e7d43e..2772d4200 100644 --- a/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java +++ b/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java @@ -44,7 +44,7 @@ public class MVSFTPEntryParserTest extends AbstractFTPParseTest { "FPFS41 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.RPTBM056.D061704", "FPFS25 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.WTM204.D061704", "PEX26F 3390 2017/07/03 115807 FB 29600 29600 PS INCOMING.FIN.D170630.T160630", - "VVVVVV 3390 2020/04/18 1 60 U 32760 32760 PO NAME", + "VVVVVV 3390 2020/04/18 1 60 U 32760 32760 PO NAME", "TST017 3390 2023/09/08 2 59 FBA 133 32718 PO NAME", "TST063 3390 2023/09/11 1 1 VBA 133 27930 PS NAME", "Migrated NAME", diff --git a/src/test/java/org/apache/commons/net/telnet/TelnetClientFunctionalTest.java b/src/test/java/org/apache/commons/net/telnet/TelnetClientFunctionalTest.java index 28c006996..3c7bb7d45 100644 --- a/src/test/java/org/apache/commons/net/telnet/TelnetClientFunctionalTest.java +++ b/src/test/java/org/apache/commons/net/telnet/TelnetClientFunctionalTest.java @@ -77,7 +77,7 @@ public boolean waitForString(final InputStream is, final String end, final long final long starttime = System.currentTimeMillis(); String readbytes = ""; - while ((readbytes.indexOf(end) < 0) && ((System.currentTimeMillis() - starttime) < timeout)) { + while (readbytes.indexOf(end) < 0 && System.currentTimeMillis() - starttime < timeout) { if (is.available() > 0) { final int ret_read = is.read(buffer); readbytes = readbytes + new String(buffer, 0, ret_read); @@ -87,8 +87,8 @@ public boolean waitForString(final InputStream is, final String end, final long } if (readbytes.indexOf(end) >= 0) { - return (true); + return true; } - return (false); + return false; } } \ No newline at end of file diff --git a/src/test/java/org/apache/commons/net/tftp/TFTPServerPathTest.java b/src/test/java/org/apache/commons/net/tftp/TFTPServerPathTest.java index 972cd007f..006b04fce 100644 --- a/src/test/java/org/apache/commons/net/tftp/TFTPServerPathTest.java +++ b/src/test/java/org/apache/commons/net/tftp/TFTPServerPathTest.java @@ -94,7 +94,7 @@ public void testReadOnly() throws IOException { try (final FileInputStream fis = new FileInputStream(file)) { tftp.sendFile(out.getName(), TFTP.BINARY_MODE, fis, "localhost", SERVER_PORT); fail("Server allowed write"); - } + } }); } finally { deleteFixture(file); @@ -122,7 +122,7 @@ public void testWriteOnly() throws IOException { try (final FileOutputStream output = new FileOutputStream(out)) { tftp.receiveFile(file.getName(), TFTP.BINARY_MODE, output, "localhost", SERVER_PORT); fail("Server allowed read"); - } + } }); out.delete(); From 04817c96adfce576b2dacc33ec8f96b230b2a981 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 13 Sep 2023 09:50:38 -0400 Subject: [PATCH 42/45] Simplify --- .../commons/net/telnet/TelnetClientFunctionalTest.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/test/java/org/apache/commons/net/telnet/TelnetClientFunctionalTest.java b/src/test/java/org/apache/commons/net/telnet/TelnetClientFunctionalTest.java index 3c7bb7d45..a41a99dd9 100644 --- a/src/test/java/org/apache/commons/net/telnet/TelnetClientFunctionalTest.java +++ b/src/test/java/org/apache/commons/net/telnet/TelnetClientFunctionalTest.java @@ -86,9 +86,6 @@ public boolean waitForString(final InputStream is, final String end, final long } } - if (readbytes.indexOf(end) >= 0) { - return true; - } - return false; + return readbytes.indexOf(end) >= 0; } } \ No newline at end of file From 4d656cd62a2070a93ea7c099e6a375fe028b7b18 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Sep 2023 02:49:36 +0000 Subject: [PATCH 43/45] Bump github/codeql-action from 2.21.5 to 2.21.7 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.5 to 2.21.7. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/00e563ead9f72a8461b24876bee2d0c2e8bd2ee8...04daf014b50eaf774287bf3f0f1869d4b4c4b913) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/scorecards-analysis.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 1cd0e96bb..142042177 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -57,7 +57,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # v2.21.5 + uses: github/codeql-action/init@04daf014b50eaf774287bf3f0f1869d4b4c4b913 # v2.21.7 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -68,7 +68,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # v2.21.5 + uses: github/codeql-action/autobuild@04daf014b50eaf774287bf3f0f1869d4b4c4b913 # v2.21.7 # ℹī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -82,4 +82,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # v2.21.5 + uses: github/codeql-action/analyze@04daf014b50eaf774287bf3f0f1869d4b4c4b913 # v2.21.7 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index b7912d35d..d914a1380 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -64,6 +64,6 @@ jobs: retention-days: 5 - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # 2.21.5 + uses: github/codeql-action/upload-sarif@04daf014b50eaf774287bf3f0f1869d4b4c4b913 # 2.21.7 with: sarif_file: results.sarif From 5e137c62d5110cc735b4e71f7cf679417765d980 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 16 Sep 2023 11:27:11 -0400 Subject: [PATCH 44/45] Partial patch: Bulletproof TFTPServerPathTest #173 from Jakub Kupczyk --- .../org/apache/commons/net/tftp/TFTPServer.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/apache/commons/net/tftp/TFTPServer.java b/src/test/java/org/apache/commons/net/tftp/TFTPServer.java index c6fc2efec..ffd26d72d 100644 --- a/src/test/java/org/apache/commons/net/tftp/TFTPServer.java +++ b/src/test/java/org/apache/commons/net/tftp/TFTPServer.java @@ -610,7 +610,7 @@ protected void finalize() throws Throwable { } /** - * Get the current value for maxTimeoutRetries + * Gets the current value for maxTimeoutRetries * * @return the max allowed number of retries */ @@ -619,7 +619,16 @@ public int getMaxTimeoutRetries() { } /** - * The current socket timeout used during transfers in milliseconds. + * Gets the server port number + * + * @return the server port number + */ + public int getPort() { + return port; + } + + /** + * Gets the current socket timeout used during transfers in milliseconds. * * @return the timeout value */ From cd0aa01783cc7c0459f24ac9139b952f144c110b Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 16 Sep 2023 11:29:20 -0400 Subject: [PATCH 45/45] Reuse FileUtils#contentEquals(File,File) in tests --- .../org/apache/commons/net/tftp/TFTPTest.java | 33 +++---------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/src/test/java/org/apache/commons/net/tftp/TFTPTest.java b/src/test/java/org/apache/commons/net/tftp/TFTPTest.java index 36c17f807..63f8f0a11 100644 --- a/src/test/java/org/apache/commons/net/tftp/TFTPTest.java +++ b/src/test/java/org/apache/commons/net/tftp/TFTPTest.java @@ -76,33 +76,8 @@ private static File createFile(final File file, final int size) throws IOExcepti return file; } - private boolean filesIdentical(final File a, final File b) throws IOException { - if (!a.exists() || !b.exists()) { - return false; - } - - if (a.length() != b.length()) { - return false; - } - - try (final InputStream fisA = new BufferedInputStream(new FileInputStream(a)); - final InputStream fisB = new BufferedInputStream(new FileInputStream(b))) { - - int aBit = fisA.read(); - int bBit = fisB.read(); - - while (aBit != -1) { - if (aBit != bBit) { - fisA.close(); - fisB.close(); - return false; - } - aBit = fisA.read(); - bBit = fisB.read(); - } - - } - return true; + private boolean contentEquals(final File a, final File b) throws IOException { + return FileUtils.contentEquals(a, b); } @Override @@ -155,7 +130,7 @@ private void testDownload(final int mode, final File file) throws IOException { } assertTrue("file not created", out.exists()); - assertTrue("FILES not identical on file " + file, filesIdentical(out, file)); + assertTrue("FILES not identical on file " + file, contentEquals(out, file)); // delete the downloaded file out.delete(); @@ -208,7 +183,7 @@ private void testUpload(final int mode, final File file) throws Exception { // close out its file buffers, etc. Thread.sleep(100); assertTrue("file not created", in.exists()); - assertTrue("FILES not identical on file " + file, filesIdentical(file, in)); + assertTrue("FILES not identical on file " + file, contentEquals(file, in)); in.delete(); }