Browse Source

pr 41724: FTP task fail, FTPClient may return null in its arrays.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@574313 13f79535-47bb-0310-9956-ffa450edef68
master
Jacobus Martinus Kruithof 18 years ago
parent
commit
02fce032ed
2 changed files with 20 additions and 13 deletions
  1. +3
    -0
      WHATSNEW
  2. +17
    -13
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java

+ 3
- 0
WHATSNEW View File

@@ -61,6 +61,9 @@ Changes that could break older environments:

Fixed bugs:
-----------
* Error in FTP task
Bugzilla report 41724

* Regression: Locator fails with URI encoding problem when spaces in path
Bugzilla report 42222



+ 17
- 13
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -371,8 +371,9 @@ public class FTP
}
for (int i = 0; i < newfiles.length; i++) {
FTPFile file = newfiles[i];
if (!file.getName().equals(".")
&& !file.getName().equals("..")) {
if (file != null
&& !file.getName().equals(".")
&& !file.getName().equals("..")) {
if (isFunctioningAsDirectory(ftp, dir, file)) {
String name = vpath + file.getName();
boolean slowScanAllowed = true;
@@ -571,7 +572,7 @@ public class FTP
boolean candidateFound = false;
String target = null;
for (int icounter = 0; icounter < array.length; icounter++) {
if (array[icounter].isDirectory()) {
if (array[icounter] != null && array[icounter].isDirectory()) {
if (!array[icounter].getName().equals(".")
&& !array[icounter].getName().equals("..")) {
candidateFound = true;
@@ -580,7 +581,7 @@ public class FTP
+ target + " where a directory called " + array[icounter].getName()
+ " exists", Project.MSG_DEBUG);
for (int pcounter = 0; pcounter < array.length; pcounter++) {
if (array[pcounter].getName().equals(target) && pcounter != icounter) {
if (array[pcounter] != null && pcounter != icounter && target.equals(array[pcounter].getName()) ) {
candidateFound = false;
}
}
@@ -719,7 +720,7 @@ public class FTP
return null;
}
for (int icounter = 0; icounter < theFiles.length; icounter++) {
if (theFiles[icounter].getName().equalsIgnoreCase(soughtPathElement)) {
if (theFiles[icounter] != null && theFiles[icounter].getName().equalsIgnoreCase(soughtPathElement)) {
return theFiles[icounter].getName();
}
}
@@ -841,12 +842,15 @@ public class FTP
return null;
}
for (int fcount = 0; fcount < theFiles.length; fcount++) {
if (theFiles[fcount].getName().equals(lastpathelement)) {
return theFiles[fcount];
} else if (!isCaseSensitive()
&& theFiles[fcount].getName().equalsIgnoreCase(lastpathelement)) {
return theFiles[fcount];
}
if (theFiles[fcount] != null) {
if (theFiles[fcount].getName().equals(lastpathelement)) {
return theFiles[fcount];
} else if (!isCaseSensitive()
&& theFiles[fcount].getName().equalsIgnoreCase(
lastpathelement)) {
return theFiles[fcount];
}
}
}
return null;
}
@@ -1825,11 +1829,11 @@ public class FTP
String fileName = localFile.getName();
boolean found = false;
try {
if (counter == 1) {
if (theFiles == null) {
theFiles = ftp.listFiles();
}
for (int counter2 = 0; counter2 < theFiles.length; counter2++) {
if (theFiles[counter2].getName().equals(fileName)) {
if (theFiles[counter2] != null && theFiles[counter2].getName().equals(fileName)) {
found = true;
break;
}


Loading…
Cancel
Save