Browse Source

SonarQube: nested if’s is a major code smell

master
Gintas Grigelionis 6 years ago
parent
commit
2b699eb695
29 changed files with 254 additions and 361 deletions
  1. +6
    -5
      src/main/org/apache/tools/ant/IntrospectionHelper.java
  2. +6
    -12
      src/main/org/apache/tools/ant/Main.java
  3. +20
    -30
      src/main/org/apache/tools/ant/PropertyHelper.java
  4. +3
    -5
      src/main/org/apache/tools/ant/RuntimeConfigurable.java
  5. +6
    -11
      src/main/org/apache/tools/ant/UnknownElement.java
  6. +8
    -10
      src/main/org/apache/tools/ant/filters/ConcatFilter.java
  7. +5
    -9
      src/main/org/apache/tools/ant/filters/HeadFilter.java
  8. +17
    -19
      src/main/org/apache/tools/ant/filters/StripJavaComments.java
  9. +3
    -5
      src/main/org/apache/tools/ant/filters/TabsToSpaces.java
  10. +13
    -16
      src/main/org/apache/tools/ant/helper/ProjectHelper2.java
  11. +10
    -19
      src/main/org/apache/tools/ant/taskdefs/Available.java
  12. +5
    -6
      src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
  13. +2
    -4
      src/main/org/apache/tools/ant/taskdefs/Jikes.java
  14. +3
    -6
      src/main/org/apache/tools/ant/taskdefs/SQLExec.java
  15. +2
    -4
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  16. +5
    -6
      src/main/org/apache/tools/ant/taskdefs/email/EmailAddress.java
  17. +10
    -17
      src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
  18. +5
    -9
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java
  19. +17
    -19
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
  20. +24
    -42
      src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java
  21. +31
    -34
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  22. +13
    -14
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  23. +15
    -18
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
  24. +4
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java
  25. +9
    -11
      src/main/org/apache/tools/ant/types/resources/URLResource.java
  26. +2
    -4
      src/main/org/apache/tools/ant/util/GlobPatternMapper.java
  27. +3
    -5
      src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java
  28. +3
    -6
      src/main/org/apache/tools/ant/util/RegexpPatternMapper.java
  29. +4
    -7
      src/main/org/apache/tools/tar/TarBuffer.java

+ 6
- 5
src/main/org/apache/tools/ant/IntrospectionHelper.java View File

@@ -218,11 +218,12 @@ public final class IntrospectionHelper {
*/ */
continue; continue;
} }
if (File.class.equals(args[0])) {
// Ant Resources/FileProviders override java.io.File
if (Resource.class.equals(as.type) || FileProvider.class.equals(as.type)) {
continue;
}
if (File.class.equals(args[0])
&& (Resource.class.equals(as.type) || FileProvider.class.equals(as.type))) {
/*
Ant Resources/FileProviders override java.io.File
*/
continue;
} }
/* /*
In cases other than those just explicitly covered, In cases other than those just explicitly covered,


+ 6
- 12
src/main/org/apache/tools/ant/Main.java View File

@@ -737,10 +737,8 @@ public class Main implements AntMain {


for (final ArgumentProcessor processor : processorRegistry.getProcessors()) { for (final ArgumentProcessor processor : processorRegistry.getProcessors()) {
final List<String> extraArgs = extraArguments.get(processor.getClass()); final List<String> extraArgs = extraArguments.get(processor.getClass());
if (extraArgs != null) {
if (processor.handleArg(extraArgs)) {
return;
}
if (extraArgs != null && processor.handleArg(extraArgs)) {
return;
} }
} }


@@ -810,10 +808,8 @@ public class Main implements AntMain {


for (final ArgumentProcessor processor : processorRegistry.getProcessors()) { for (final ArgumentProcessor processor : processorRegistry.getProcessors()) {
final List<String> extraArgs = extraArguments.get(processor.getClass()); final List<String> extraArgs = extraArguments.get(processor.getClass());
if (extraArgs != null) {
if (processor.handleArg(project, extraArgs)) {
return;
}
if (extraArgs != null && processor.handleArg(project, extraArgs)) {
return;
} }
} }


@@ -825,10 +821,8 @@ public class Main implements AntMain {
} }


// make sure that we have a target to execute // make sure that we have a target to execute
if (targets.isEmpty()) {
if (project.getDefaultTarget() != null) {
targets.addElement(project.getDefaultTarget());
}
if (targets.isEmpty() && project.getDefaultTarget() != null) {
targets.addElement(project.getDefaultTarget());
} }


project.executeTargets(targets); project.executeTargets(targets);


+ 20
- 30
src/main/org/apache/tools/ant/PropertyHelper.java View File

@@ -144,8 +144,7 @@ public class PropertyHelper implements GetProperty {
* @param propertyHelper the invoking PropertyHelper. * @param propertyHelper the invoking PropertyHelper.
* @return true if this entity 'owns' the property. * @return true if this entity 'owns' the property.
*/ */
boolean setNew(
String property, Object value, PropertyHelper propertyHelper);
boolean setNew(String property, Object value, PropertyHelper propertyHelper);


/** /**
* Set a property. * Set a property.
@@ -157,8 +156,7 @@ public class PropertyHelper implements GetProperty {
* @param propertyHelper the invoking PropertyHelper. * @param propertyHelper the invoking PropertyHelper.
* @return true if this entity 'owns' the property. * @return true if this entity 'owns' the property.
*/ */
boolean set(
String property, Object value, PropertyHelper propertyHelper);
boolean set(String property, Object value, PropertyHelper propertyHelper);
} }


