@@ -355,7 +355,10 @@ public class Main implements AntMain { | |||||
try { | try { | ||||
final File logFile = new File(args[i + 1]); | final File logFile = new File(args[i + 1]); | ||||
i++; | i++; | ||||
logTo = new PrintStream(new FileOutputStream(logFile)); | |||||
// life-cycle of FileOutputStream is controlled by | |||||
// logTo which becomes "out" and is closed in | |||||
// handleLogfile | |||||
logTo = new PrintStream(new FileOutputStream(logFile)); //NOSONAR | |||||
isLogFileUsed = true; | isLogFileUsed = true; | ||||
} catch (final IOException ioe) { | } catch (final IOException ioe) { | ||||
final String msg = "Cannot write on the specified log file. " | final String msg = "Cannot write on the specified log file. " | ||||
@@ -167,7 +167,7 @@ public class Truncate extends Task { | |||||
} | } | ||||
RandomAccessFile raf = null; | RandomAccessFile raf = null; | ||||
try { | try { | ||||
raf = new RandomAccessFile(f, READ_WRITE); | |||||
raf = new RandomAccessFile(f, READ_WRITE); //NOSONAR | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
throw new BuildException("Could not open " + f + " for writing", e); | throw new BuildException("Could not open " + f + " for writing", e); | ||||
} | } | ||||
@@ -202,4 +202,4 @@ public class Truncate extends Task { | |||||
return path; | return path; | ||||
} | } | ||||
} | |||||
} |
@@ -299,7 +299,7 @@ public class CvsTagDiff extends AbstractCvsTask { | |||||
BufferedReader reader = null; | BufferedReader reader = null; | ||||
try { | try { | ||||
reader = new BufferedReader(new FileReader(tmpFile)); | |||||
reader = new BufferedReader(new FileReader(tmpFile)); //NOSONAR | |||||
// entries are of the form: | // entries are of the form: | ||||
//CVS 1.11 | //CVS 1.11 | ||||
@@ -260,7 +260,7 @@ public class PropertyFile extends Task { | |||||
throw new BuildException(x, getLocation()); | throw new BuildException(x, getLocation()); | ||||
} | } | ||||
try { | try { | ||||
OutputStream os = new FileOutputStream(propertyfile); | |||||
OutputStream os = new FileOutputStream(propertyfile); //NOSONAR | |||||
try { | try { | ||||
try { | try { | ||||
os.write(baos.toByteArray()); | os.write(baos.toByteArray()); | ||||
@@ -727,7 +727,8 @@ public class IPlanetEjbc { | |||||
} else { | } else { | ||||
location = (String) fileDtds.get(publicId); | location = (String) fileDtds.get(publicId); | ||||
if (location != null) { | if (location != null) { | ||||
inputStream = new FileInputStream(location); | |||||
// closed when the InputSource is closed | |||||
inputStream = new FileInputStream(location); //NOSONAR | |||||
} | } | ||||
} | } | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
@@ -459,7 +459,7 @@ public class JDependTask extends Task { | |||||
PrintWriter pw = null; | PrintWriter pw = null; | ||||
if (getOutputFile() != null) { | if (getOutputFile() != null) { | ||||
try { | try { | ||||
fw = new FileWriter(getOutputFile().getPath()); | |||||
fw = new FileWriter(getOutputFile().getPath()); //NOSONAR | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
String msg = "JDepend Failed when creating the output file: " | String msg = "JDepend Failed when creating the output file: " | ||||
+ e.getMessage(); | + e.getMessage(); | ||||
@@ -184,7 +184,7 @@ public class ContainsRegexpSelector extends BaseExtendSelector | |||||
} | } | ||||
try { | try { | ||||
in = new BufferedReader(new InputStreamReader(r.getInputStream())); | |||||
in = new BufferedReader(new InputStreamReader(r.getInputStream())); //NOSONAR | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
throw new BuildException("Could not get InputStream from " | throw new BuildException("Could not get InputStream from " | ||||
+ r.toLongString(), e); | + r.toLongString(), e); | ||||
@@ -187,9 +187,9 @@ public class ContainsSelector extends BaseExtendSelector implements ResourceSele | |||||
BufferedReader in = null; | BufferedReader in = null; | ||||
try { | try { | ||||
if (encoding != null) { | if (encoding != null) { | ||||
in = new BufferedReader(new InputStreamReader(r.getInputStream(), encoding)); | |||||
in = new BufferedReader(new InputStreamReader(r.getInputStream(), encoding)); //NOSONAR | |||||
} else { | } else { | ||||
in = new BufferedReader(new InputStreamReader(r.getInputStream())); | |||||
in = new BufferedReader(new InputStreamReader(r.getInputStream())); //NOSONAR | |||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
throw new BuildException("Could not get InputStream from " | throw new BuildException("Could not get InputStream from " | ||||
@@ -1708,7 +1708,7 @@ public class FileUtils { | |||||
*/ | */ | ||||
public String getDefaultEncoding() { | public String getDefaultEncoding() { | ||||
InputStreamReader is = new InputStreamReader( | InputStreamReader is = new InputStreamReader( | ||||
new InputStream() { | |||||
new InputStream() { //NOSONAR | |||||
public int read() { | public int read() { | ||||
return -1; | return -1; | ||||
} | } | ||||
@@ -370,8 +370,10 @@ public class ZipFile implements Closeable { | |||||
final OffsetEntry offsetEntry = ((Entry) ze).getOffsetEntry(); | final OffsetEntry offsetEntry = ((Entry) ze).getOffsetEntry(); | ||||
ZipUtil.checkRequestedFeatures(ze); | ZipUtil.checkRequestedFeatures(ze); | ||||
final long start = offsetEntry.dataOffset; | final long start = offsetEntry.dataOffset; | ||||
// doesn't get closed if the method is not supported, but | |||||
// doesn't hold any resources either | |||||
final BoundedInputStream bis = | final BoundedInputStream bis = | ||||
new BoundedInputStream(start, ze.getCompressedSize()); | |||||
new BoundedInputStream(start, ze.getCompressedSize()); //NOSONAR | |||||
switch (ze.getMethod()) { | switch (ze.getMethod()) { | ||||
case ZipEntry.STORED: | case ZipEntry.STORED: | ||||
return bis; | return bis; | ||||