Skip to content

Commit

Permalink
Code clean-up - formatting. No functional change.
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Nov 22, 2024
1 parent 16e8292 commit c73b37c
Show file tree
Hide file tree
Showing 14 changed files with 414 additions and 604 deletions.
54 changes: 25 additions & 29 deletions java/org/apache/jasper/compiler/AntCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ protected Project getProject() {
logger.setOutputPrintStream(System.out);
logger.setErrorPrintStream(System.err);
logger.setMessageOutputLevel(Project.MSG_INFO);
project.addBuildListener( logger);
project.addBuildListener(logger);
if (System.getProperty(Constants.CATALINA_HOME_PROP) != null) {
project.setBasedir(System.getProperty(Constants.CATALINA_HOME_PROP));
}

if( options.getCompiler() != null ) {
if( log.isTraceEnabled() ) {
log.trace("Compiler " + options.getCompiler() );
if (options.getCompiler() != null) {
if (log.isTraceEnabled()) {
log.trace("Compiler " + options.getCompiler());
}
project.setProperty("build.compiler", options.getCompiler() );
project.setProperty("build.compiler", options.getCompiler());
}
project.init();
return project;
Expand All @@ -95,9 +95,7 @@ public static class JasperAntLogger extends DefaultLogger {
protected final StringBuilder reportBuf = new StringBuilder();

@Override
protected void printMessage(final String message,
final PrintStream stream,
final int priority) {
protected void printMessage(final String message, final PrintStream stream, final int priority) {
}

@Override
Expand All @@ -118,7 +116,7 @@ protected String getReport() {

@Override
protected void generateClass(Map<String,SmapStratum> smaps)
throws FileNotFoundException, JasperException, Exception {
throws FileNotFoundException, JasperException, Exception {

long t1 = 0;
if (log.isDebugEnabled()) {
Expand All @@ -131,9 +129,9 @@ protected void generateClass(Map<String,SmapStratum> smaps)

StringBuilder errorReport = new StringBuilder();

StringBuilder info=new StringBuilder();
info.append("Compile: javaFileName=" + javaFileName + "\n" );
info.append(" classpath=" + classpath + "\n" );
StringBuilder info = new StringBuilder();
info.append("Compile: javaFileName=" + javaFileName + "\n");
info.append(" classpath=" + classpath + "\n");

// Start capturing the System.err output for this thread
SystemLogHandler.setThread();
Expand All @@ -155,8 +153,7 @@ protected void generateClass(Map<String,SmapStratum> smaps)
}

if (log.isTraceEnabled()) {
log.trace( "Using classpath: " + System.getProperty("java.class.path") +
File.pathSeparator + classpath);
log.trace("Using classpath: " + System.getProperty("java.class.path") + File.pathSeparator + classpath);
}

// Initializing sourcepath
Expand All @@ -181,7 +178,7 @@ protected void generateClass(Map<String,SmapStratum> smaps)
javac.setSrcdir(srcPath);
javac.setTempdir(options.getScratchDir());
javac.setFork(ctxt.getOptions().getFork());
info.append(" srcDir=" + srcPath + "\n" );
info.append(" srcDir=" + srcPath + "\n");

// Set the Java compiler to use
if (options.getCompiler() != null) {
Expand All @@ -203,15 +200,15 @@ protected void generateClass(Map<String,SmapStratum> smaps)
PatternSet.NameEntry includes = javac.createInclude();

includes.setName(ctxt.getJavaPath());
info.append(" include="+ ctxt.getJavaPath() + "\n" );
info.append(" include=" + ctxt.getJavaPath() + "\n");

BuildException be = null;

try {
if (ctxt.getOptions().getFork()) {
javac.execute();
} else {
synchronized(javacLock) {
synchronized (javacLock) {
javac.execute();
}
}
Expand All @@ -233,24 +230,23 @@ protected void generateClass(Map<String,SmapStratum> smaps)
if (!ctxt.keepGenerated()) {
File javaFile = new File(javaFileName);
if (!javaFile.delete()) {
throw new JasperException(Localizer.getMessage(
"jsp.warning.compiler.javafile.delete.fail", javaFile));
throw new JasperException(Localizer.getMessage("jsp.warning.compiler.javafile.delete.fail", javaFile));
}
}

if (be != null) {
String errorReportString = errorReport.toString();
log.error(Localizer.getMessage("jsp.error.compilation", javaFileName, errorReportString));
JavacErrorDetail[] javacErrors = ErrorDispatcher.parseJavacErrors(
errorReportString, javaFileName, pageNodes);
JavacErrorDetail[] javacErrors =
ErrorDispatcher.parseJavacErrors(errorReportString, javaFileName, pageNodes);
if (javacErrors != null) {
errDispatcher.javacError(javacErrors);
} else {
errDispatcher.javacError(errorReportString, be);
}
}

if( log.isDebugEnabled() ) {
if (log.isDebugEnabled()) {
long t2 = System.currentTimeMillis();
log.debug(Localizer.getMessage("jsp.compiled", ctxt.getServletJavaFileName(), Long.valueOf(t2 - t1)));
}
Expand All @@ -277,6 +273,7 @@ protected static class SystemLogHandler extends PrintStream {

/**
* Construct the handler to capture the output of the given steam.
*
* @param wrapped The wrapped stream
*/
public SystemLogHandler(PrintStream wrapped) {
Expand All @@ -297,15 +294,13 @@ public SystemLogHandler(PrintStream wrapped) {
/**
* Thread &lt;-&gt; PrintStream associations.
*/
protected static final ThreadLocal<PrintStream> streams =
new ThreadLocal<>();
protected static final ThreadLocal<PrintStream> streams = new ThreadLocal<>();


/**
* Thread &lt;-&gt; ByteArrayOutputStream associations.
*/
protected static final ThreadLocal<ByteArrayOutputStream> data =
new ThreadLocal<>();
protected static final ThreadLocal<ByteArrayOutputStream> data = new ThreadLocal<>();


// --------------------------------------------------------- Public Methods
Expand All @@ -322,6 +317,7 @@ public static void setThread() {

/**
* Stop capturing thread's output and return captured data as a String.
*
* @return the captured output
*/
public static String unsetThread() {
Expand All @@ -340,6 +336,7 @@ public static String unsetThread() {

/**
* Find PrintStream to which the output must be written to.
*
* @return the current stream
*/
protected PrintStream findStream() {
Expand Down Expand Up @@ -371,7 +368,7 @@ public boolean checkError() {

@Override
protected void setError() {
//findStream().setError();
// findStream().setError();
}

@Override
Expand All @@ -380,8 +377,7 @@ public void write(int b) {
}

@Override
public void write(byte[] b)
throws IOException {
public void write(byte[] b) throws IOException {
findStream().write(b);
}

Expand Down
Loading

0 comments on commit c73b37c

Please sign in to comment.