diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 2914fed69..7a4ae0b39 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -3,6 +3,7 @@ Amongst other, the following people contributed to ant:
Adam Blinkinsop
Adam Bryzak
Adam Sotona
+Adrian Nistor
Aleksandr Ishutin
Alex Rosen
Alexei Yudichev
diff --git a/contributors.xml b/contributors.xml
index 6c86cd6fd..55ddebda2 100644
--- a/contributors.xml
+++ b/contributors.xml
@@ -42,6 +42,10 @@
Adam
Sotona
+
+ Adrian
+ Nistor
+
Aleksandr
Ishutin
diff --git a/src/main/org/apache/tools/ant/ComponentHelper.java b/src/main/org/apache/tools/ant/ComponentHelper.java
index 44b7daa3c..eceedeef0 100644
--- a/src/main/org/apache/tools/ant/ComponentHelper.java
+++ b/src/main/org/apache/tools/ant/ComponentHelper.java
@@ -1017,7 +1017,7 @@ public class ComponentHelper {
* Print unknown definition.forking
*/
private void printUnknownDefinition(PrintWriter out, String componentName, String dirListing) {
- boolean isAntlib = componentName.indexOf(MagicNames.ANTLIB_PREFIX) == 0;
+ boolean isAntlib = componentName.startsWith(MagicNames.ANTLIB_PREFIX);
String uri = ProjectHelper.extractUriFromComponentName(componentName);
out.println("Cause: The name is undefined.");
out.println("Action: Check the spelling.");
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java
index 02fcac282..63451e7e2 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java
@@ -156,7 +156,7 @@ public class FailureRecorder extends ProjectComponent implements JUnitResultForm
Object listener = allListeners.get(i);
if (listener instanceof FailureRecorder) {
alreadyRegistered = true;
- continue;
+ break;
}
}
// register if needed
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
index 9ac230792..44f50b0d4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
@@ -727,6 +727,7 @@ public class FTP extends Task implements FTPTaskConfig {
&& pcounter != icounter
&& target.equals(array[pcounter].getName())) {
candidateFound = false;
+ break;
}
}
if (candidateFound) {
@@ -908,7 +909,7 @@ public class FTP extends Task implements FTPTaskConfig {
*/
public String getFastRelativePath() {
String absPath = getAbsolutePath();
- if (absPath.indexOf(rootPath + remoteFileSep) == 0) {
+ if (absPath.startsWith(rootPath + remoteFileSep)) {
return absPath.substring(rootPath.length() + remoteFileSep.length());
}
return null;
@@ -2356,13 +2357,13 @@ public class FTP extends Task implements FTPTaskConfig {
throws IOException, BuildException {
String workingDirectory = ftp.printWorkingDirectory();
if (verbose) {
- if (dir.indexOf("/") == 0 || workingDirectory == null) {
+ if (dir.startsWith("/") || workingDirectory == null) {
log("Creating directory: " + dir + " in /");
} else {
log("Creating directory: " + dir + " in " + workingDirectory);
}
}
- if (dir.indexOf("/") == 0) {
+ if (dir.startsWith("/")) {
ftp.changeWorkingDirectory("/");
}
String subdir = "";
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
index 7597a2d39..1115f67ef 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
@@ -628,6 +628,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
&& pcounter != icounter
&& target.equals(array[pcounter].getName())) {
candidateFound = false;
+ break;
}
}
if (candidateFound) {
@@ -810,7 +811,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
*/
public String getFastRelativePath() {
String absPath = getAbsolutePath();
- if (absPath.indexOf(rootPath + task.getSeparator()) == 0) {
+ if (absPath.startsWith(rootPath + task.getSeparator())) {
return absPath.substring(rootPath.length()
+ task.getSeparator().length());
}
@@ -1757,13 +1758,13 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
throws IOException, BuildException {
String workingDirectory = ftp.printWorkingDirectory();
if (task.isVerbose()) {
- if (dir.indexOf("/") == 0 || workingDirectory == null) {
+ if (dir.startsWith("/") || workingDirectory == null) {
task.log("Creating directory: " + dir + " in /");
} else {
task.log("Creating directory: " + dir + " in " + workingDirectory);
}
}
- if (dir.indexOf("/") == 0) {
+ if (dir.startsWith("/")) {
ftp.changeWorkingDirectory("/");
}
String subdir = "";
diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java
index 01030107f..c963f49f1 100644
--- a/src/main/org/apache/tools/ant/util/FileUtils.java
+++ b/src/main/org/apache/tools/ant/util/FileUtils.java
@@ -637,7 +637,7 @@ public class FileUtils {
int len = filename.length();
return (c == sep && (len == 1 || filename.charAt(1) != sep))
|| (Character.isLetter(c) && len > 1
- && filename.indexOf(':') == 1
+ && filename.charAt(1) == ':'
&& (len == 2 || filename.charAt(2) != sep));
}
diff --git a/src/main/org/apache/tools/ant/util/IdentityStack.java b/src/main/org/apache/tools/ant/util/IdentityStack.java
index 8aee0fed9..07b7766c1 100644
--- a/src/main/org/apache/tools/ant/util/IdentityStack.java
+++ b/src/main/org/apache/tools/ant/util/IdentityStack.java
@@ -17,6 +17,10 @@
*/
package org.apache.tools.ant.util;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.Set;
import java.util.Stack;
/**
@@ -102,4 +106,18 @@ public class IdentityStack extends Stack {
return -1;
}
+ public synchronized boolean removeAll(Collection> c) {
+ if (!(c instanceof Set)) {
+ c = new HashSet(c);
+ }
+ return super.removeAll(c);
+ }
+
+ public synchronized boolean containsAll(Collection> c) {
+ IdentityHashMap map = new IdentityHashMap();
+ for (Object e : this) {
+ map.put(e, Boolean.TRUE);
+ }
+ return map.keySet().containsAll(c);
+ }
}
diff --git a/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java b/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
index e52261aab..8b46e27fc 100644
--- a/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
+++ b/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
@@ -410,7 +410,7 @@ public class DirectoryScannerTest extends BuildFileTest {
// ${tests.and.ant.share.classloader} will be set
// we are trying to catch this here.
if (shareclassloader == null
- || (shareclassloader != null && shareclassloader.indexOf("${") == 0)) {
+ || (shareclassloader != null && shareclassloader.startsWith("${"))) {
System.out.println("cannot execute testIsExcludedDirectoryScanned when tests are forked, " +
"package private method called");
return;
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java
index c8a46ea1a..1a9f39f1f 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java
@@ -204,7 +204,7 @@ public class XmlPropertyTest extends BuildFileTest {
String xmlValue = (String)xmlproperties.get(currentKey);
- if ( propertyValue.indexOf("ID.") == 0 ) {
+ if (propertyValue.startsWith("ID.")) {
// The property is an id's thing -- either a property
// or a path. We need to make sure
// that the object was created with the given id.
@@ -231,7 +231,7 @@ public class XmlPropertyTest extends BuildFileTest {
} else {
- if (propertyValue.indexOf("FILE.") == 0) {
+ if (propertyValue.startsWith("FILE.")) {
// The property is the name of a file. We are testing
// a location attribute, so we need to resolve the given
// file name in the provided folder.