//TODO PropertyEnumerator Delegate type, would improve PropertySet //TODO PropertyEnumerator Delegate type, would improve PropertySet
@@ -173,6 +171,7 @@ public class PropertyHelper implements GetProperty {
private final String PREFIX = "toString:"; private final String PREFIX = "toString:";
private final int PREFIX_LEN = PREFIX.length(); private final int PREFIX_LEN = PREFIX.length();


@Override
public Object evaluate(String property, PropertyHelper propertyHelper) { public Object evaluate(String property, PropertyHelper propertyHelper) {
Object o = null; Object o = null;
if (property.startsWith(PREFIX) && propertyHelper.getProject() != null) { if (property.startsWith(PREFIX) && propertyHelper.getProject() != null) {
@@ -182,18 +181,15 @@ public class PropertyHelper implements GetProperty {
} }
}; };


private static final PropertyExpander DEFAULT_EXPANDER =
(s, pos, notUsed) -> {
private static final PropertyExpander DEFAULT_EXPANDER = (s, pos, notUsed) -> {
int index = pos.getIndex(); int index = pos.getIndex();
//directly check near, triggering characters: //directly check near, triggering characters:
if (s.length() - index >= 3 && '$' == s.charAt(index)
&& '{' == s.charAt(index + 1)) {
if (s.length() - index >= 3 && '$' == s.charAt(index) && '{' == s.charAt(index + 1)) {
int start = index + 2; int start = index + 2;
//defer to String.indexOf() for protracted check: //defer to String.indexOf() for protracted check:
int end = s.indexOf('}', start); int end = s.indexOf('}', start);
if (end < 0) { if (end < 0) {
throw new BuildException(
"Syntax error in property: " + s.substring(index));
throw new BuildException("Syntax error in property: " + s.substring(index));
} }
pos.setIndex(end + 1); pos.setIndex(end + 1);
return start == end ? "" : s.substring(start, end); return start == end ? "" : s.substring(start, end);
@@ -202,19 +198,16 @@ public class PropertyHelper implements GetProperty {
}; };


/** dummy */ /** dummy */
private static final PropertyExpander SKIP_DOUBLE_DOLLAR =
(s, pos, notUsed) -> {
private static final PropertyExpander SKIP_DOUBLE_DOLLAR = (s, pos, notUsed) -> {
int index = pos.getIndex(); int index = pos.getIndex();
if (s.length() - index >= 2) {
/* check for $$; if found, advance by one--
* this expander is at the bottom of the stack
* and will thus be the last consulted,
* so the next thing that ParseProperties will do
* is advance the parse position beyond the second $
*/
if ('$' == s.charAt(index) && '$' == s.charAt(++index)) {
pos.setIndex(index);
}
/* check for $$; if found, advance by one--
* this expander is at the bottom of the stack
* and will thus be the last consulted,
* so the next thing that ParseProperties will do
* is advance the parse position beyond the second $
*/
if (s.length() - index >= 2 && '$' == s.charAt(index) && '$' == s.charAt(++index)) {
pos.setIndex(index);
} }
return null; return null;
}; };
@@ -226,6 +219,7 @@ public class PropertyHelper implements GetProperty {
private final String PREFIX = "ant.refid:"; private final String PREFIX = "ant.refid:";
private final int PREFIX_LEN = PREFIX.length(); private final int PREFIX_LEN = PREFIX.length();


@Override
public Object evaluate(String prop, PropertyHelper helper) { public Object evaluate(String prop, PropertyHelper helper) {
return prop.startsWith(PREFIX) && helper.getProject() != null return prop.startsWith(PREFIX) && helper.getProject() != null
? helper.getProject().getReference(prop.substring(PREFIX_LEN)) ? helper.getProject().getReference(prop.substring(PREFIX_LEN))
@@ -279,8 +273,7 @@ public class PropertyHelper implements GetProperty {
* @since Ant 1.8.0 * @since Ant 1.8.0
*/ */
public static Object getProperty(Project project, String name) { public static Object getProperty(Project project, String name) {
return PropertyHelper.getPropertyHelper(project)
.getProperty(name);
return PropertyHelper.getPropertyHelper(project).getProperty(name);
} }


/** /**
@@ -292,8 +285,7 @@ public class PropertyHelper implements GetProperty {
* @since Ant 1.8.0 * @since Ant 1.8.0
*/ */
public static void setProperty(Project project, String name, Object value) { public static void setProperty(Project project, String name, Object value) {
PropertyHelper.getPropertyHelper(project)
.setProperty(name, value, true);
PropertyHelper.getPropertyHelper(project).setProperty(name, value, true);
} }


/** /**
@@ -304,10 +296,8 @@ public class PropertyHelper implements GetProperty {
* @param value the value to use. * @param value the value to use.
* @since Ant 1.8.0 * @since Ant 1.8.0
*/ */
public static void setNewProperty(
Project project, String name, Object value) {
PropertyHelper.getPropertyHelper(project)
.setNewProperty(name, value);
public static void setNewProperty(Project project, String name, Object value) {
PropertyHelper.getPropertyHelper(project).setNewProperty(name, value);
} }


//override facility for subclasses to put custom hashtables in //override facility for subclasses to put custom hashtables in


+ 3
- 5
src/main/org/apache/tools/ant/RuntimeConfigurable.java View File

@@ -596,11 +596,9 @@ public class RuntimeConfigurable implements Serializable {
} }


// Text // Text
if (r.characters != null) {
if (characters == null
|| characters.toString().trim().isEmpty()) {
characters = new StringBuffer(r.characters.toString());
}
if (r.characters != null
&& (characters == null || characters.toString().trim().isEmpty())) {
characters = new StringBuffer(r.characters.toString());
} }
} }
} }

+ 6
- 11
src/main/org/apache/tools/ant/UnknownElement.java View File

@@ -346,19 +346,14 @@ public class UnknownElement extends Task {
RuntimeConfigurable childWrapper = parentWrapper.getChild(i); RuntimeConfigurable childWrapper = parentWrapper.getChild(i);
UnknownElement child = it.next(); UnknownElement child = it.next();
try { try {
if (!childWrapper.isEnabled(child)) {
if (ih.supportsNestedElement(
parentUri, ProjectHelper.genComponentName(
child.getNamespace(), child.getTag()))) {
continue;
}
// fall tru and fail in handlechild (unsupported element)
// fall tru and fail in handlechild (unsupported element)
if (!childWrapper.isEnabled(child) && ih.supportsNestedElement(parentUri,
ProjectHelper.genComponentName(child.getNamespace(), child.getTag()))) {
continue;
} }
if (!handleChild(
parentUri, ih, parent, child, childWrapper)) {
if (!handleChild(parentUri, ih, parent, child, childWrapper)) {
if (!(parent instanceof TaskContainer)) { if (!(parent instanceof TaskContainer)) {
ih.throwNotSupported(getProject(), parent,
child.getTag());
ih.throwNotSupported(getProject(), parent, child.getTag());
} else { } else {
// a task container - anything could happen - just add the // a task container - anything could happen - just add the
// child to the container // child to the container


+ 8
- 10
src/main/org/apache/tools/ant/filters/ConcatFilter.java View File

@@ -113,16 +113,14 @@ public final class ConcatFilter extends BaseParamFilterReader
if (ch == -1) { if (ch == -1) {
ch = super.read(); ch = super.read();
} }
if (ch == -1) {
// don't call super.close() because that reader is used
// on other places ...
if (appendReader != null) {
ch = appendReader.read();
if (ch == -1) {
// I am the only one so I have to close the reader
appendReader.close();
appendReader = null;
}
// don't call super.close() because that reader is used
// on other places ...
if (ch == -1 && appendReader != null) {
ch = appendReader.read();
if (ch == -1) {
// I am the only one so I have to close the reader
appendReader.close();
appendReader = null;
} }
} }




+ 5
- 9
src/main/org/apache/tools/ant/filters/HeadFilter.java View File

@@ -203,17 +203,13 @@ public final class HeadFilter extends BaseParamFilterReader
*/ */
private String headFilter(String line) { private String headFilter(String line) {
linesRead++; linesRead++;
if (skip > 0) {
if ((linesRead - 1) < skip) {
return null;
}
if (skip > 0 && (linesRead - 1) < skip) {
return null;
} }


if (lines > 0) {
if (linesRead > (lines + skip)) {
eof = true;
return null;
}
if (lines > 0 && linesRead > (lines + skip)) {
eof = true;
return null;
} }
return line; return line;
} }


+ 17
- 19
src/main/org/apache/tools/ant/filters/StripJavaComments.java View File

@@ -93,32 +93,30 @@ public final class StripJavaComments
quoted = !quoted; quoted = !quoted;
} else { } else {
quoted = false; quoted = false;
if (!inString) {
if (!inString && ch == '/') {
ch = in.read();
if (ch == '/') { if (ch == '/') {
ch = in.read();
if (ch == '/') {
while (ch != '\n' && ch != -1 && ch != '\r') {
ch = in.read();
}
} else if (ch == '*') {
while (ch != -1) {
while (ch != '\n' && ch != -1 && ch != '\r') {
ch = in.read();
}
} else if (ch == '*') {
while (ch != -1) {
ch = in.read();
if (ch == '*') {
ch = in.read(); ch = in.read();
if (ch == '*') {
while (ch == '*') {
ch = in.read(); ch = in.read();
while (ch == '*') {
ch = in.read();
}
}


if (ch == '/') {
ch = read();
break;
}
if (ch == '/') {
ch = read();
break;
} }
} }
} else {
readAheadCh = ch;
ch = '/';
} }
} else {
readAheadCh = ch;
ch = '/';
} }
} }
} }


+ 3
- 5
src/main/org/apache/tools/ant/filters/TabsToSpaces.java View File

@@ -143,11 +143,9 @@ public final class TabsToSpaces
Parameter[] params = getParameters(); Parameter[] params = getParameters();
if (params != null) { if (params != null) {
for (Parameter param : params) { for (Parameter param : params) {
if (param != null) {
if (TAB_LENGTH_KEY.equals(param.getName())) {
tabLength = Integer.parseInt(param.getValue());
break;
}
if (param != null && TAB_LENGTH_KEY.equals(param.getName())) {
tabLength = Integer.parseInt(param.getValue());
break;
} }
} }
} }


+ 13
- 16
src/main/org/apache/tools/ant/helper/ProjectHelper2.java View File

@@ -728,10 +728,8 @@ public class ProjectHelper2 extends ProjectHelper {
String value = attrs.getValue(i); String value = attrs.getValue(i);
switch (attrs.getLocalName(i)) { switch (attrs.getLocalName(i)) {
case "default": case "default":
if (value != null && !value.isEmpty()) {
if (!context.isIgnoringProjectTag()) {
project.setDefault(value);
}
if (value != null && !value.isEmpty() && !context.isIgnoringProjectTag()) {
project.setDefault(value);
} }
break; break;
case "name": case "name":
@@ -741,22 +739,21 @@ public class ProjectHelper2 extends ProjectHelper {
if (!context.isIgnoringProjectTag()) { if (!context.isIgnoringProjectTag()) {
project.setName(value); project.setName(value);
project.addReference(value, project); project.addReference(value, project);
} else if (isInIncludeMode()) {
if (!value.isEmpty() && getCurrentTargetPrefix() != null
&& getCurrentTargetPrefix().endsWith(ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX)) {
String newTargetPrefix = getCurrentTargetPrefix().replace(ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX, value);
// help nested include tasks
setCurrentTargetPrefix(newTargetPrefix);
}
} else if (isInIncludeMode() && !value.isEmpty()
&& getCurrentTargetPrefix() != null
&& getCurrentTargetPrefix().endsWith(
ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX)) {
String newTargetPrefix = getCurrentTargetPrefix().replace(
ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX, value);
// help nested include tasks
setCurrentTargetPrefix(newTargetPrefix);
} }
} }
break; break;
case "id": case "id":
if (value != null) {
// What's the difference between id and name ?
if (!context.isIgnoringProjectTag()) {
project.addReference(value, project);
}
// What's the difference between id and name ?
if (value != null && !context.isIgnoringProjectTag()) {
project.addReference(value, project);
} }
break; break;
case "basedir": case "basedir":


+ 10
- 19
src/main/org/apache/tools/ant/taskdefs/Available.java View File

@@ -266,12 +266,10 @@ public class Available extends Task implements Condition {
"At least one of (classname|file|resource) is required", "At least one of (classname|file|resource) is required",
getLocation()); getLocation());
} }
if (type != null) {
if (file == null) {
throw new BuildException(
if (type != null && file == null) {
throw new BuildException(
"The type attribute is only valid when specifying the file attribute.", "The type attribute is only valid when specifying the file attribute.",
getLocation()); getLocation());
}
} }
if (classpath != null) { if (classpath != null) {
classpath.setProject(getProject()); classpath.setProject(getProject());
@@ -342,19 +340,16 @@ public class Available extends Task implements Condition {
// ** full-pathname specified == path in list // ** full-pathname specified == path in list
// ** simple name specified == path in list // ** simple name specified == path in list
if (path.exists() if (path.exists()
&& (filename.equals(p)
|| filename.equals(path.getName()))) {
&& (filename.equals(p) || filename.equals(path.getName()))) {
if (type == null) { if (type == null) {
log("Found: " + path, Project.MSG_VERBOSE); log("Found: " + path, Project.MSG_VERBOSE);
return true; return true;
} }
if (type.isDir()
&& path.isDirectory()) {
if (type.isDir() && path.isDirectory()) {
log("Found directory: " + path, Project.MSG_VERBOSE); log("Found directory: " + path, Project.MSG_VERBOSE);
return true; return true;
} }
if (type.isFile()
&& path.isFile()) {
if (type.isFile() && path.isFile()) {
log("Found file: " + path, Project.MSG_VERBOSE); log("Found file: " + path, Project.MSG_VERBOSE);
return true; return true;
} }
@@ -363,8 +358,7 @@ public class Available extends Task implements Condition {
} }
File parent = path.getParentFile(); File parent = path.getParentFile();
// ** full-pathname specified == parent dir of path in list // ** full-pathname specified == parent dir of path in list
if (parent != null && parent.exists()
&& filename.equals(parent.getAbsolutePath())) {
if (parent != null && parent.exists() && filename.equals(parent.getAbsolutePath())) {
if (type == null) { if (type == null) {
log("Found: " + parent, Project.MSG_VERBOSE); log("Found: " + parent, Project.MSG_VERBOSE);
return true; return true;
@@ -377,17 +371,14 @@ public class Available extends Task implements Condition {
return false; return false;
} }
// ** simple name specified == path in list + name // ** simple name specified == path in list + name
if (path.exists() && path.isDirectory()) {
if (checkFile(new File(path, filename),
filename + " in " + path)) {
return true;
}
if (path.exists() && path.isDirectory()
&& checkFile(new File(path, filename), filename + " in " + path)) {
return true;
} }


// ** simple name specified == parent dir + name // ** simple name specified == parent dir + name
while (searchParents && parent != null && parent.exists()) { while (searchParents && parent != null && parent.exists()) {
if (checkFile(new File(parent, filename),
filename + " in " + parent)) {
if (checkFile(new File(parent, filename), filename + " in " + parent)) {
return true; return true;
} }
parent = parent.getParentFile(); parent = parent.getParentFile();


+ 5
- 6
src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java View File

@@ -361,13 +361,12 @@ public class ExecuteOn extends ExecTask {
Vector<File> baseDirs = new Vector<>(); Vector<File> baseDirs = new Vector<>();
for (AbstractFileSet fs : filesets) { for (AbstractFileSet fs : filesets) {
String currentType = type; String currentType = type;
if (fs instanceof DirSet) {
if (!FileDirBoth.DIR.equals(type)) {
log("Found a nested dirset but type is " + type + ". "
+ "Temporarily switching to type=\"dir\" on the assumption that you really did mean <dirset> not <fileset>.",
if (fs instanceof DirSet && !FileDirBoth.DIR.equals(type)) {
log("Found a nested dirset but type is " + type + ". "
+ "Temporarily switching to type=\"dir\" on the assumption"
+ " that you really did mean <dirset> not <fileset>.",
Project.MSG_DEBUG); Project.MSG_DEBUG);
currentType = FileDirBoth.DIR;
}
currentType = FileDirBoth.DIR;
} }
File base = fs.getDir(getProject()); File base = fs.getDir(getProject());




+ 2
- 4
src/main/org/apache/tools/ant/taskdefs/Jikes.java View File

@@ -123,10 +123,8 @@ public class Jikes {
throw new BuildException("Error running Jikes compiler", e); throw new BuildException("Error running Jikes compiler", e);
} }
} finally { } finally {
if (tmpFile != null) {
if (!tmpFile.delete()) {
tmpFile.deleteOnExit();
}
if (tmpFile != null && !tmpFile.delete()) {
tmpFile.deleteOnExit();
} }
} }
} }


+ 3
- 6
src/main/org/apache/tools/ant/taskdefs/SQLExec.java View File

@@ -619,17 +619,14 @@ public class SQLExec extends JDBCTask {
sqlCommand = sqlCommand.trim(); sqlCommand = sqlCommand.trim();


try { try {
if (srcFile == null && sqlCommand.isEmpty() && resources == null) {
if (transactions.isEmpty()) {
throw new BuildException(
if (srcFile == null && sqlCommand.isEmpty() && resources == null && transactions.isEmpty()) {
throw new BuildException(
"Source file or resource collection, transactions or sql statement must be set!", "Source file or resource collection, transactions or sql statement must be set!",
getLocation()); getLocation());
}
} }


if (srcFile != null && !srcFile.isFile()) { if (srcFile != null && !srcFile.isFile()) {
throw new BuildException("Source file " + srcFile
+ " is not a file!", getLocation());
throw new BuildException("Source file " + srcFile + " is not a file!", getLocation());
} }


if (resources != null) { if (resources != null) {


+ 2
- 4
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -761,11 +761,9 @@ public class Zip extends MatchingTask {


// If we've been successful on an update, delete the // If we've been successful on an update, delete the
// temporary file // temporary file
if (doUpdate) {
if (!renamedFile.delete()) {
log("Warning: unable to delete temporary file "
if (doUpdate && !renamedFile.delete()) {
log("Warning: unable to delete temporary file "
+ renamedFile.getName(), Project.MSG_WARN); + renamedFile.getName(), Project.MSG_WARN);
}
} }
success = true; success = true;
} finally { } finally {


+ 5
- 6
src/main/org/apache/tools/ant/taskdefs/email/EmailAddress.java View File

@@ -51,12 +51,11 @@ public class EmailAddress {
int len = email.length(); int len = email.length();


// shortcut for "<address>" // shortcut for "<address>"
if (len > minLen) {
if ((email.charAt(0) == '<' || email.charAt(1) == '<')
&& (email.charAt(len - 1) == '>' || email.charAt(len - 2) == '>')) {
this.address = trim(email, true);
return;
}
if (len > minLen
&& (email.charAt(0) == '<' || email.charAt(1) == '<')
&& (email.charAt(len - 1) == '>' || email.charAt(len - 2) == '>')) {
this.address = trim(email, true);
return;
} }


int paramDepth = 0; int paramDepth = 0;


+ 10
- 17
src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java View File

@@ -305,15 +305,12 @@ public class Depend extends MatchingTask {


List<String> dependencyList = null; List<String> dependencyList = null;


if (cache != null) {
// try to read the dependency info from the map if it is
// not out of date
if (cacheFileExists
// try to read the dependency info from the map if it is not out of date
if (cache != null && cacheFileExists
&& cacheLastModified > info.absoluteFile.lastModified()) { && cacheLastModified > info.absoluteFile.lastModified()) {
// depFile exists and is newer than the class file
// need to get dependency list from the map.
dependencyList = dependencyMap.get(info.className);
}
// depFile exists and is newer than the class file
// need to get dependency list from the map.
dependencyList = dependencyMap.get(info.className);
} }


if (dependencyList == null) { if (dependencyList == null) {
@@ -512,20 +509,16 @@ public class Depend extends MatchingTask {
* @param affectedClass the name of the affected .class file * @param affectedClass the name of the affected .class file
* @param className the file that is triggering the out of dateness * @param className the file that is triggering the out of dateness
*/ */
private void warnOutOfDateButNotDeleted(
ClassFileInfo affectedClassInfo, String affectedClass,
private void warnOutOfDateButNotDeleted(ClassFileInfo affectedClassInfo, String affectedClass,
String className) { String className) {
if (affectedClassInfo.isUserWarned) { if (affectedClassInfo.isUserWarned) {
return; return;
} }
int level = Project.MSG_WARN; int level = Project.MSG_WARN;
if (!warnOnRmiStubs) {
//downgrade warnings on RMI stublike classes, as they are generated
//by rmic, so there is no need to tell the user that their source is
//missing.
if (isRmiStub(affectedClass, className)) {
level = Project.MSG_VERBOSE;
}
// downgrade warnings on RMI stublike classes, as they are generated by rmic,
// so there is no need to tell the user that their source is missing.
if (!warnOnRmiStubs && isRmiStub(affectedClass, className)) {
level = Project.MSG_VERBOSE;
} }
log("The class " + affectedClass + " in file " log("The class " + affectedClass + " in file "
+ affectedClassInfo.absoluteFile.getPath() + affectedClassInfo.absoluteFile.getPath()


+ 5
- 9
src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java View File

@@ -157,12 +157,10 @@ public class DescriptorHandler extends HandlerBase {
return; return;
} }


if (getClass().getResource(location) != null) {
if (publicId != null) {
resourceDTDs.put(publicId, location);
owningTask.log("Mapped publicId " + publicId + " to resource "
if (getClass().getResource(location) != null && publicId != null) {
resourceDTDs.put(publicId, location);
owningTask.log("Mapped publicId " + publicId + " to resource "
+ location, Project.MSG_VERBOSE); + location, Project.MSG_VERBOSE);
}
} }


try { try {
@@ -383,10 +381,8 @@ public class DescriptorHandler extends HandlerBase {
} }


// Get the value of the <ejb-name> tag. Only the first occurrence. // Get the value of the <ejb-name> tag. Only the first occurrence.
if (currentElement.equals(EJB_NAME)) {
if (ejbName == null) {
ejbName = currentText.trim();
}
if (currentElement.equals(EJB_NAME) && ejbName == null) {
ejbName = currentText.trim();
} }
} }
} }

+ 17
- 19
src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java View File

@@ -468,29 +468,27 @@ public class JonasDeploymentTool extends GenericDeploymentTool {


String baseName = null; String baseName = null;


if (getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR)) {
// try to find JOnAS specific convention name
if (getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR)
&& !descriptorFileName.contains(getConfig().baseNameTerminator)) {


// try to find JOnAS specific convention name
if (!descriptorFileName.contains(getConfig().baseNameTerminator)) {

// baseNameTerminator not found: the descriptor use the
// JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
// not [Foo<baseNameTerminator>-ejb-jar.xml,
// Foo<baseNameTerminator>-jonas-ejb-jar.xml].
// baseNameTerminator not found: the descriptor use the
// JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
// not [Foo<baseNameTerminator>-ejb-jar.xml,
// Foo<baseNameTerminator>-jonas-ejb-jar.xml].


String aCanonicalDescriptor = descriptorFileName.replace('\\', '/');
int lastSeparatorIndex = aCanonicalDescriptor.lastIndexOf('/');
int endOfBaseName;
String aCanonicalDescriptor = descriptorFileName.replace('\\', '/');
int lastSeparatorIndex = aCanonicalDescriptor.lastIndexOf('/');
int endOfBaseName;


if (lastSeparatorIndex != -1) {
endOfBaseName = descriptorFileName.indexOf(".xml", lastSeparatorIndex);
} else {
endOfBaseName = descriptorFileName.indexOf(".xml");
}
if (lastSeparatorIndex != -1) {
endOfBaseName = descriptorFileName.indexOf(".xml", lastSeparatorIndex);
} else {
endOfBaseName = descriptorFileName.indexOf(".xml");
}


if (endOfBaseName != -1) {
baseName = descriptorFileName.substring(0, endOfBaseName);
}
if (endOfBaseName != -1) {
baseName = descriptorFileName.substring(0, endOfBaseName);
} }
} }




+ 24
- 42
src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java View File

@@ -190,12 +190,11 @@ public final class Extension {
if (null == manifest) { if (null == manifest) {
return new Extension[0]; return new Extension[0];
} }
return Stream
.concat(Optional.ofNullable(manifest.getMainAttributes())
.map(Stream::of).orElse(Stream.empty()),
return Stream.concat(Optional.ofNullable(manifest.getMainAttributes())
.map(Stream::of).orElse(Stream.empty()),
manifest.getEntries().values().stream()) manifest.getEntries().values().stream())
.map(attrs -> getExtension("", attrs)).filter(Objects::nonNull)
.toArray(Extension[]::new);
.map(attrs -> getExtension("", attrs)).filter(Objects::nonNull)
.toArray(Extension[]::new);
} }


/** /**
@@ -255,15 +254,13 @@ public final class Extension {
specificationVendor); specificationVendor);
} }


final DeweyDecimal specificationVersion
= extension.getSpecificationVersion();
final DeweyDecimal specificationVersion = extension.getSpecificationVersion();
if (null != specificationVersion) { if (null != specificationVersion) {
attributes.putValue(prefix + SPECIFICATION_VERSION, attributes.putValue(prefix + SPECIFICATION_VERSION,
specificationVersion.toString()); specificationVersion.toString());
} }


final String implementationVendorID
= extension.getImplementationVendorID();
final String implementationVendorID = extension.getImplementationVendorID();
if (null != implementationVendorID) { if (null != implementationVendorID) {
attributes.putValue(prefix + IMPLEMENTATION_VENDOR_ID, attributes.putValue(prefix + IMPLEMENTATION_VENDOR_ID,
implementationVendorID); implementationVendorID);
@@ -275,8 +272,7 @@ public final class Extension {
implementationVendor); implementationVendor);
} }


final DeweyDecimal implementationVersion
= extension.getImplementationVersion();
final DeweyDecimal implementationVersion = extension.getImplementationVersion();
if (null != implementationVersion) { if (null != implementationVersion) {
attributes.putValue(prefix + IMPLEMENTATION_VERSION, attributes.putValue(prefix + IMPLEMENTATION_VERSION,
implementationVersion.toString()); implementationVersion.toString());
@@ -314,8 +310,7 @@ public final class Extension {


if (null != specificationVersion) { if (null != specificationVersion) {
try { try {
this.specificationVersion
= new DeweyDecimal(specificationVersion);
this.specificationVersion = new DeweyDecimal(specificationVersion);
} catch (final NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
final String error = "Bad specification version format '" final String error = "Bad specification version format '"
+ specificationVersion + "' in '" + extensionName + specificationVersion + "' in '" + extensionName
@@ -423,33 +418,24 @@ public final class Extension {
} }


// Available specification version must be >= required // Available specification version must be >= required
final DeweyDecimal requiredSpecificationVersion
= required.getSpecificationVersion();
if (null != requiredSpecificationVersion) {
if (null == specificationVersion
|| !isCompatible(specificationVersion, requiredSpecificationVersion)) {
return REQUIRE_SPECIFICATION_UPGRADE;
}
final DeweyDecimal requiredSpecificationVersion = required.getSpecificationVersion();
if (null != requiredSpecificationVersion && (null == specificationVersion
|| !isCompatible(specificationVersion, requiredSpecificationVersion))) {
return REQUIRE_SPECIFICATION_UPGRADE;
} }


// Implementation Vendor ID must match // Implementation Vendor ID must match
final String requiredImplementationVendorID
= required.getImplementationVendorID();
if (null != requiredImplementationVendorID) {
if (null == implementationVendorID
|| !implementationVendorID.equals(requiredImplementationVendorID)) {
return REQUIRE_VENDOR_SWITCH;
}
final String requiredImplementationVendorID = required.getImplementationVendorID();
if (null != requiredImplementationVendorID && (null == implementationVendorID
|| !implementationVendorID.equals(requiredImplementationVendorID))) {
return REQUIRE_VENDOR_SWITCH;
} }


// Implementation version must be >= required // Implementation version must be >= required
final DeweyDecimal requiredImplementationVersion
= required.getImplementationVersion();
if (null != requiredImplementationVersion) {
if (null == implementationVersion
|| !isCompatible(implementationVersion, requiredImplementationVersion)) {
return REQUIRE_IMPLEMENTATION_UPGRADE;
}
final DeweyDecimal requiredImplementationVersion = required.getImplementationVersion();
if (null != requiredImplementationVersion && (null == implementationVersion
|| !isCompatible(implementationVersion, requiredImplementationVersion))) {
return REQUIRE_IMPLEMENTATION_UPGRADE;
} }


// This available optional package satisfies the requirements // This available optional package satisfies the requirements
@@ -516,8 +502,7 @@ public final class Extension {
* @param first First version number (dotted decimal) * @param first First version number (dotted decimal)
* @param second Second version number (dotted decimal) * @param second Second version number (dotted decimal)
*/ */
private boolean isCompatible(final DeweyDecimal first,
final DeweyDecimal second) {
private boolean isCompatible(final DeweyDecimal first, final DeweyDecimal second) {
return first.isGreaterThanOrEqual(second); return first.isGreaterThanOrEqual(second);
} }


@@ -530,8 +515,7 @@ public final class Extension {
* EXTENSION_LIST or OPTIONAL_EXTENSION_LIST) * EXTENSION_LIST or OPTIONAL_EXTENSION_LIST)
* @return the list of listed extensions * @return the list of listed extensions
*/ */
private static Extension[] getListed(final Manifest manifest,
final Attributes.Name listKey) {
private static Extension[] getListed(final Manifest manifest, final Attributes.Name listKey) {
final List<Extension> results = new ArrayList<>(); final List<Extension> results = new ArrayList<>();
final Attributes mainAttributes = manifest.getMainAttributes(); final Attributes mainAttributes = manifest.getMainAttributes();


@@ -576,8 +560,7 @@ public final class Extension {
* @param onToken the token * @param onToken the token
* @return the resultant array * @return the resultant array
*/ */
private static String[] split(final String string,
final String onToken) {
private static String[] split(final String string, final String onToken) {
final StringTokenizer tokenizer = new StringTokenizer(string, onToken); final StringTokenizer tokenizer = new StringTokenizer(string, onToken);
final String[] result = new String[tokenizer.countTokens()]; final String[] result = new String[tokenizer.countTokens()];


@@ -600,8 +583,7 @@ public final class Extension {
* @param attributes Attributes to searched * @param attributes Attributes to searched
* @return the new Extension object, or null * @return the new Extension object, or null
*/ */
private static Extension getExtension(final String prefix,
final Attributes attributes) {
private static Extension getExtension(final String prefix, final Attributes attributes) {
//WARNING: We trim the values of all the attributes because //WARNING: We trim the values of all the attributes because
//Some extension declarations are badly defined (ie have spaces //Some extension declarations are badly defined (ie have spaces
//after version or vendorID) //after version or vendorID)


+ 31
- 34
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -1687,13 +1687,12 @@ public class JUnitTask extends Task {
* @since 1.9.8 * @since 1.9.8
*/ */
private void checkModules() { private void checkModules() {
if (hasPath(getCommandline().getModulepath())
|| hasPath(getCommandline().getUpgrademodulepath())) {
if (!batchTests.stream().allMatch(BaseTest::getFork)
|| !tests.stream().allMatch(BaseTest::getFork)) {
throw new BuildException(
if ((hasPath(getCommandline().getModulepath())
|| hasPath(getCommandline().getUpgrademodulepath()))
&& (!batchTests.stream().allMatch(BaseTest::getFork)
|| !tests.stream().allMatch(BaseTest::getFork))) {
throw new BuildException(
"The module path requires fork attribute to be set to true."); "The module path requires fork attribute to be set to true.");
}
} }
} }


@@ -1943,37 +1942,35 @@ public class JUnitTask extends Task {
private void createClassLoader() { private void createClassLoader() {
final Path userClasspath = getCommandline().getClasspath(); final Path userClasspath = getCommandline().getClasspath();
final Path userModulepath = getCommandline().getModulepath(); final Path userModulepath = getCommandline().getModulepath();
if (userClasspath != null || userModulepath != null) {
if (reloading || classLoader == null) {
deleteClassLoader();
final Path path = new Path(getProject());
if (userClasspath != null) {
path.add((Path) userClasspath.clone());
}
if (userModulepath != null && !hasJunit(path)) {
path.add(expandModulePath(userModulepath));
}
if (includeAntRuntime) {
log("Implicitly adding " + antRuntimeClasses
if ((userClasspath != null || userModulepath != null) && (reloading || classLoader == null)) {
deleteClassLoader();
final Path path = new Path(getProject());
if (userClasspath != null) {
path.add((Path) userClasspath.clone());
}
if (userModulepath != null && !hasJunit(path)) {
path.add(expandModulePath(userModulepath));
}
if (includeAntRuntime) {
log("Implicitly adding " + antRuntimeClasses
+ " to CLASSPATH", Project.MSG_VERBOSE); + " to CLASSPATH", Project.MSG_VERBOSE);
path.append(antRuntimeClasses);
}
classLoader = getProject().createClassLoader(path);
if (getClass().getClassLoader() != null
path.append(antRuntimeClasses);
}
classLoader = getProject().createClassLoader(path);
if (getClass().getClassLoader() != null
&& getClass().getClassLoader() != Project.class.getClassLoader()) { && getClass().getClassLoader() != Project.class.getClassLoader()) {
classLoader.setParent(getClass().getClassLoader());
}
classLoader.setParentFirst(false);
classLoader.addJavaLibraries();
log("Using CLASSPATH " + classLoader.getClasspath(),
Project.MSG_VERBOSE);
// make sure the test will be accepted as a TestCase
classLoader.addSystemPackageRoot("junit");
// make sure the test annotation are accepted
classLoader.addSystemPackageRoot("org.junit");
// will cause trouble in JDK 1.1 if omitted
classLoader.addSystemPackageRoot("org.apache.tools.ant");
classLoader.setParent(getClass().getClassLoader());
} }
classLoader.setParentFirst(false);
classLoader.addJavaLibraries();
log("Using CLASSPATH " + classLoader.getClasspath(),
Project.MSG_VERBOSE);
// make sure the test will be accepted as a TestCase
classLoader.addSystemPackageRoot("junit");
// make sure the test annotation are accepted
classLoader.addSystemPackageRoot("org.junit");
// will cause trouble in JDK 1.1 if omitted
classLoader.addSystemPackageRoot("org.apache.tools.ant");
} }
} }




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

@@ -710,26 +710,25 @@ public class FTP extends Task implements FTPTaskConfig {
boolean candidateFound = false; boolean candidateFound = false;
String target = null; String target = null;
for (int icounter = 0; icounter < array.length; icounter++) { for (int icounter = 0; icounter < array.length; icounter++) {
if (array[icounter] != null && array[icounter].isDirectory()) {
if (!".".equals(array[icounter].getName())
if (array[icounter] != null && array[icounter].isDirectory()
&& !".".equals(array[icounter].getName())
&& !"..".equals(array[icounter].getName())) { && !"..".equals(array[icounter].getName())) {
candidateFound = true;
target = fiddleName(array[icounter].getName());
getProject().log("will try to cd to "
+ target + " where a directory called " + array[icounter].getName()
+ " exists", Project.MSG_DEBUG);
for (int pcounter = 0; pcounter < array.length; pcounter++) {
if (array[pcounter] != null
candidateFound = true;
target = fiddleName(array[icounter].getName());
getProject().log("will try to cd to "
+ target + " where a directory called " + array[icounter].getName()
+ " exists", Project.MSG_DEBUG);
for (int pcounter = 0; pcounter < array.length; pcounter++) {
if (array[pcounter] != null
&& pcounter != icounter && pcounter != icounter
&& target.equals(array[pcounter].getName())) { && target.equals(array[pcounter].getName())) {
candidateFound = false;
break;
}
}
if (candidateFound) {
candidateFound = false;
break; break;
} }
} }
if (candidateFound) {
break;
}
} }
} }
if (candidateFound) { if (candidateFound) {


+ 15
- 18
src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java View File

@@ -611,26 +611,25 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
boolean candidateFound = false; boolean candidateFound = false;
String target = null; String target = null;
for (int icounter = 0; icounter < array.length; icounter++) { for (int icounter = 0; icounter < array.length; icounter++) {
if (array[icounter] != null && array[icounter].isDirectory()) {
if (!".".equals(array[icounter].getName())
if (array[icounter] != null && array[icounter].isDirectory()
&& !".".equals(array[icounter].getName())
&& !"..".equals(array[icounter].getName())) { && !"..".equals(array[icounter].getName())) {
candidateFound = true;
target = fiddleName(array[icounter].getName());
task.log("will try to cd to "
+ target + " where a directory called " + array[icounter].getName()
+ " exists", Project.MSG_DEBUG);
for (int pcounter = 0; pcounter < array.length; pcounter++) {
if (array[pcounter] != null
candidateFound = true;
target = fiddleName(array[icounter].getName());
task.log("will try to cd to "
+ target + " where a directory called " + array[icounter].getName()
+ " exists", Project.MSG_DEBUG);
for (int pcounter = 0; pcounter < array.length; pcounter++) {
if (array[pcounter] != null
&& pcounter != icounter && pcounter != icounter
&& target.equals(array[pcounter].getName())) { && target.equals(array[pcounter].getName())) {
candidateFound = false;
break;
}
}
if (candidateFound) {
candidateFound = false;
break; break;
} }
} }
if (candidateFound) {
break;
}
} }
} }
if (candidateFound) { if (candidateFound) {
@@ -1298,12 +1297,10 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
if (i >= 0) { if (i >= 0) {
String cwd = ftp.printWorkingDirectory(); String cwd = ftp.printWorkingDirectory();
String parent = dir.getParent(); String parent = dir.getParent();
if (parent != null) {
if (!ftp.changeWorkingDirectory(resolveFile(parent))) {
throw new BuildException(
if (parent != null && !ftp.changeWorkingDirectory(resolveFile(parent))) {
throw new BuildException(
"could not change to directory: %s", "could not change to directory: %s",
ftp.getReplyString()); ftp.getReplyString());
}
} }


while (i >= 0) { while (i >= 0) {


+ 4
- 8
src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java View File

@@ -134,10 +134,8 @@ public class ScpFromMessageBySftp extends ScpFromMessage {
final String remoteFile, final String remoteFile,
final File localFile) throws SftpException { final File localFile) throws SftpException {
String pwd = remoteFile; String pwd = remoteFile;
if (remoteFile.lastIndexOf('/') != -1) {
if (remoteFile.length() > 1) {
pwd = remoteFile.substring(0, remoteFile.lastIndexOf('/'));
}
if (remoteFile.lastIndexOf('/') != -1 && remoteFile.length() > 1) {
pwd = remoteFile.substring(0, remoteFile.lastIndexOf('/'));
} }
channel.cd(pwd); channel.cd(pwd);
if (!localFile.exists()) { if (!localFile.exists()) {
@@ -168,10 +166,8 @@ public class ScpFromMessageBySftp extends ScpFromMessage {
if (!localFile.exists()) { if (!localFile.exists()) {
final String path = localFile.getAbsolutePath(); final String path = localFile.getAbsolutePath();
final int i = path.lastIndexOf(File.pathSeparator); final int i = path.lastIndexOf(File.pathSeparator);
if (i != -1) {
if (path.length() > File.pathSeparator.length()) {
new File(path.substring(0, i)).mkdirs();
}
if (i != -1 && path.length() > File.pathSeparator.length()) {
new File(path.substring(0, i)).mkdirs();
} }
} }




+ 9
- 11
src/main/org/apache/tools/ant/types/resources/URLResource.java View File

@@ -145,17 +145,15 @@ public class URLResource extends Resource implements URLProvider {
if (isReference()) { if (isReference()) {
return ((URLResource) getCheckedRef()).getURL(); return ((URLResource) getCheckedRef()).getURL();
} }
if (url == null) {
if (baseURL != null) {
if (relPath == null) {
throw new BuildException("must provide relativePath"
+ " attribute when using baseURL.");
}
try {
url = new URL(baseURL, relPath);
} catch (MalformedURLException e) {
throw new BuildException(e);
}
if (url == null && baseURL != null) {
if (relPath == null) {
throw new BuildException("must provide relativePath"
+ " attribute when using baseURL.");
}
try {
url = new URL(baseURL, relPath);
} catch (MalformedURLException e) {
throw new BuildException(e);
} }
} }
return url; return url;


+ 2
- 4
src/main/org/apache/tools/ant/util/GlobPatternMapper.java View File

@@ -198,10 +198,8 @@ public class GlobPatternMapper implements FileNameMapper {
if (!caseSensitive) { if (!caseSensitive) {
name = name.toLowerCase(); name = name.toLowerCase();
} }
if (handleDirSep) {
if (name.contains("\\")) {
name = name.replace('\\', '/');
}
if (handleDirSep && name.contains("\\")) {
name = name.replace('\\', '/');
} }
return name; return name;
} }


+ 3
- 5
src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java View File

@@ -294,11 +294,9 @@ public class LayoutPreservingProperties extends Properties {
boolean writtenSep = false; boolean writtenSep = false;
for (LogicalLine line : logicalLines.subList(skipLines, totalLines)) { for (LogicalLine line : logicalLines.subList(skipLines, totalLines)) {
if (line instanceof Pair) { if (line instanceof Pair) {
if (((Pair) line).isNew()) {
if (!writtenSep) {
osw.write(eol);
writtenSep = true;
}
if (((Pair) line).isNew() && !writtenSep) {
osw.write(eol);
writtenSep = true;
} }
osw.write(line.toString() + eol); osw.write(line.toString() + eol);
} else if (line != null) { } else if (line != null) {


+ 3
- 6
src/main/org/apache/tools/ant/util/RegexpPatternMapper.java View File

@@ -118,13 +118,10 @@ public class RegexpPatternMapper implements FileNameMapper {
if (sourceFileName == null) { if (sourceFileName == null) {
return null; return null;
} }
if (handleDirSep) {
if (sourceFileName.contains("\\")) {
sourceFileName = sourceFileName.replace('\\', '/');
}
if (handleDirSep && sourceFileName.contains("\\")) {
sourceFileName = sourceFileName.replace('\\', '/');
} }
if (reg == null || to == null
|| !reg.matches(sourceFileName, regexpOptions)) {
if (reg == null || to == null || !reg.matches(sourceFileName, regexpOptions)) {
return null; return null;
} }
return new String[] {replaceReferences(sourceFileName)}; return new String[] {replaceReferences(sourceFileName)};


+ 4
- 7
src/main/org/apache/tools/tar/TarBuffer.java View File

@@ -282,11 +282,9 @@ public class TarBuffer {
offset += numBytes; offset += numBytes;
bytesNeeded -= numBytes; bytesNeeded -= numBytes;


if (numBytes != blockSize) {
if (debug) {
System.err.printf("ReadBlock: INCOMPLETE READ %d of %d bytes read.%n",
numBytes, blockSize);
}
if (numBytes != blockSize && debug) {
System.err.printf("ReadBlock: INCOMPLETE READ %d of %d bytes read.%n",
numBytes, blockSize);
} }
} }


@@ -322,8 +320,7 @@ public class TarBuffer {
*/ */
public void writeRecord(byte[] record) throws IOException { public void writeRecord(byte[] record) throws IOException {
if (debug) { if (debug) {
System.err.printf("WriteRecord: recIdx = %d blkIdx = %d%n",
currRecIdx, currBlkIdx);
System.err.printf("WriteRecord: recIdx = %d blkIdx = %d%n", currRecIdx, currBlkIdx);
} }


if (outStream == null) { if (outStream == null) {


Loading…
Cancel
Save