Skip to content

fix: use profile.d to append CLASSPATH instead of WriteEnvFile#1180

Open
ramonskie wants to merge 1 commit intofeature/go-migrationfrom
fix/classpath-append-via-profile-d
Open

fix: use profile.d to append CLASSPATH instead of WriteEnvFile#1180
ramonskie wants to merge 1 commit intofeature/go-migrationfrom
fix/classpath-append-via-profile-d

Conversation

@ramonskie
Copy link
Contributor

Problem

Five framework Finalize() methods were using WriteEnvFile("CLASSPATH", ...) to add their JAR to the classpath. This has two bugs:

  1. Silent overwrites: WriteEnvFile writes a single file at $DEPS_DIR/<idx>/env/CLASSPATH. Every subsequent call replaces the file, so the last framework to run wins and all others' JARs are silently dropped.
  2. Wrong paths: The old code read os.Getenv("CLASSPATH") at staging time (always empty) and stored staging-time absolute paths (e.g. /tmp/staging/deps/...) that are invalid at container runtime.

Fix

Switch all five affected Finalize() methods to WriteProfileD with the standard prepend pattern used consistently elsewhere in the codebase (e.g. metric_writer, container_customizer, dist_zip, play):

export CLASSPATH="$DEPS_DIR/<idx>/<subdir>/<jar>:${CLASSPATH:-}"

Profile.d scripts are sourced in sequence at container startup, so each framework safely accumulates its JAR without clobbering others.

Affected files

  • src/java/frameworks/java_cf_env.go
  • src/java/frameworks/client_certificate_mapper.go
  • src/java/frameworks/spring_auto_reconfiguration.go
  • src/java/frameworks/postgresql_jdbc.go
  • src/java/frameworks/maria_db_jdbc.go

WriteEnvFile overwrites the single env file on every call, so the last
framework to run won the CLASSPATH, silently dropping all others.
Additionally, the old code read os.Getenv("CLASSPATH") at staging time
which is always empty, and embedded staging-time absolute paths that are
wrong at container runtime.

Switch all five affected Finalize() methods to WriteProfileD with the
standard prepend pattern:

  export CLASSPATH="$DEPS_DIR/<idx>/<subdir>/<jar>:${CLASSPATH:-}"

Each profile.d script is sourced in order at startup so every framework
safely accumulates its entry without clobbering the others.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant