Bug 28603 - JspC Ant task does not detect errors on a second compile
Summary: JspC Ant task does not detect errors on a second compile
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 5.0.19
Hardware: All Windows XP
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-26 17:26 UTC by Petr Jiricka
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments
The test application which reproduces this issue. (1.41 KB, application/octet-stream)
2004-05-06 13:00 UTC, Petr Jiricka
Details
Patch that works for me. (903 bytes, patch)
2004-05-10 14:02 UTC, Petr Jiricka
Details | Diff
Set 'writer' to NULL, so it won't be closed again in finally (867 bytes, patch)
2004-05-10 16:27 UTC, Jan Luehe
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2004-04-26 17:26:23 UTC
1. Set up an application with an Ant script to compile JSPs as recommended at
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jasper-howto.html
2. Write a JSP which contains erroneous text such that the first phase (JSP ->
Java translation) fails e.g. by including <jsp:include x="50"/> in the page.
3. Compile the application using the Ant script - a Jasper exception will be
reported.
4. Compile the application again - build will succeed despite the error.
Comment 1 Jan Luehe 2004-04-27 18:15:53 UTC
Fixed by removing empty .java file (that was generated by "new
FileOutputStream()") if parser/validator/generator throws exception.
Comment 2 Petr Jiricka 2004-05-06 12:59:10 UTC
I must say this still does not work for me in Tomcat 5.0.24. I am attaching an
application which reproduces this issue. To reproduce:

1. Unzip the attached testApp.zip
2. Modify the build.properties file from testApp.zip to point to a Tomcat 5.0.24
installation
3. In the root directory of this test application, run Ant twice (I am using Ant
1.6.1). The first time you run Ant, a compilation error is reported, but the
second time it is not and build succeeds.

Thanks for looking at this.
Comment 3 Petr Jiricka 2004-05-06 13:00:06 UTC
Created attachment 11444 [details]
The test application which reproduces this issue.
Comment 4 Jan Luehe 2004-05-06 22:44:13 UTC
Hmm, this works for me (on UNIX).

Do you see an empty JSP_jsp.java file being generated in your project's "build"
directory? Such a file used to be generated, but my fix should have deleted it
(using File.delete()).
Comment 5 Petr Jiricka 2004-05-07 16:38:18 UTC
Ok, I'll look at this over the weekend and debug it on my side.
Comment 6 Petr Jiricka 2004-05-10 14:01:27 UTC
I found out where the problem is: When the file is deleted, the outputstream
that writes this file is still open, so the delete operation fails on Windows.
The stream is closed too late. I will attach a patch that fixes this on my machine.

Comment 7 Petr Jiricka 2004-05-10 14:02:38 UTC
Created attachment 11489 [details]
Patch that works for me.
Comment 8 Jan Luehe 2004-05-10 16:27:28 UTC
Created attachment 11499 [details]
Set 'writer' to NULL, so it won't be closed again in finally
Comment 9 Jan Luehe 2004-05-10 16:28:58 UTC
Thanks for investigating, Petr!

I've applied your patch, which I slightly modified by setting 'writer' to NULL
after closing it in the exception handling code you added, so that it won't be
closed again in the finally.

Modified patch attached.
Comment 10 Petr Jiricka 2004-05-10 17:54:17 UTC
Thanks!