ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/jdepend JDependTask.java
Date Fri, 23 Apr 2004 16:56:20 GMT
peterreilly    2004/04/23 09:56:20

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant/taskdefs/optional/jdepend
                        JDependTask.java
  Log:
  JDependTask did not close an output file
  PR: 28557
  Obtained from: Jeff Badorek
  
  Revision  Changes    Path
  1.598     +2 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.597
  retrieving revision 1.598
  diff -u -r1.597 -r1.598
  --- WHATSNEW	23 Apr 2004 15:15:39 -0000	1.597
  +++ WHATSNEW	23 Apr 2004 16:56:20 -0000	1.598
  @@ -126,6 +126,8 @@
   * I/O-intensive processes hung when executed via <exec spawn="true">.
     Bugzilla reports 23893/26852.
   
  +* JDependTask did not close an output file. Bugzilla Report 28557.
  +
   Other changes:
   --------------
   
  
  
  
  1.32      +83 -72    ant/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
  
  Index: JDependTask.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- JDependTask.java	9 Mar 2004 16:48:30 -0000	1.31
  +++ JDependTask.java	23 Apr 2004 16:56:20 -0000	1.32
  @@ -453,8 +453,8 @@
               jdepend = new jdepend.textui.JDepend();
           }
   
  +        FileWriter fw = null;
           if (getOutputFile() != null) {
  -            FileWriter fw;
               try {
                   fw = new FileWriter(getOutputFile().getPath());
               } catch (IOException e) {
  @@ -467,87 +467,98 @@
               log("Output to be stored in " + getOutputFile().getPath());
           }
   
  -        if (getClassespath() != null) {
  -            // This is the new, better way - use classespath instead
  -            // of sourcespath.  The code is currently the same - you
  -            // need class files in a directory to use this - jar files
  -            // coming soon....
  -            String[] classesPath = getClassespath().list();
  -            for (int i = 0; i < classesPath.length; i++) {
  -                File f = new File(classesPath[i]);
  -                // not necessary as JDepend would fail, but why loose
  -                // some time?
  -                if (!f.exists() || !f.isDirectory()) {
  -                    String msg = "\""
  -                        + f.getPath()
  -                        + "\" does not represent a valid"
  -                        + " directory. JDepend would fail.";
  -                    log(msg);
  -                    throw new BuildException(msg);
  -                }
  -                try {
  -                    jdepend.addDirectory(f.getPath());
  -                } catch (IOException e) {
  -                    String msg =
  -                        "JDepend Failed when adding a class directory: "
  -                        + e.getMessage();
  -                    log(msg);
  -                    throw new BuildException(msg);
  +
  +        try {
  +            if (getClassespath() != null) {
  +                // This is the new, better way - use classespath instead
  +                // of sourcespath.  The code is currently the same - you
  +                // need class files in a directory to use this - jar files
  +                // coming soon....
  +                String[] classesPath = getClassespath().list();
  +                for (int i = 0; i < classesPath.length; i++) {
  +                    File f = new File(classesPath[i]);
  +                    // not necessary as JDepend would fail, but why loose
  +                    // some time?
  +                    if (!f.exists() || !f.isDirectory()) {
  +                        String msg = "\""
  +                            + f.getPath()
  +                            + "\" does not represent a valid"
  +                            + " directory. JDepend would fail.";
  +                        log(msg);
  +                        throw new BuildException(msg);
  +                    }
  +                    try {
  +                        jdepend.addDirectory(f.getPath());
  +                    } catch (IOException e) {
  +                        String msg =
  +                            "JDepend Failed when adding a class directory: "
  +                            + e.getMessage();
  +                        log(msg);
  +                        throw new BuildException(msg);
  +                    }
  +                }
  +
  +            } else if (getSourcespath() != null) {
  +
  +                // This is the old way and is deprecated - classespath is
  +                // the right way to do this and is above
  +                String[] sourcesPath = getSourcespath().list();
  +                for (int i = 0; i < sourcesPath.length; i++) {
  +                    File f = new File(sourcesPath[i]);
  +
  +                    // not necessary as JDepend would fail, but why loose
  +                    // some time?
  +                    if (!f.exists() || !f.isDirectory()) {
  +                        String msg = "\""
  +                            + f.getPath()
  +                            + "\" does not represent a valid"
  +                            + " directory. JDepend would fail.";
  +                        log(msg);
  +                        throw new BuildException(msg);
  +                    }
  +                    try {
  +                        jdepend.addDirectory(f.getPath());
  +                    } catch (IOException e) {
  +                        String msg =
  +                            "JDepend Failed when adding a source directory: "
  +                            + e.getMessage();
  +                        log(msg);
  +                        throw new BuildException(msg);
  +                    }
                   }
               }
   
  -        } else if (getSourcespath() != null) {
  -
  -            // This is the old way and is deprecated - classespath is
  -            // the right way to do this and is above
  -            String[] sourcesPath = getSourcespath().list();
  -            for (int i = 0; i < sourcesPath.length; i++) {
  -                File f = new File(sourcesPath[i]);
  -
  -                // not necessary as JDepend would fail, but why loose
  -                // some time?
  -                if (!f.exists() || !f.isDirectory()) {
  -                    String msg = "\""
  -                        + f.getPath()
  -                        + "\" does not represent a valid"
  -                        + " directory. JDepend would fail.";
  -                    log(msg);
  -                    throw new BuildException(msg);
  -                }
  -                try {
  -                    jdepend.addDirectory(f.getPath());
  -                } catch (IOException e) {
  -                    String msg =
  -                        "JDepend Failed when adding a source directory: "
  -                        + e.getMessage();
  -                    log(msg);
  -                    throw new BuildException(msg);
  +            // This bit turns <exclude> child tags into patters to ignore
  +            String[] patterns = defaultPatterns.getExcludePatterns(getProject());
  +            if (patterns != null && patterns.length > 0) {
  +                if (setFilter != null) {
  +                    Vector v = new Vector();
  +                    for (int i = 0; i < patterns.length; i++) {
  +                        v.addElement(patterns[i]);
  +                    }
  +                    try {
  +                        Object o = packageFilterC.newInstance(new Object[] {v});
  +                        setFilter.invoke(jdepend, new Object[] {o});
  +                    } catch (Throwable e) {
  +                        log("excludes will be ignored as JDepend doesn't like me: "
  +                            + e.getMessage(), Project.MSG_WARN);
  +                    }
  +                } else {
  +                    log("Sorry, your version of JDepend doesn't support excludes",
  +                        Project.MSG_WARN);
                   }
               }
  -        }
   
  -        // This bit turns <exclude> child tags into patters to ignore
  -        String[] patterns = defaultPatterns.getExcludePatterns(getProject());
  -        if (patterns != null && patterns.length > 0) {
  -            if (setFilter != null) {
  -                Vector v = new Vector();
  -                for (int i = 0; i < patterns.length; i++) {
  -                    v.addElement(patterns[i]);
  -                }
  +            jdepend.analyze();
  +        } finally {
  +            if (fw != null) {
                   try {
  -                    Object o = packageFilterC.newInstance(new Object[] {v});
  -                    setFilter.invoke(jdepend, new Object[] {o});
  -                } catch (Throwable e) {
  -                    log("excludes will be ignored as JDepend doesn't like me: "
  -                        + e.getMessage(), Project.MSG_WARN);
  +                    fw.close();
  +                } catch (Throwable t) {
  +                    // Ignore
                   }
  -            } else {
  -                log("Sorry, your version of JDepend doesn't support excludes",
  -                    Project.MSG_WARN);
               }
           }
  -
  -        jdepend.analyze();
           return SUCCESS;
       }
   
  
  
  

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


Mime
View raw message