Skip to content

v5.x regression: JAVA_OPTS handling broken (pipes/newlines in 5.0.2, quoting in 5.0.3) #1301

@jmuollo

Description

@jmuollo

Summary

There are regressions in JAVA_OPTS handling across the v5.x line:


Root Cause

  • 5.0.2 (pre-start scripts fails when JAVA_OPTS contains special characters #1259): sed substitution fails with | / newlines → JVM options may be dropped or corrupted
  • 5.0.3 introduces:
    USER_JAVA_OPTS=$(echo "$JAVA_OPTS" | tr '\n' ' ' | tr -s ' ' | xargs)
    xargs removes quoting → argument boundaries lost → downstream shell parsing splits args and may expand *

Minimal Reproducer

JAVA_OPTS='-Dfoo="bar baz" -DcronSched="0 */7 * * * *"'
USER_JAVA_OPTS=$(echo "$JAVA_OPTS" | tr '\n' ' ' | tr -s ' ' | xargs)
set -f; eval set -- $USER_JAVA_OPTS; printf '<%s>\n' "$@"
# => quoted args split; cron expression becomes multiple tokens
<-Dfoo=bar>
<baz>
<-DcronSched=0>
<*/7>
<*>
<*>
<*>
<*>

Real CF Failure

   2026-05-26T23:15:42.56+0000 [APP/PROC/WEB/0] OUT Invoking pre-start scripts.
   2026-05-26T23:15:42.58+0000 [APP/PROC/WEB/0] OUT Created symlink: /home/vcap/app/BOOT-INF/lib/client-certificate-mapper-2.0.1.jar -> /home/vcap/deps/2/client_certificate_mapper/client-certificate-mapper-2.0.1.jar
   2026-05-26T23:15:42.58+0000 [APP/PROC/WEB/0] OUT Invoking start command.
   2026-05-26T23:15:42.58+0000 [APP/PROC/WEB/0] OUT JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=169241K -XX:ReservedCodeCacheSize=240M -Xss1M -Xmx576230K
   2026-05-26T23:15:42.63+0000 [APP/PROC/WEB/0] ERR Error: Could not find or load main class *.1
   2026-05-26T23:15:42.63+0000 [APP/PROC/WEB/0] ERR Caused by: java.lang.ClassNotFoundException: *.1
   2026-05-26T23:15:42.64+0000 [API/0] OUT Process became ready with guid fe7a5b4a-fba8-48cb-8283-c5a8d1f61132 payload: {"instance"=>"8dcab366-fa64-4dcc-4bad-5f7d", "index"=>0, "cell_id"=>"0b0ac42c-af1a-4963-85a2-dabc9f16253c", "ready"=>true, "version"=>"57f8bb8d-5b81-4b64-8047-c79ab1b62a35"}
   2026-05-26T23:15:42.64+0000 [APP/PROC/WEB/0] OUT Exit status 1

Could not find or load main class *.1 is due to the quotes being stripped from -DcronSched="0 */1 * * * *"


Impact

Breaks valid JVM usage such as:

-Dkey="value with spaces"
-DcronSched="0 */7 * * * *"

This is not cron-specific — affects any quoted JVM argument.


Expected

  • JAVA_OPTS should preserve argument boundaries
  • special characters (|, *, whitespace) must not corrupt or expand arguments

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions