@@ -52,7 +52,8 @@ public class RuntimeConfigurable implements Serializable { | |||||
private String elementTag = null; | private String elementTag = null; | ||||
/** List of child element wrappers. */ | /** List of child element wrappers. */ | ||||
private List<RuntimeConfigurable> children = null; | |||||
// picking ArrayList rather than List as arrayList is Serializable | |||||
private ArrayList<RuntimeConfigurable> children = null; | |||||
/** The element to configure. It is only used during | /** The element to configure. It is only used during | ||||
* maybeConfigure. | * maybeConfigure. | ||||
@@ -589,7 +590,7 @@ public class RuntimeConfigurable implements Serializable { | |||||
// Children (this is a shadow of UnknownElement#children) | // Children (this is a shadow of UnknownElement#children) | ||||
if (r.children != null) { | if (r.children != null) { | ||||
List<RuntimeConfigurable> newChildren = new ArrayList<RuntimeConfigurable>(); | |||||
ArrayList<RuntimeConfigurable> newChildren = new ArrayList<RuntimeConfigurable>(); | |||||
newChildren.addAll(r.children); | newChildren.addAll(r.children); | ||||
if (children != null) { | if (children != null) { | ||||
newChildren.addAll(children); | newChildren.addAll(children); | ||||
@@ -362,7 +362,7 @@ public final class SortFilter extends BaseParamFilterReader | |||||
if (reverse) { | if (reverse) { | ||||
Collections.sort(lines, new Comparator<String>() { | Collections.sort(lines, new Comparator<String>() { | ||||
public int compare(String s1, String s2) { | public int compare(String s1, String s2) { | ||||
return (-s1.compareTo(s2)); | |||||
return (-s1.compareTo(s2)); //NOSONAR | |||||
} | } | ||||
}); | }); | ||||
} else { | } else { | ||||
@@ -390,8 +390,7 @@ public class AntStructure extends Task { | |||||
} catch (final IllegalAccessException ie) { | } catch (final IllegalAccessException ie) { | ||||
sb.append("CDATA "); | sb.append("CDATA "); | ||||
} | } | ||||
} else if (type.getSuperclass() != null | |||||
&& type.getSuperclass().getName().equals("java.lang.Enum")) { | |||||
} else if (Enum.class.isAssignableFrom(type)) { | |||||
try { | try { | ||||
final Object[] values = (Object[]) type.getMethod("values", (Class[]) null) | final Object[] values = (Object[]) type.getMethod("values", (Class[]) null) | ||||
.invoke(null, (Object[]) null); | .invoke(null, (Object[]) null); | ||||
@@ -53,6 +53,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||||
private Long timeout = null; | private Long timeout = null; | ||||
private volatile Throwable caught = null; | private volatile Throwable caught = null; | ||||
private volatile boolean timedOut = false; | private volatile boolean timedOut = false; | ||||
private boolean done = false; | |||||
private Thread thread = null; | private Thread thread = null; | ||||
/** | /** | ||||
@@ -150,7 +151,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||||
+ " is not declared static"); | + " is not declared static"); | ||||
} | } | ||||
if (timeout == null) { | if (timeout == null) { | ||||
run(); | |||||
run(); //NOSONAR | |||||
} else { | } else { | ||||
thread = new Thread(this, "ExecuteJava"); | thread = new Thread(this, "ExecuteJava"); | ||||
Task currentThreadTask | Task currentThreadTask | ||||
@@ -168,7 +169,9 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||||
thread.start(); | thread.start(); | ||||
w.start(); | w.start(); | ||||
try { | try { | ||||
wait(); | |||||
while (!done) { | |||||
wait(); | |||||
} | |||||
} catch (InterruptedException e) { | } catch (InterruptedException e) { | ||||
// ignore | // ignore | ||||
} | } | ||||
@@ -228,6 +231,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||||
perm.restoreSecurityManager(); | perm.restoreSecurityManager(); | ||||
} | } | ||||
synchronized (this) { | synchronized (this) { | ||||
done = true; | |||||
notifyAll(); | notifyAll(); | ||||
} | } | ||||
} | } | ||||
@@ -243,6 +247,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||||
timedOut = true; | timedOut = true; | ||||
thread.interrupt(); | thread.interrupt(); | ||||
} | } | ||||
done = true; | |||||
notifyAll(); | notifyAll(); | ||||
} | } | ||||
@@ -1066,7 +1066,7 @@ public class Manifest { | |||||
try { | try { | ||||
write(new PrintWriter(sw)); | write(new PrintWriter(sw)); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
return null; | |||||
return ""; | |||||
} | } | ||||
return sw.toString(); | return sw.toString(); | ||||
} | } | ||||
@@ -312,7 +312,13 @@ public class Parallel extends Task | |||||
Thread timeoutThread = new Thread() { | Thread timeoutThread = new Thread() { | ||||
public synchronized void run() { | public synchronized void run() { | ||||
try { | try { | ||||
wait(timeout); | |||||
final long start = System.currentTimeMillis(); | |||||
final long end = start + timeout; | |||||
long now = System.currentTimeMillis(); | |||||
while (now < end) { | |||||
wait(end - now); | |||||
now = System.currentTimeMillis(); | |||||
} | |||||
synchronized (semaphore) { | synchronized (semaphore) { | ||||
stillRunning = false; | stillRunning = false; | ||||
timedOut = true; | timedOut = true; | ||||
@@ -352,7 +358,7 @@ public class Parallel extends Task | |||||
// System.out.println("Thread " + i + " is still | // System.out.println("Thread " + i + " is still | ||||
// alive "); | // alive "); | ||||
// still running - wait for it | // still running - wait for it | ||||
semaphore.wait(); | |||||
semaphore.wait(); //NOSONAR | |||||
continue outer2; | continue outer2; | ||||
} | } | ||||
} | } | ||||
@@ -44,21 +44,16 @@ class ChangeLogParser { | |||||
private static final int GET_REVISION = 4; | private static final int GET_REVISION = 4; | ||||
private static final int GET_PREVIOUS_REV = 5; | private static final int GET_PREVIOUS_REV = 5; | ||||
// FIXME formatters are not thread-safe | |||||
/** input format for dates read in from cvs log */ | /** input format for dates read in from cvs log */ | ||||
private static final SimpleDateFormat INPUT_DATE | |||||
private final SimpleDateFormat inputDate | |||||
= new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.US); | = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.US); | ||||
/** | /** | ||||
* New formatter used to parse CVS date/timestamp. | * New formatter used to parse CVS date/timestamp. | ||||
*/ | */ | ||||
private static final SimpleDateFormat CVS1129_INPUT_DATE = | |||||
private final SimpleDateFormat cvs1129InputDate = | |||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", Locale.US); | new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", Locale.US); | ||||
static { | static { | ||||
TimeZone utc = TimeZone.getTimeZone("UTC"); | |||||
INPUT_DATE.setTimeZone(utc); | |||||
CVS1129_INPUT_DATE.setTimeZone(utc); | |||||
} | } | ||||
//The following is data used while processing stdout of CVS command | //The following is data used while processing stdout of CVS command | ||||
@@ -102,6 +97,10 @@ class ChangeLogParser { | |||||
for (int i = 0; i < moduleNames.length; i++) { | for (int i = 0; i < moduleNames.length; i++) { | ||||
moduleNameLengths[i] = moduleNames[i].length(); | moduleNameLengths[i] = moduleNames[i].length(); | ||||
} | } | ||||
TimeZone utc = TimeZone.getTimeZone("UTC"); | |||||
inputDate.setTimeZone(utc); | |||||
cvs1129InputDate.setTimeZone(utc); | |||||
} | } | ||||
/** | /** | ||||
@@ -297,10 +296,10 @@ class ChangeLogParser { | |||||
*/ | */ | ||||
private Date parseDate(final String date) { | private Date parseDate(final String date) { | ||||
try { | try { | ||||
return INPUT_DATE.parse(date); | |||||
return inputDate.parse(date); | |||||
} catch (ParseException e) { | } catch (ParseException e) { | ||||
try { | try { | ||||
return CVS1129_INPUT_DATE.parse(date); | |||||
return cvs1129InputDate.parse(date); | |||||
} catch (ParseException e2) { | } catch (ParseException e2) { | ||||
throw new IllegalStateException("Invalid date format: " + date); | throw new IllegalStateException("Invalid date format: " + date); | ||||
} | } | ||||
@@ -34,18 +34,18 @@ import org.w3c.dom.Element; | |||||
*/ | */ | ||||
public class ChangeLogWriter { | public class ChangeLogWriter { | ||||
/** output format for dates written to xml file */ | /** output format for dates written to xml file */ | ||||
private static final SimpleDateFormat OUTPUT_DATE | |||||
private final SimpleDateFormat outputDate | |||||
= new SimpleDateFormat("yyyy-MM-dd"); | = new SimpleDateFormat("yyyy-MM-dd"); | ||||
/** output format for times written to xml file */ | /** output format for times written to xml file */ | ||||
private static final SimpleDateFormat OUTPUT_TIME | |||||
private static SimpleDateFormat outputTime | |||||
= new SimpleDateFormat("HH:mm"); | = new SimpleDateFormat("HH:mm"); | ||||
/** stateless helper for writing the XML document */ | /** stateless helper for writing the XML document */ | ||||
private static final DOMElementWriter DOM_WRITER = new DOMElementWriter(); | private static final DOMElementWriter DOM_WRITER = new DOMElementWriter(); | ||||
static { | |||||
public ChangeLogWriter() { | |||||
TimeZone utc = TimeZone.getTimeZone("UTC"); | TimeZone utc = TimeZone.getTimeZone("UTC"); | ||||
OUTPUT_DATE.setTimeZone(utc); | |||||
OUTPUT_TIME.setTimeZone(utc); | |||||
outputDate.setTimeZone(utc); | |||||
outputTime.setTimeZone(utc); | |||||
} | } | ||||
/** | /** | ||||
@@ -87,9 +87,9 @@ public class ChangeLogWriter { | |||||
final CVSEntry entry) throws IOException { | final CVSEntry entry) throws IOException { | ||||
Element ent = doc.createElement("entry"); | Element ent = doc.createElement("entry"); | ||||
DOMUtils.appendTextElement(ent, "date", | DOMUtils.appendTextElement(ent, "date", | ||||
OUTPUT_DATE.format(entry.getDate())); | |||||
outputDate.format(entry.getDate())); | |||||
DOMUtils.appendTextElement(ent, "time", | DOMUtils.appendTextElement(ent, "time", | ||||
OUTPUT_TIME.format(entry.getDate())); | |||||
outputTime.format(entry.getDate())); | |||||
DOMUtils.appendCDATAElement(ent, "author", entry.getAuthor()); | DOMUtils.appendCDATAElement(ent, "author", entry.getAuthor()); | ||||
final Enumeration enumeration = entry.getFiles().elements(); | final Enumeration enumeration = entry.getFiles().elements(); | ||||
@@ -440,6 +440,24 @@ public class EchoProperties extends Task { | |||||
Tuple that = (Tuple) o; | Tuple that = (Tuple) o; | ||||
return key.compareTo(that.key); | return key.compareTo(that.key); | ||||
} | } | ||||
@Override | |||||
public boolean equals(Object o) { | |||||
if (o == this) { | |||||
return true; | |||||
} | |||||
if (o == null || o.getClass() != getClass()) { | |||||
return false; | |||||
} | |||||
Tuple that = (Tuple) o; | |||||
return (key == null ? that.key == null : key.equals(that.key)) | |||||
&& (value == null ? that.value == null : value.equals(that.value)); | |||||
} | |||||
@Override | |||||
public int hashCode() { | |||||
return key != null ? key.hashCode() : 0; | |||||
} | |||||
} | } | ||||
private List sortProperties(Properties props) { | private List sortProperties(Properties props) { | ||||
@@ -335,7 +335,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
} | } | ||||
if (traceConfiguration != null) { | if (traceConfiguration != null) { | ||||
if ("org.apache.xalan.transformer.TransformerImpl" | |||||
if ("org.apache.xalan.transformer.TransformerImpl" //NOSONAR | |||||
.equals(transformer.getClass().getName())) { | .equals(transformer.getClass().getName())) { | ||||
try { | try { | ||||
final Class traceSupport = | final Class traceSupport = | ||||
@@ -67,7 +67,7 @@ public class KaffeRmic extends DefaultRmicAdapter { | |||||
} | } | ||||
cmd.setExecutable(c.getName()); | cmd.setExecutable(c.getName()); | ||||
if (!c.getName().equals(RMIC_CLASSNAMES[RMIC_CLASSNAMES.length - 1])) { | |||||
if (!c.getName().equals(RMIC_CLASSNAMES[RMIC_CLASSNAMES.length - 1])) { //NOSONAR | |||||
// only supported since Kaffe 1.1.2 | // only supported since Kaffe 1.1.2 | ||||
cmd.createArgument().setValue("-verbose"); | cmd.createArgument().setValue("-verbose"); | ||||
getRmic().log(Commandline.describeCommand(cmd)); | getRmic().log(Commandline.describeCommand(cmd)); | ||||
@@ -27,8 +27,7 @@ import org.apache.tools.ant.Project; | |||||
* An AntFilterReader is a wrapper class that encloses the classname | * An AntFilterReader is a wrapper class that encloses the classname | ||||
* and configuration of a Configurable FilterReader. | * and configuration of a Configurable FilterReader. | ||||
*/ | */ | ||||
public final class AntFilterReader | |||||
extends DataType implements Cloneable { | |||||
public final class AntFilterReader extends DataType { | |||||
private String className; | private String className; | ||||
@@ -45,8 +45,7 @@ import org.apache.tools.ant.filters.TokenFilter; | |||||
* FilterChain may contain a chained set of filter readers. | * FilterChain may contain a chained set of filter readers. | ||||
* | * | ||||
*/ | */ | ||||
public class FilterChain extends DataType | |||||
implements Cloneable { | |||||
public class FilterChain extends DataType { | |||||
private Vector<Object> filterReaders = new Vector<Object>(); | private Vector<Object> filterReaders = new Vector<Object>(); | ||||
@@ -30,7 +30,7 @@ import org.apache.tools.ant.util.FileNameMapper; | |||||
* Element to define a FileNameMapper. | * Element to define a FileNameMapper. | ||||
* | * | ||||
*/ | */ | ||||
public class Mapper extends DataType implements Cloneable { | |||||
public class Mapper extends DataType { | |||||
// CheckStyle:VisibilityModifier OFF - bc | // CheckStyle:VisibilityModifier OFF - bc | ||||
protected MapperType type = null; | protected MapperType type = null; | ||||
@@ -302,7 +302,7 @@ public class Permissions { | |||||
* @param perm The permission to check against. | * @param perm The permission to check against. | ||||
*/ | */ | ||||
boolean matches(final java.security.Permission perm) { | boolean matches(final java.security.Permission perm) { | ||||
if (!className.equals(perm.getClass().getName())) { | |||||
if (!className.equals(perm.getClass().getName())) { //NOSONAR | |||||
return false; | return false; | ||||
} | } | ||||
if (name != null) { | if (name != null) { | ||||
@@ -119,7 +119,7 @@ import org.xml.sax.XMLReader; | |||||
* | * | ||||
*/ | */ | ||||
public class XMLCatalog extends DataType | public class XMLCatalog extends DataType | ||||
implements Cloneable, EntityResolver, URIResolver { | |||||
implements EntityResolver, URIResolver { | |||||
/** helper for some File.toURL connversions */ | /** helper for some File.toURL connversions */ | ||||
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | ||||
@@ -216,7 +216,7 @@ public abstract class ArchiveResource extends Resource { | |||||
if (isReference()) { | if (isReference()) { | ||||
return getCheckedRef().equals(another); | return getCheckedRef().equals(another); | ||||
} | } | ||||
if (another == null || !(another.getClass().equals(getClass()))) { | |||||
if (another == null || another.getClass() != getClass()) { | |||||
return false; | return false; | ||||
} | } | ||||
ArchiveResource r = (ArchiveResource) another; | ArchiveResource r = (ArchiveResource) another; | ||||
@@ -95,7 +95,7 @@ public class MappedResource extends ResourceDecorator { | |||||
*/ | */ | ||||
@Override | @Override | ||||
public boolean equals(Object other) { | public boolean equals(Object other) { | ||||
if (other == null || !other.getClass().equals(getClass())) { | |||||
if (other == null || other.getClass() != getClass()) { | |||||
return false; | return false; | ||||
} | } | ||||
MappedResource m = (MappedResource) other; | MappedResource m = (MappedResource) other; | ||||
@@ -74,6 +74,7 @@ public abstract class ResourceDecorator extends Resource { | |||||
* Get the name of the resource. | * Get the name of the resource. | ||||
* @return the name of the wrapped resource. | * @return the name of the wrapped resource. | ||||
*/ | */ | ||||
@Override | |||||
public String getName() { | public String getName() { | ||||
return getResource().getName(); | return getResource().getName(); | ||||
} | } | ||||
@@ -82,6 +83,7 @@ public abstract class ResourceDecorator extends Resource { | |||||
* The exists attribute tells whether a file exists. | * The exists attribute tells whether a file exists. | ||||
* @return true if this resource exists. | * @return true if this resource exists. | ||||
*/ | */ | ||||
@Override | |||||
public boolean isExists() { | public boolean isExists() { | ||||
return getResource().isExists(); | return getResource().isExists(); | ||||
} | } | ||||
@@ -92,6 +94,7 @@ public abstract class ResourceDecorator extends Resource { | |||||
* @return 0 if the resource does not exist to mirror the behavior | * @return 0 if the resource does not exist to mirror the behavior | ||||
* of {@link java.io.File File}. | * of {@link java.io.File File}. | ||||
*/ | */ | ||||
@Override | |||||
public long getLastModified() { | public long getLastModified() { | ||||
return getResource().getLastModified(); | return getResource().getLastModified(); | ||||
} | } | ||||
@@ -100,6 +103,7 @@ public abstract class ResourceDecorator extends Resource { | |||||
* Tells if the resource is a directory. | * Tells if the resource is a directory. | ||||
* @return boolean flag indicating if the resource is a directory. | * @return boolean flag indicating if the resource is a directory. | ||||
*/ | */ | ||||
@Override | |||||
public boolean isDirectory() { | public boolean isDirectory() { | ||||
return getResource().isDirectory(); | return getResource().isDirectory(); | ||||
} | } | ||||
@@ -109,6 +113,7 @@ public abstract class ResourceDecorator extends Resource { | |||||
* @return the size, as a long, 0 if the Resource does not exist (for | * @return the size, as a long, 0 if the Resource does not exist (for | ||||
* compatibility with java.io.File), or UNKNOWN_SIZE if not known. | * compatibility with java.io.File), or UNKNOWN_SIZE if not known. | ||||
*/ | */ | ||||
@Override | |||||
public long getSize() { | public long getSize() { | ||||
return getResource().getSize(); | return getResource().getSize(); | ||||
} | } | ||||
@@ -121,6 +126,7 @@ public abstract class ResourceDecorator extends Resource { | |||||
* @throws UnsupportedOperationException if InputStreams are not | * @throws UnsupportedOperationException if InputStreams are not | ||||
* supported for this Resource type. | * supported for this Resource type. | ||||
*/ | */ | ||||
@Override | |||||
public InputStream getInputStream() throws IOException { | public InputStream getInputStream() throws IOException { | ||||
return getResource().getInputStream(); | return getResource().getInputStream(); | ||||
} | } | ||||
@@ -133,6 +139,7 @@ public abstract class ResourceDecorator extends Resource { | |||||
* @throws UnsupportedOperationException if OutputStreams are not | * @throws UnsupportedOperationException if OutputStreams are not | ||||
* supported for this Resource type. | * supported for this Resource type. | ||||
*/ | */ | ||||
@Override | |||||
public OutputStream getOutputStream() throws IOException { | public OutputStream getOutputStream() throws IOException { | ||||
return getResource().getOutputStream(); | return getResource().getOutputStream(); | ||||
} | } | ||||
@@ -141,6 +148,7 @@ public abstract class ResourceDecorator extends Resource { | |||||
* Fulfill the ResourceCollection contract. | * Fulfill the ResourceCollection contract. | ||||
* @return whether this Resource is a FileProvider. | * @return whether this Resource is a FileProvider. | ||||
*/ | */ | ||||
@Override | |||||
public boolean isFilesystemOnly() { | public boolean isFilesystemOnly() { | ||||
return as(FileProvider.class) != null; | return as(FileProvider.class) != null; | ||||
} | } | ||||
@@ -149,6 +157,7 @@ public abstract class ResourceDecorator extends Resource { | |||||
* Overrides the base version. | * Overrides the base version. | ||||
* @param r the Reference to set. | * @param r the Reference to set. | ||||
*/ | */ | ||||
@Override | |||||
public void setRefid(Reference r) { | public void setRefid(Reference r) { | ||||
if (resource != null) { | if (resource != null) { | ||||
throw noChildrenAllowed(); | throw noChildrenAllowed(); | ||||
@@ -159,6 +168,7 @@ public abstract class ResourceDecorator extends Resource { | |||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
@Override | |||||
public <T> T as(Class<T> clazz) { | public <T> T as(Class<T> clazz) { | ||||
return getResource().as(clazz); | return getResource().as(clazz); | ||||
} | } | ||||
@@ -166,6 +176,7 @@ public abstract class ResourceDecorator extends Resource { | |||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
@Override | |||||
public int compareTo(Resource other) { | public int compareTo(Resource other) { | ||||
if (other == this) { | if (other == this) { | ||||
return 0; | return 0; | ||||
@@ -181,7 +192,9 @@ public abstract class ResourceDecorator extends Resource { | |||||
* Get the hash code for this Resource. | * Get the hash code for this Resource. | ||||
* @return hash code as int. | * @return hash code as int. | ||||
*/ | */ | ||||
public int hashCode() { | |||||
@Override | |||||
public int hashCode() { // NOSONAR | |||||
// super.equals + compareTo are consistent with this implementation | |||||
return (getClass().hashCode() << 4) | getResource().hashCode(); | return (getClass().hashCode() << 4) | getResource().hashCode(); | ||||
} | } | ||||
@@ -267,4 +280,5 @@ public abstract class ResourceDecorator extends Resource { | |||||
throw new BuildException("you can't change the size of a " | throw new BuildException("you can't change the size of a " | ||||
+ getDataTypeName()); | + getDataTypeName()); | ||||
} | } | ||||
} | } |
@@ -71,6 +71,7 @@ public class StringResource extends Resource { | |||||
* Enforce String immutability. | * Enforce String immutability. | ||||
* @param s the new name/value for this StringResource. | * @param s the new name/value for this StringResource. | ||||
*/ | */ | ||||
@Override | |||||
public synchronized void setName(String s) { | public synchronized void setName(String s) { | ||||
if (getName() != null) { | if (getName() != null) { | ||||
throw new BuildException(new ImmutableResourceException()); | throw new BuildException(new ImmutableResourceException()); | ||||
@@ -90,6 +91,7 @@ public class StringResource extends Resource { | |||||
* Synchronize access. | * Synchronize access. | ||||
* @return the name/value of this StringResource. | * @return the name/value of this StringResource. | ||||
*/ | */ | ||||
@Override | |||||
public synchronized String getName() { | public synchronized String getName() { | ||||
return super.getName(); | return super.getName(); | ||||
} | } | ||||
@@ -107,6 +109,7 @@ public class StringResource extends Resource { | |||||
* | * | ||||
* @return true if this resource exists. | * @return true if this resource exists. | ||||
*/ | */ | ||||
@Override | |||||
public boolean isExists() { | public boolean isExists() { | ||||
return getValue() != null; | return getValue() != null; | ||||
} | } | ||||
@@ -144,6 +147,7 @@ public class StringResource extends Resource { | |||||
* @return the size, as a long, 0 if the Resource does not exist (for | * @return the size, as a long, 0 if the Resource does not exist (for | ||||
* compatibility with java.io.File), or UNKNOWN_SIZE if not known. | * compatibility with java.io.File), or UNKNOWN_SIZE if not known. | ||||
*/ | */ | ||||
@Override | |||||
public synchronized long getSize() { | public synchronized long getSize() { | ||||
return isReference() ? ((Resource) getCheckedRef()).getSize() | return isReference() ? ((Resource) getCheckedRef()).getSize() | ||||
: getContent().length(); | : getContent().length(); | ||||
@@ -153,7 +157,9 @@ public class StringResource extends Resource { | |||||
* Get the hash code for this Resource. | * Get the hash code for this Resource. | ||||
* @return hash code as int. | * @return hash code as int. | ||||
*/ | */ | ||||
@Override | |||||
public synchronized int hashCode() { | public synchronized int hashCode() { | ||||
// super.equals + super.compareTo are consistent with this implementation | |||||
if (isReference()) { | if (isReference()) { | ||||
return getCheckedRef().hashCode(); | return getCheckedRef().hashCode(); | ||||
} | } | ||||
@@ -166,6 +172,7 @@ public class StringResource extends Resource { | |||||
* @return the string contents of the resource. | * @return the string contents of the resource. | ||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
@Override | |||||
public String toString() { | public String toString() { | ||||
return String.valueOf(getContent()); | return String.valueOf(getContent()); | ||||
} | } | ||||
@@ -178,6 +185,7 @@ public class StringResource extends Resource { | |||||
* @throws UnsupportedOperationException if InputStreams are not | * @throws UnsupportedOperationException if InputStreams are not | ||||
* supported for this Resource type. | * supported for this Resource type. | ||||
*/ | */ | ||||
@Override | |||||
public synchronized InputStream getInputStream() throws IOException { | public synchronized InputStream getInputStream() throws IOException { | ||||
if (isReference()) { | if (isReference()) { | ||||
return ((Resource) getCheckedRef()).getInputStream(); | return ((Resource) getCheckedRef()).getInputStream(); | ||||
@@ -198,6 +206,7 @@ public class StringResource extends Resource { | |||||
* @throws UnsupportedOperationException if OutputStreams are not | * @throws UnsupportedOperationException if OutputStreams are not | ||||
* supported for this Resource type. | * supported for this Resource type. | ||||
*/ | */ | ||||
@Override | |||||
public synchronized OutputStream getOutputStream() throws IOException { | public synchronized OutputStream getOutputStream() throws IOException { | ||||
if (isReference()) { | if (isReference()) { | ||||
return ((Resource) getCheckedRef()).getOutputStream(); | return ((Resource) getCheckedRef()).getOutputStream(); | ||||
@@ -212,6 +221,7 @@ public class StringResource extends Resource { | |||||
* Overrides the super version. | * Overrides the super version. | ||||
* @param r the Reference to set. | * @param r the Reference to set. | ||||
*/ | */ | ||||
@Override | |||||
public void setRefid(Reference r) { | public void setRefid(Reference r) { | ||||
if (encoding != DEFAULT_ENCODING) { | if (encoding != DEFAULT_ENCODING) { | ||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
@@ -250,6 +260,7 @@ public class StringResource extends Resource { | |||||
baos = (ByteArrayOutputStream) out; | baos = (ByteArrayOutputStream) out; | ||||
} | } | ||||
@Override | |||||
public void close() throws IOException { | public void close() throws IOException { | ||||
super.close(); | super.close(); | ||||
String result = encoding == null | String result = encoding == null | ||||
@@ -313,7 +313,7 @@ public class URLResource extends Resource implements URLProvider { | |||||
if (isReference()) { | if (isReference()) { | ||||
return getCheckedRef().equals(another); | return getCheckedRef().equals(another); | ||||
} | } | ||||
if (another == null || !(another.getClass().equals(getClass()))) { | |||||
if (another == null || another.getClass() != getClass()) { | |||||
return false; | return false; | ||||
} | } | ||||
URLResource otheru = (URLResource) another; | URLResource otheru = (URLResource) another; | ||||
@@ -143,8 +143,14 @@ public class OutputStreamFunneler { | |||||
if (!funnel.closed) { | if (!funnel.closed) { | ||||
try { | try { | ||||
if (timeoutMillis > 0) { | if (timeoutMillis > 0) { | ||||
final long start = System.currentTimeMillis(); | |||||
final long end = start + timeoutMillis; | |||||
long now = System.currentTimeMillis(); | |||||
try { | try { | ||||
wait(timeoutMillis); | |||||
while (now < end) { | |||||
wait(end - now); | |||||
now = System.currentTimeMillis(); | |||||
} | |||||
} catch (InterruptedException eyeEx) { | } catch (InterruptedException eyeEx) { | ||||
//ignore | //ignore | ||||
} | } | ||||
@@ -72,7 +72,7 @@ public class ResourceUtils { | |||||
*/ | */ | ||||
public static final String ISO_8859_1 = "ISO-8859-1"; | public static final String ISO_8859_1 = "ISO-8859-1"; | ||||
private static final long MAX_IO_CHUNK_SIZE = 16*1024*1024; // 16 MB | |||||
private static final long MAX_IO_CHUNK_SIZE = 16*1024*1024l; // 16 MB | |||||
/** | /** | ||||
* Tells which source files should be reprocessed based on the | * Tells which source files should be reprocessed based on the | ||||
@@ -630,7 +630,7 @@ public class ResourceUtils { | |||||
} | } | ||||
expected = in1.readLine(); | expected = in1.readLine(); | ||||
} | } | ||||
return in2.readLine() == null ? 0 : -1; | |||||
return in2.readLine() == null ? 0 : -1; //NOSONAR | |||||
} finally { | } finally { | ||||
FileUtils.close(in1); | FileUtils.close(in1); | ||||
FileUtils.close(in2); | FileUtils.close(in2); | ||||
@@ -117,9 +117,13 @@ public class WorkerAnt extends Thread { | |||||
* @throws InterruptedException if the execution was interrupted | * @throws InterruptedException if the execution was interrupted | ||||
*/ | */ | ||||
public void waitUntilFinished(long timeout) throws InterruptedException { | public void waitUntilFinished(long timeout) throws InterruptedException { | ||||
final long start = System.currentTimeMillis(); | |||||
final long end = start + timeout; | |||||
synchronized (notify) { | synchronized (notify) { | ||||
if (!finished) { | |||||
notify.wait(timeout); | |||||
long now = System.currentTimeMillis(); | |||||
while (!finished && now < end) { | |||||
notify.wait(end - now); | |||||
now = System.currentTimeMillis(); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -975,7 +975,7 @@ class BlockSort { | |||||
runningOrder[i] = i; | runningOrder[i] = i; | ||||
} | } | ||||
for (int h = 364; h != 1;) { | |||||
for (int h = 364; h != 1;) { //NOSONAR | |||||
h /= 3; | h /= 3; | ||||
for (int i = h; i <= 255; i++) { | for (int i = h; i <= 255; i++) { | ||||
final int vv = runningOrder[i]; | final int vv = runningOrder[i]; | ||||
@@ -191,7 +191,7 @@ public class TarUtils { | |||||
if (negative) { | if (negative) { | ||||
// 2's complement | // 2's complement | ||||
val--; | val--; | ||||
val ^= (long) Math.pow(2, (length - 1) * 8) - 1; | |||||
val ^= (long) Math.pow(2, (length - 1) * 8.0) - 1; | |||||
} | } | ||||
return negative ? -val : val; | return negative ? -val : val; | ||||
} | } | ||||
@@ -28,8 +28,8 @@ import java.util.zip.ZipException; | |||||
public class UnsupportedZipFeatureException extends ZipException { | public class UnsupportedZipFeatureException extends ZipException { | ||||
private final Feature reason; | private final Feature reason; | ||||
private final ZipEntry entry; | |||||
private static final long serialVersionUID = 4430521921766595597L; | |||||
private transient final ZipEntry entry; | |||||
private static final long serialVersionUID = 20161221L; | |||||
/** | /** | ||||
* Creates an exception. | * Creates an exception. | ||||
@@ -61,7 +61,7 @@ public class UnsupportedZipFeatureException extends ZipException { | |||||
/** | /** | ||||
* ZIP Features that may or may not be supported. | * ZIP Features that may or may not be supported. | ||||
*/ | */ | ||||
public static class Feature { | |||||
public static class Feature implements java.io.Serializable { | |||||
/** | /** | ||||
* The entry is encrypted. | * The entry is encrypted. | ||||
*/ | */ | ||||
@@ -86,4 +86,4 @@ public class UnsupportedZipFeatureException extends ZipException { | |||||
return name; | return name; | ||||
} | } | ||||
} | } | ||||
} | |||||
} |