You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/02/08 18:24:45 UTC

[commons-net] branch release updated (64c6727 -> 2393a55)

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

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


    from 64c6727  Format tweaks.
     new 9cb799c  Format tweaks.
     new ec77e3d  Test hasFeature(FTPCmd).
     new 2393a55  Add FTPClient.hasFeature(FTPCmd).

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


Summary of changes:
 src/changes/changes.xml                            | 17 ++++++----
 .../java/org/apache/commons/net/ftp/FTPClient.java | 36 +++++++++++++++++-----
 .../org/apache/commons/net/ftp/FTPSClientTest.java | 11 +++++++
 3 files changed, 51 insertions(+), 13 deletions(-)


[commons-net] 03/03: Add FTPClient.hasFeature(FTPCmd).

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

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

commit 2393a55791dda1b0d38a1950aad276ff7703cc6e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Feb 8 13:24:40 2021 -0500

    Add FTPClient.hasFeature(FTPCmd).
---
 src/changes/changes.xml                                 | 17 +++++++++++------
 src/main/java/org/apache/commons/net/ftp/FTPClient.java | 16 ++++++++--------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index cde7a70..2d908e9 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -64,6 +64,17 @@ The <action> type attribute can be add,update,fix,remove.
 
     <body>
         <release version="3.8.0" date="2020-MM-DD" description="Maintenance and bug fix release (Java 7).">
+            <!-- ADD -->
+           <action type="update" dev="ggregory" due-to="Arturo Bernal, Gary Gregory">
+            Add and use NetConstants.
+            </action>
+           <action type="update" dev="ggregory" due-to="Gary Gregory">
+            Add and use SocketClient.applySocketAttributes().
+            </action>
+            <action type="update" dev="ggregory" due-to="Dependabot">
+            Add FTPClient.hasFeature(FTPCmd).
+            </action>
+            <!-- UPDATE -->
             <action type="update" dev="ggregory" due-to="Dependabot">
             Bump actions/checkout from v2.3.3 to v2.3.4 #69.
             </action>
@@ -76,12 +87,6 @@ The <action> type attribute can be add,update,fix,remove.
            <action type="update" dev="ggregory" due-to="Arturo Bernal, Gary Gregory">
             Minor Improvements #71, #72.
             </action>
