From a76e7f7223a9ea49a6fe0cd4b785f9ad0bd39312 Mon Sep 17 00:00:00 2001 From: Stephen Joyner Date: Fri, 1 Mar 2019 16:15:28 -0600 Subject: [PATCH] Fix #4497 appending to output stream fails on Tomcat 7 without compile static annotation. --- .../controllers/ExecutionController.groovy | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/rundeckapp/grails-app/controllers/rundeck/controllers/ExecutionController.groovy b/rundeckapp/grails-app/controllers/rundeck/controllers/ExecutionController.groovy index 11db0450bb0..1d9e05342dc 100644 --- a/rundeckapp/grails-app/controllers/rundeck/controllers/ExecutionController.groovy +++ b/rundeckapp/grails-app/controllers/rundeck/controllers/ExecutionController.groovy @@ -40,6 +40,7 @@ import com.dtolabs.rundeck.plugins.logs.ContentConverterPlugin import com.dtolabs.rundeck.server.authorization.AuthConstants import com.dtolabs.rundeck.util.MetricsStatsBuilder import grails.converters.JSON +import groovy.transform.CompileStatic import org.quartz.JobExecutionContext import org.springframework.dao.DataAccessResourceFailureException import rundeck.CommandExec @@ -748,7 +749,7 @@ class ExecutionController extends ControllerBase{ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR) def msg= g.message(code: reader.errorCode, args: reader.errorData) log.error("Output file reader error: ${msg}") - response.outputStream << msg + appendOutput(msg) return }else if (reader.state != ExecutionLogState.AVAILABLE) { //TODO: handle other states @@ -783,8 +784,8 @@ class ExecutionController extends ControllerBase{ } catch (Exception exc) { } } - response.outputStream << (isFormatted?"${logFormater.format(msgbuf.datetime)} [${msgbuf.metadata?.user}@${msgbuf.metadata?.node} ${msgbuf.metadata?.stepctx?:'_'}][${msgbuf.loglevel}] ${message}" : message) - response.outputStream< + response.setContentType("text/html") + appendOutput(''' @@ -820,9 +822,9 @@ class ExecutionController extends ControllerBase{
- ''' - response.outputStream << g.message(code: "execution.html.waiting") - response.outputStream << ''' + ''') + appendOutput(g.message(code: "execution.html.waiting")) + appendOutput('''
- ''' + ''') }else{ response.setStatus(HttpServletResponse.SC_NOT_FOUND) log.error("Output file not available") @@ -852,7 +854,8 @@ class ExecutionController extends ControllerBase{ def iterator = reader.reader iterator.openStream(0) def lineSep=System.getProperty("line.separator") - response.outputStream<<""" + response.setContentType("text/html") + appendOutput(""" @@ -862,7 +865,7 @@ class ExecutionController extends ControllerBase{
-
""" +
""") def csslevel=!(params.loglevels in ['off','false']) def renderContent = shouldConvertContent(params) @@ -894,23 +897,23 @@ class ExecutionController extends ControllerBase{ } def css="log_line" + (csslevel?" level_${msgbuf.loglevel.toString().toLowerCase()}":'') - response.outputStream << "
" - response.outputStream << msghtml - response.outputStream << '
' + appendOutput("
") + appendOutput(msghtml) + appendOutput('
') - response.outputStream< + appendOutput('''
-''' +''') }else{ - response.outputStream << '''
+ appendOutput('''
@@ -921,11 +924,16 @@ setTimeout(function(){ -''' +''') } } + @CompileStatic + private void appendOutput(def output) { + response.outputStream << output + } + /** * @param params * @return true if configuration/params enable log data content conversion plugins