tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Petteys" <m...@arcticmail.com>
Subject RE: tomcat diffs
Date Mon, 01 Nov 1999 21:31:16 GMT

> Hi Matt,
>
> There are 2 problems with the WARUtil patch.
> First, it seems you use a different indentation, and that makes
> hard to detect
> the
> changes.

    public static void expand(File dir, URL war)
    throws MalformedURLException, IOException {
        String s = trim(war.getFile(), "/");
	URL u = new URL(s);
	ZipInputStream zis = new ZipInputStream(u.openStream());
	ZipEntry ze = null;

	while ((ze = zis.getNextEntry()) != null) {
-->		try {
            File f = new File(dir, ze.getName());

            if (ze.isDirectory()) {
                f.mkdirs();
	    } else {
	        byte[] buffer = new byte[1024];
		int length = 0;
	        FileOutputStream fos = new FileOutputStream(f);

		while ((length = zis.read(buffer)) >= 0) {
		    fos.write(buffer, 0, length);
		}

		fos.close();
	    }
-->		} catch (FileNotFoundException fnfe) {
-->			System.out.println("Could not find " + ze.getName() + " in " + s );
-->		}
	}

	zis.close();
    }

> Second, I don't understand where FileNotFoundException happened ?

Well, I screwed up and created a WAR file with a jar's MANIFEST file in it
and it threw this exception.  I tracked it down to this point in the code.
Without this catch, it will die w/o expanding the WAR file and print a
simple 404 out when you request files out of your WAR file.  A real pain to
debug.

Along that line, there are various places where response.sendError(404) is
called in catch clauses.  I know there isn't a logger integrated yet but
without printing out the stack there is no way to know where the errors are
occuring.  Would it make sense to print the stack out to System.out for the
time being?

mp


Mime
View raw message