commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1788347 - in /commons/proper/net/trunk/src: changes/changes.xml main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java
Date Thu, 23 Mar 2017 23:51:01 GMT
Author: sebb
Date: Thu Mar 23 23:51:01 2017
New Revision: 1788347

URL: http://svn.apache.org/viewvc?rev=1788347&view=rev
Log:
NET-631 Bug in MVSFTPEntryParser.parseUnixList (FindBugs)

Modified:
    commons/proper/net/trunk/src/changes/changes.xml
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java

Modified: commons/proper/net/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1788347&r1=1788346&r2=1788347&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml [utf-8] (original)
+++ commons/proper/net/trunk/src/changes/changes.xml [utf-8] Thu Mar 23 23:51:01 2017
@@ -71,6 +71,9 @@ This is mainly a bug-fix release. See fu
  However it is not source compatible with releases before 3.4, as some methods were added
to the interface NtpV3Packet in 3.4
         
 ">
+            <action issue="NET-631" type="fix" dev="sebb">
+            Bug in MVSFTPEntryParser.parseUnixList (FindBugs)
+            </action>
             <action issue="NET-584" type="fix" dev="sebb" due-to="Kazantsev Andrey Sergeevich/Nick
Manley">
             Error when using org.apache.commons.net.ftp.FTPClient setControlKeepAliveTimeout
             </action>

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java?rev=1788347&r1=1788346&r2=1788347&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java
(original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java
Thu Mar 23 23:51:01 2017
@@ -271,7 +271,7 @@ public class MVSFTPEntryParser extends C
                 isParsed = parseSimpleEntry(f, entry);
             }
         } else if (isType == UNIX_LIST_TYPE) {
-            isParsed = parseUnixList(f, entry);
+            return unixFTPEntryParser.parseFTPEntry(entry);
         } else if (isType == JES_LEVEL_1_LIST_TYPE) {
             isParsed = parseJeslevel1List(f, entry);
         } else if (isType == JES_LEVEL_2_LIST_TYPE) {
@@ -402,21 +402,6 @@ public class MVSFTPEntryParser extends C
     }
 
     /**
-     * Parse the entry as a standard unix file. Using the UnixFTPEntryParser.
-     *
-     * @param file
-     * @param entry
-     * @return true: entry is parsed, false: entry could not be parsed.
-     */
-    private boolean parseUnixList(FTPFile file, String entry) {
-        file = unixFTPEntryParser.parseFTPEntry(entry);
-        if (file == null) {
-            return false;
-        }
-        return true;
-    }
-
-    /**
      * Matches these entries, note: no header:
      * <pre>
      * [1]      [2]      [3]   [4] [5]

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java?rev=1788347&r1=1788346&r2=1788347&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java
(original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java
Thu Mar 23 23:51:01 2017
@@ -17,6 +17,7 @@
 package org.apache.commons.net.ftp.parser;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.commons.net.ftp.FTPFile;
@@ -63,6 +64,12 @@ public class MVSFTPEntryParserTest exten
             "IBMUSER2 JOB01906 IBMUSER  OUTPUT A        RC=0000 3 spool files",
             "IBMUSER  TSU01830 IBMUSER  OUTPUT TSU      ABEND=522 3 spool files", };
 
+    private static final String[] goodsamplesUnixList = {
+            "total 1234",
+            "-rwxr-xr-x   2 root     root         4096 Mar  2 15:13 zxbox",
+            "drwxr-xr-x   2 root     root         4096 Aug 24  2001 zxjdbc",
+            };
+
     private static final String[] badsamples = {
             "MigratedP201.$FTXPBI1.$CF2ITB.$AAB0402.I",
             "PSMLC133902005/04/041VB2799427998PSfile1.I", "file2.O", };
@@ -97,7 +104,7 @@ public class MVSFTPEntryParserTest exten
         l.add(goodsamplesMemberList);
         l.add(goodsamplesJES1List);
         l.add(goodsamplesJES2List);
-
+        l.add(goodsamplesUnixList);
         return l;
     }
 
@@ -163,6 +170,20 @@ public class MVSFTPEntryParserTest exten
         }
     }
 
+    public void testUnixListings() {
+        MVSFTPEntryParser parser = new MVSFTPEntryParser();
+        List<String> list = new ArrayList<String>();
+        Collections.addAll(list, goodsamplesUnixList);
+        parser.preParse(list);
+        for (String test : list) {
+            FTPFile f = parser.parseFTPEntry(test);
+            assertNotNull("Failed to parse " + test, f);
+            assertNotNull("Failed to parse name " + test, f.getName());
+            assertNotNull("Failed to parse group " + test, f.getGroup());
+            assertNotNull("Failed to parse user " + test, f.getUser());
+        }
+    }
+
     @Override
     public void testParseFieldsOnDirectory() throws Exception {
         MVSFTPEntryParser parser = new MVSFTPEntryParser();



Mime
View raw message