diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java index 647fc9fa9..4626e14d7 100644 --- a/src/main/org/apache/tools/ant/Main.java +++ b/src/main/org/apache/tools/ant/Main.java @@ -246,7 +246,7 @@ public class Main implements AntMain { printMessage(be); } } catch (final Throwable exc) { - exc.printStackTrace(); + exc.printStackTrace(); //NOSONAR printMessage(exc); } finally { handleLogfile(); @@ -881,11 +881,11 @@ public class Main implements AntMain { // but if we don't, we lose valuable information System.err.println("Caught an exception while logging the" + " end of the build. Exception was:"); - t.printStackTrace(); + t.printStackTrace(); //NOSONAR if (error != null) { System.err.println("There has been an error prior to" + " that:"); - error.printStackTrace(); + error.printStackTrace(); //NOSONAR } throw new BuildException(t); //NOSONAR } diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index e9160024f..827183d29 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -873,7 +873,7 @@ public class Project implements ResourceFactory { try { setBasedir("."); } catch (final BuildException ex) { - ex.printStackTrace(); + ex.printStackTrace(); //NOSONAR } } return baseDir; diff --git a/src/main/org/apache/tools/ant/ProjectHelperRepository.java b/src/main/org/apache/tools/ant/ProjectHelperRepository.java index 1dd44124f..02ad62d85 100644 --- a/src/main/org/apache/tools/ant/ProjectHelperRepository.java +++ b/src/main/org/apache/tools/ant/ProjectHelperRepository.java @@ -108,7 +108,7 @@ public class ProjectHelperRepository { + e.getClass().getName() + ": " + e.getMessage() + ")"); if (DEBUG) { - e.printStackTrace(System.err); + e.printStackTrace(System.err); //NOSONAR } } } @@ -175,7 +175,7 @@ public class ProjectHelperRepository { + ProjectHelper.HELPER_PROPERTY + " (" + e.getMessage() + ")"); if (DEBUG) { - e.printStackTrace(System.err); + e.printStackTrace(System.err); //NOSONAR } } return null; @@ -203,7 +203,7 @@ public class ProjectHelperRepository { System.out.println("Unable to load ProjectHelper from service " + ProjectHelper.SERVICE_ID + " (" + e.getMessage() + ")"); if (DEBUG) { - e.printStackTrace(System.err); + e.printStackTrace(System.err); //NOSONAR } } return null; diff --git a/src/main/org/apache/tools/ant/filters/ReplaceTokens.java b/src/main/org/apache/tools/ant/filters/ReplaceTokens.java index 21ca3bc91..74da64a16 100644 --- a/src/main/org/apache/tools/ant/filters/ReplaceTokens.java +++ b/src/main/org/apache/tools/ant/filters/ReplaceTokens.java @@ -27,6 +27,7 @@ import java.util.Properties; import java.util.SortedMap; import java.util.TreeMap; +import org.apache.tools.ant.Project; import org.apache.tools.ant.types.Parameter; import org.apache.tools.ant.types.Resource; import org.apache.tools.ant.types.resources.FileResource; @@ -244,7 +245,11 @@ public final class ReplaceTokens in = resource.getInputStream(); props.load(in); } catch (IOException ioe) { - ioe.printStackTrace(); + if (getProject() != null) { + getProject().log("getProperties failed, " + ioe.getMessage(), Project.MSG_ERR); + } else { + ioe.printStackTrace(); //NOSONAR + } } finally { FileUtils.close(in); } diff --git a/src/main/org/apache/tools/ant/launch/Launcher.java b/src/main/org/apache/tools/ant/launch/Launcher.java index 364bc5820..534bbfb3d 100644 --- a/src/main/org/apache/tools/ant/launch/Launcher.java +++ b/src/main/org/apache/tools/ant/launch/Launcher.java @@ -117,7 +117,7 @@ public class Launcher { System.err.println(e.getMessage()); } catch (final Throwable t) { exitCode = EXIT_CODE_ERROR; - t.printStackTrace(System.err); + t.printStackTrace(System.err); //NOSONAR } if (exitCode != 0) { if (launchDiag) { @@ -297,7 +297,7 @@ public class Launcher { "Failed to locate" + mainClassname); thrown = cnfe; } catch (final Throwable t) { - t.printStackTrace(System.err); + t.printStackTrace(System.err); //NOSONAR thrown=t; } if(thrown!=null) { diff --git a/src/main/org/apache/tools/ant/listener/MailLogger.java b/src/main/org/apache/tools/ant/listener/MailLogger.java index 4b50547f3..3d5bcd235 100644 --- a/src/main/org/apache/tools/ant/listener/MailLogger.java +++ b/src/main/org/apache/tools/ant/listener/MailLogger.java @@ -177,7 +177,7 @@ public class MailLogger extends DefaultLogger { } } catch (Exception e) { System.out.println("MailLogger failed to send e-mail!"); - e.printStackTrace(System.err); + e.printStackTrace(System.err); //NOSONAR } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Execute.java b/src/main/org/apache/tools/ant/taskdefs/Execute.java index 128caa9eb..956309a6d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Execute.java +++ b/src/main/org/apache/tools/ant/taskdefs/Execute.java @@ -113,7 +113,7 @@ public class Execute { procEnvironment = System.getenv(); return procEnvironment; } catch (Exception x) { - x.printStackTrace(); + x.printStackTrace(); //NOSONAR } } @@ -162,7 +162,7 @@ public class Execute { procEnvironment.put(var.substring(0, eq), var.substring(eq + 1)); } } catch (java.io.IOException exc) { - exc.printStackTrace(); + exc.printStackTrace(); //NOSONAR // Just try to see how much we got } return procEnvironment; diff --git a/src/main/org/apache/tools/ant/taskdefs/KeySubst.java b/src/main/org/apache/tools/ant/taskdefs/KeySubst.java index 6ff67c040..28d46b9a1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/KeySubst.java +++ b/src/main/org/apache/tools/ant/taskdefs/KeySubst.java @@ -153,7 +153,7 @@ public class KeySubst extends Task { System.out.println(KeySubst.replace("$f ${VERSION} f ${b} jj $", hash)); } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(); //NOSONAR } } diff --git a/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java b/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java index ba9c9d487..bc3ff4952 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java +++ b/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java @@ -84,7 +84,7 @@ class ProcessDestroyer implements Runnable { } catch (NoSuchMethodException e) { // it just won't be added as a shutdown hook... :( } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(); //NOSONAR } } @@ -100,14 +100,14 @@ class ProcessDestroyer implements Runnable { addShutdownHookMethod.invoke(Runtime.getRuntime(), args); added = true; } catch (IllegalAccessException e) { - e.printStackTrace(); + e.printStackTrace(); //NOSONAR } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t != null && t.getClass() == IllegalStateException.class) { // shutdown already is in progress running = true; } else { - e.printStackTrace(); + e.printStackTrace(); //NOSONAR } } } @@ -129,14 +129,14 @@ class ProcessDestroyer implements Runnable { System.err.println("Could not remove shutdown hook"); } } catch (IllegalAccessException e) { - e.printStackTrace(); + e.printStackTrace(); //NOSONAR } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t != null && t.getClass() == IllegalStateException.class) { // shutdown already is in progress running = true; } else { - e.printStackTrace(); + e.printStackTrace(); //NOSONAR } } // start the hook thread, a unstarted thread may not be diff --git a/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java b/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java index dfb8e8453..a49593681 100644 --- a/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java +++ b/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java @@ -111,7 +111,7 @@ public class RecorderEntry implements BuildLogger, SubBuildListener { } else { out.println(StringUtils.LINE_SEP + "BUILD FAILED" + StringUtils.LINE_SEP); - error.printStackTrace(out); + error.printStackTrace(out); //NOSONAR } } cleanup(); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java index 7c778dae9..02106a97d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java @@ -401,7 +401,7 @@ public class PropertyFile extends Task { } catch (NullPointerException npe) { // Default to string type // which means do nothing - npe.printStackTrace(); + npe.printStackTrace(); //NOSONAR } if (newValue == null) { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java index 984fc3785..f9c2ef1aa 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java @@ -310,7 +310,7 @@ public class IPlanetEjbc { // SAXException or ParserConfigurationException may be thrown System.out.println("An exception was generated while trying to "); System.out.println("create a new SAXParser."); - e.printStackTrace(); + e.printStackTrace(); //NOSONAR return; } @@ -1484,7 +1484,7 @@ public class IPlanetEjbc { System.out.println(text); } } catch (IOException e) { - e.printStackTrace(); + e.printStackTrace(); //NOSONAR } finally { FileUtils.close(reader); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java index 0397d843e..c7d39e096 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java @@ -1023,7 +1023,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR } } } catch (final IOException e) { - e.printStackTrace(); + e.printStackTrace(); //NOSONAR } } else { final JUnitTest t = new JUnitTest(args[0]); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java b/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java index aef214fe0..d1675a801 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java @@ -109,7 +109,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { project.log("Audio format is not yet supported: " + uafe.getMessage()); } catch (IOException ioe) { - ioe.printStackTrace(); + ioe.printStackTrace(); //NOSONAR } if (audioInputStream != null) { @@ -125,7 +125,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { project.log("The sound device is currently unavailable"); return; } catch (IOException e) { - e.printStackTrace(); + e.printStackTrace(); //NOSONAR } if (duration != null) { diff --git a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java index 1446e8904..e8cf3fea4 100644 --- a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java +++ b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java @@ -137,7 +137,7 @@ public class PropertiesfileCache implements Cache { cache.load(bis); bis.close(); } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(); //NOSONAR } } // after loading the cache is up to date with the file @@ -164,7 +164,7 @@ public class PropertiesfileCache implements Cache { bos.flush(); bos.close(); } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(); //NOSONAR } } cacheDirty = false; diff --git a/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java b/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java index aed6f3717..eceb9a0b2 100644 --- a/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java +++ b/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java @@ -700,7 +700,7 @@ public class LayoutPreservingProperties extends Properties { dolly = super.clone(); } catch (final CloneNotSupportedException e) { // should be fine - e.printStackTrace(); + e.printStackTrace(); //NOSONAR } return dolly; }