Bug 56895 - catalina.bat does not properly compose JAVA_OPTS
catalina.bat does not properly compose JAVA_OPTS
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Integration
7.0.54
PC All
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2014-08-27 22:43 UTC by Lucas Theisen
Modified: 2014-12-06 05:33 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lucas Theisen 2014-08-27 22:43:50 UTC
When composing JAVA_OPTS, the current bat script uses this approach:

set JAVA_OPTS=%JAVA_OPTS% %OTHER_STUFF%

However, this leads to issues if the existing JAVA_OPTS had some sort of escape sequence in it.  For example, in my setenv.bat, I add some proxy info:

SET "JAVA_OPTS=-Dhttp.proxyHost=myproxy.localdomain -Dhttp.nonProxyHosts=*.localdomain^|localhost^|appserver.localdomain"

Using the existing approach, the escape sequence ^| gets processed into | leaving the next evaluation to treat it as a command pipe, which causes immediate failure.

If instead you use this approach:

set "JAVA_OPTS=%JAVA_OPTS% %OTHER_STUFF%"

Then those escape sequences are preserved.  Here is the patch for version 7.0.54:

--- catalina.bat_ORIGINAL       2014-08-27 18:37:05.173641700 -0400
+++ catalina.bat        2014-08-27 18:06:22.779721000 -0400
@@ -176,12 +176,12 @@
 if not exist "%CATALINA_BASE%\conf\logging.properties" goto noJuliConfig
 set LOGGING_CONFIG=-Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties"
 :noJuliConfig
-set JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%
+set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%"

 if not "%LOGGING_MANAGER%" == "" goto noJuliManager
 set LOGGING_MANAGER=-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
 :noJuliManager
-set JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%
+set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%"

 rem ----- Execute The Requested Command ---------------------------------------
Comment 1 Mark Thomas 2014-09-03 14:11:08 UTC
Fixed in 8.0.x for 8.0.12 onwards and in 7.0.x for 7.0.56 onwards.
Comment 2 Ognjen Blagojevic 2014-10-03 07:15:01 UTC
(In reply to Mark Thomas from comment #1)
> Fixed in 8.0.x for 8.0.12 onwards and in 7.0.x for 7.0.56 onwards.

FTR, 8.0.12 was already released at the moment the patch is applied. 8.0.13 iz skipped, therefore, it is 8.0.14 onwards.

-Ognjen