ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbaill...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant Diagnostics.java
Date Mon, 04 Nov 2002 17:34:16 GMT
sbailliez    2002/11/04 09:34:16

  Modified:    src/main/org/apache/tools/ant Tag: ANT_15_BRANCH
                        Diagnostics.java
  Log:
  Fixed NPEs that could have been flying if ant.home was not defined
  PR: 14232
  Reported by: darin_swanson@oti.com (Darin Swanson)
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +11 -0     jakarta-ant/src/main/org/apache/tools/ant/Diagnostics.java
  
  Index: Diagnostics.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Diagnostics.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- Diagnostics.java	16 Jul 2002 12:56:07 -0000	1.1.2.5
  +++ Diagnostics.java	4 Nov 2002 17:34:16 -0000	1.1.2.6
  @@ -120,6 +120,9 @@
        */
       public static File[] listLibraries() {
           String home = System.getProperty("ant.home");
  +        if (home == null) {
  +            return null;
  +        }
           File libDir = new File(home, "lib");
           FilenameFilter filter = new FilenameFilter() {
               public boolean accept(File dir, String name) {
  @@ -128,6 +131,9 @@
           };
           // listFiles is JDK 1.2+ method...
           String[] filenames = libDir.list(filter);
  +        if (filenames == null) {
  +            return null;
  +        }
           File[] files = new File[filenames.length];
           for (int i = 0; i < filenames.length; i++){
               files[i] = new File(libDir, filenames[i]);
  @@ -235,7 +241,12 @@
        * @param out the stream to print the content to
        */
       private static void doReportLibraries(PrintStream out){
  +        out.println("ant.home: " + System.getProperty("ant.home"));
           File[] libs = listLibraries();
  +        if (libs == null) {
  +            out.println("Unable to list libraries.");
  +            return;
  +        }
           for (int i = 0; i < libs.length; i++){
               out.println(libs[i].getName()
                       + " (" + libs[i].length() + " bytes)");
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message