Skip to content

Commit

Permalink
Fix BZ 64784. Don't include timestamp in .java file when pre-compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Oct 9, 2020
1 parent 791ef21 commit 374690d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
13 changes: 13 additions & 0 deletions java/org/apache/jasper/JspC.java
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,19 @@ public TagPluginManager getTagPluginManager() {
return tagPluginManager;
}


/**
* {@inheritDoc}
* <p>
* Hard-coded to {@code false} for pre-compiled code to enable repeatable
* builds.
*/
@Override
public boolean getGeneratedJavaAddTimestamp() {
return false;
}


/**
* Adds servlet declaration and mapping for the JSP page servlet to the
* generated web.xml fragment.
Expand Down
12 changes: 12 additions & 0 deletions java/org/apache/jasper/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,16 @@ public default String getTempVariableNamePrefix() {
public default boolean getUseInstanceManagerForTags() {
return false;
}


/**
* Should the container include the time the file was generated in the
* comments at the start of a Java file generated from a JSP or tag.
* Defaults to {@code true}.
*
* @return {@code true} to include the timestamp, otherwise don't include it
*/
public default boolean getGeneratedJavaAddTimestamp() {
return true;
}
}
6 changes: 4 additions & 2 deletions java/org/apache/jasper/compiler/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3669,8 +3669,10 @@ private void generateCommentHeader() {
out.println("/*");
out.println(" * Generated by the Jasper component of Apache Tomcat");
out.println(" * Version: " + ctxt.getServletContext().getServerInfo());
out.println(" * Generated at: " + timestampFormat.format(new Date()) +
" UTC");
if (ctxt.getOptions().getGeneratedJavaAddTimestamp()) {
out.println(" * Generated at: " + timestampFormat.format(new Date()) +
" UTC");
}
out.println(" * Note: The last modified time of this file was set to");
out.println(" * the last modified time of the source file after");
out.println(" * generation to assist with modification tracking.");
Expand Down
6 changes: 6 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
</subseciton>
<subsection name="Jasper">
<changelog>
<fix>
<bug>64784</bug>: Don't include the time the Java file was generated as
a comment when generating Java files for JSPs and/or tags if the Java
file was created during pre-compilation. This is to aid repeatable
builds. (markt)
</fix>
<fix>
<bug>64794</bug>: Security exception reading system property on
JspRuntimeLibrary use. (remm)
Expand Down

0 comments on commit 374690d

Please sign in to comment.