-           <action type="update" dev="ggregory" due-to="Arturo Bernal, Gary Gregory">
-            Add and use NetConstants.
-            </action>
-           <action type="update" dev="ggregory" due-to="Gary Gregory">
-            Add and use SocketClient.applySocketAttributes().
-            </action>
         </release>
         <release version="3.7.2" date="2020-10-14" description="Maintenance and bug fix release (Java 7).">
             <action issue="NET-689" type="fix" dev="ggregory" due-to="Charlie, Gary Gregory">
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 3e4b027..907411d 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPClient.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPClient.java
@@ -473,15 +473,15 @@ public class FTPClient extends FTP implements Configurable {
      * transfer.
      */
     public static final int PASSIVE_REMOTE_DATA_CONNECTION_MODE = 3;
-    
+
     /** Pattern for PASV mode responses. Groups: (n,n,n,n),(n),(n) */
     private static final java.util.regex.Pattern PARMS_PAT;
-    
+
     static {
         PARMS_PAT = java.util.regex.Pattern.compile(
                 "(\\d{1,3},\\d{1,3},\\d{1,3},\\d{1,3}),(\\d{1,3}),(\\d{1,3})");
     }
-    
+
     private static Properties getOverrideProperties() {
         return PropertiesSingleton.PROPERTIES;
     }
@@ -534,7 +534,7 @@ public class FTPClient extends FTP implements Configurable {
         // malformed reply, return all after reply code and space
         return param;
     }
-    
+
     private int dataConnectionMode;
     private int dataTimeoutMillis;
 
@@ -544,10 +544,10 @@ public class FTPClient extends FTP implements Configurable {
     private int activeMinPort;
     private int activeMaxPort;
     private InetAddress activeExternalHost;
-    
+
     /** overrides __activeExternalHost in EPRT/PORT commands. */
     private InetAddress reportActiveExternalHost;
-    
+
     /** The address to bind to on passive connections, if necessary. */
     private InetAddress passiveLocalHost;
     private int fileType;
@@ -2211,11 +2211,11 @@ public class FTPClient extends FTP implements Configurable {
             for (final String line : _replyLines) {
                 if (line.startsWith(" ")) { // it's a FEAT entry
                     String key;
-                    String value="";
+                    String value = "";
                     final int varsep = line.indexOf(' ', 1);
                     if (varsep > 0) {
                         key = line.substring(1, varsep);
-                        value = line.substring(varsep+1);
+                        value = line.substring(varsep + 1);
                     } else {
                         key = line.substring(1);
                     }


[commons-net] 02/03: Test hasFeature(FTPCmd).

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

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

commit ec77e3db00fa24422d9c47fe41be84f5fc1513bd
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Feb 8 13:20:01 2021 -0500

    Test hasFeature(FTPCmd).
---
 src/test/java/org/apache/commons/net/ftp/FTPSClientTest.java | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/test/java/org/apache/commons/net/ftp/FTPSClientTest.java b/src/test/java/org/apache/commons/net/ftp/FTPSClientTest.java
index a79f1cd..300de79 100644
--- a/src/test/java/org/apache/commons/net/ftp/FTPSClientTest.java
+++ b/src/test/java/org/apache/commons/net/ftp/FTPSClientTest.java
@@ -236,6 +236,17 @@ public class FTPSClientTest {
 
     @Test
     public void testOpenClose() throws SocketException, IOException {
+        final FTPSClient ftpsClient = loginClient();
+        try {
+            assertTrue(ftpsClient.hasFeature("MODE"));
+            assertTrue(ftpsClient.hasFeature(FTPCmd.MODE));
+        } finally {
+            ftpsClient.disconnect();
+        }
+    }
+
+    @Test
+    public void testHasFeature() throws SocketException, IOException {
         loginClient().disconnect();
     }
 


[commons-net] 01/03: Format tweaks.

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

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

commit 9cb799c68ca72222170d97794db5b0732abe6d27
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Feb 8 13:09:58 2021 -0500

    Format tweaks.
---
 .../java/org/apache/commons/net/ftp/FTPClient.java | 32 ++++++++++++++++++----
 1 file changed, 27 insertions(+), 5 deletions(-)

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 8917c4c..3e4b027 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPClient.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPClient.java
@@ -291,9 +291,7 @@ import org.apache.commons.net.util.NetConstants;
  *
  * @see org.apache.commons.net.MalformedServerReplyException
  */
-public class FTPClient extends FTP
-implements Configurable
-{
+public class FTPClient extends FTP implements Configurable {
     // @since 3.0
     private static class CSL implements CopyStreamListener {
 
@@ -475,15 +473,19 @@ implements Configurable
      * transfer.
      */
     public static final int PASSIVE_REMOTE_DATA_CONNECTION_MODE = 3;
+    
     /** Pattern for PASV mode responses. Groups: (n,n,n,n),(n),(n) */
     private static final java.util.regex.Pattern PARMS_PAT;
+    
     static {
         PARMS_PAT = java.util.regex.Pattern.compile(
                 "(\\d{1,3},\\d{1,3},\\d{1,3},\\d{1,3}),(\\d{1,3}),(\\d{1,3})");
     }
-    private static Properties getOverrideProperties(){
+    
+    private static Properties getOverrideProperties() {
         return PropertiesSingleton.PROPERTIES;
     }
+
     /**
      * Parse the pathname from a CWD reply.
      * <p>
@@ -532,6 +534,7 @@ implements Configurable
         // malformed reply, return all after reply code and space
         return param;
     }
+    
     private int dataConnectionMode;
     private int dataTimeoutMillis;
 
@@ -541,7 +544,10 @@ implements Configurable
     private int activeMinPort;
     private int activeMaxPort;
     private InetAddress activeExternalHost;
-    private InetAddress reportActiveExternalHost; // overrides __activeExternalHost in EPRT/PORT commands
+    
+    /** overrides __activeExternalHost in EPRT/PORT commands. */
+    private InetAddress reportActiveExternalHost;
+    
     /** The address to bind to on passive connections, if necessary. */
     private InetAddress passiveLocalHost;
     private int fileType;
@@ -2115,6 +2121,22 @@ implements Configurable
      * if it is necessary to distinguish these cases.
      *
      * @throws IOException on error
+     * @since 3.8.0
+     */
+    public boolean hasFeature(final FTPCmd feature) throws IOException {
+        return hasFeature(feature.name());
+    }
+
+    /**
+     * Queries the server for a supported feature.
+     * Caches the parsed response to avoid resending the command repeatedly.
+     *
+     * @param feature the name of the feature; it is converted to upper case.
+     * @return {@code true} if the feature is present, {@code false} if the feature is not present
+     * or the {@link #feat()} command failed. Check {@link #getReplyCode()} or {@link #getReplyString()}
+     * if it is necessary to distinguish these cases.
+     *
+     * @throws IOException on error
      * @since 3.0
      */
     public boolean hasFeature(final String feature) throws IOException {