Browse Source

remove logging from ZipScanner.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274101 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
88f6a10229
2 changed files with 7 additions and 54 deletions
  1. +0
    -2
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  2. +7
    -52
      src/main/org/apache/tools/ant/types/ZipScanner.java

+ 0
- 2
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -665,8 +665,6 @@ public class Zip extends MatchingTask {
private synchronized ZipScanner getZipScanner() { private synchronized ZipScanner getZipScanner() {
if (zs == null) { if (zs == null) {
zs = new ZipScanner(); zs = new ZipScanner();
// set the task of the zip scanner so that it can log properly
zs.setTask(this);
zs.setSrc(zipFile); zs.setSrc(zipFile);
} }
return zs; return zs;


+ 7
- 52
src/main/org/apache/tools/ant/types/ZipScanner.java View File

@@ -64,9 +64,9 @@ import java.util.zip.ZipInputStream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipException; import java.util.zip.ZipException;


import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;


/** /**
* ZipScanner accesses the pattern matching algorithm in DirectoryScanner, * ZipScanner accesses the pattern matching algorithm in DirectoryScanner,
@@ -84,10 +84,6 @@ public class ZipScanner extends DirectoryScanner {
* The zip file which should be scanned. * The zip file which should be scanned.
*/ */
protected File srcFile; protected File srcFile;
/**
* The current task, used to report errors, ...
*/
private Task task;
/** /**
* to record the last scanned zip file with its modification date * to record the last scanned zip file with its modification date
*/ */
@@ -106,17 +102,6 @@ public class ZipScanner extends DirectoryScanner {
public void setSrc(File srcFile) { public void setSrc(File srcFile) {
this.srcFile = srcFile; this.srcFile = srcFile;
} }
/**
* Sets the current task. This is used to provide proper logging
* for exceptions
*
* @param task the current task
*
* @since Ant 1.5.2
*/
public void setTask(Task task) {
this.task = task;
}


/** /**
* Returns the names of the files which matched at least one of the * Returns the names of the files which matched at least one of the
@@ -245,25 +230,14 @@ public class ZipScanner extends DirectoryScanner {
return; return;
} }


if (task != null) {
task.log("checking zip entries: " + srcFile, Project.MSG_VERBOSE);
}

ZipEntry entry = null; ZipEntry entry = null;
ZipInputStream in = null; ZipInputStream in = null;
myentries = new Hashtable(); myentries = new Hashtable();
try { try {
try { try {
in = new ZipInputStream(new FileInputStream(srcFile)); in = new ZipInputStream(new FileInputStream(srcFile));
if (task != null) {
task.log("opening input stream from " + srcFile,
Project.MSG_DEBUG);
}
} catch (IOException ex) { } catch (IOException ex) {
// XXX - throw a BuildException instead ??
if (task != null) {
task.log("problem opening "+srcFile,Project.MSG_ERR);
}
throw new BuildException("problem opening " + srcFile, ex);
} }


while (true) { while (true) {
@@ -276,39 +250,20 @@ public class ZipScanner extends DirectoryScanner {
new Resource(entry.getName(), true, new Resource(entry.getName(), true,
entry.getTime(), entry.getTime(),
entry.isDirectory())); entry.isDirectory()));
if (task != null) {
task.log("adding entry " + entry.getName() + " from "
+ srcFile, Project.MSG_DEBUG);
}

} catch (ZipException ex) { } catch (ZipException ex) {
// XXX - throw a BuildException instead ??
if (task != null ) {
task.log("problem reading " + srcFile,
Project.MSG_ERR);
}

throw new BuildException("problem reading " + srcFile,
ex);
} catch (IOException e) { } catch (IOException e) {
// XXX - throw a BuildException instead ??
if (task != null) {
task.log("problem reading zip entry from " + srcFile,
Project.MSG_ERR);
}
throw new BuildException("problem reading zip entry from "
+ srcFile, e);
} }
} }
} finally { } finally {
if (in != null) { if (in != null) {
try { try {
in.close(); in.close();
if (task != null) {
task.log("closing input stream from " + srcFile,
Project.MSG_DEBUG);
}
} catch (IOException ex) { } catch (IOException ex) {
if (task != null) {
task.log("problem closing input stream from "
+ srcFile, Project.MSG_ERR);
}
// swallow
} }
} }
} }


Loading…
Cancel
Save