Skip to content

Commit

Permalink
Early exit for TomcatExecutionListener (#189)
Browse files Browse the repository at this point in the history
* Early exit in Tomcat listener

* Changelog entry
  • Loading branch information
Razz4780 authored Oct 27, 2023
1 parent 8955b2f commit a09d1ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelog.d/188.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`TomcatExecutionListener` does not save/restore environment when mirrord is disabled.
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ class TomcatExecutionListener : ExecutionListener {
}

try {
val mirrordEnv = service.execManager.wrapper("idea").apply {
service.execManager.wrapper("idea").apply {
this.wsl = wsl
configFromEnv = envVars.find { e -> e.name == CONFIG_ENV_NAME }?.VALUE
}.start()?.first?.let { it + mapOf(Pair("MIRRORD_DETECT_DEBUGGER_PORT", "javaagent")) }.orEmpty().toMutableMap()

// This should allow clean shutdown of the app even if `outgoing` feature is enabled.
mirrordEnv["MIRRORD_IGNORE_DEBUGGER_PORTS"] = getTomcatServerPort()

savedEnvs[executorId] = envVars.toList()
envVars.addAll(mirrordEnv.map { (k, v) -> EnvironmentVariable(k, v, false) })
config.setEnvironmentVariables(envVars)
}.start()?.first?.let {
// `MIRRORD_IGNORE_DEBUGGER_PORTS` should allow clean shutdown of the app
// even if `outgoing` feature is enabled.
val mirrordEnv = it + mapOf(Pair("MIRRORD_DETECT_DEBUGGER_PORT", "javaagent"), Pair("MIRRORD_IGNORE_DEBUGGER_PORTS", getTomcatServerPort()))
savedEnvs[executorId] = envVars.toList()
envVars.addAll(mirrordEnv.map { (k, v) -> EnvironmentVariable(k, v, false) })
config.setEnvironmentVariables(envVars)
}
} catch (_: Throwable) {
// Error notifications were already fired.
// We can't abort the execution here, so we let the app run without mirrord.
Expand Down

0 comments on commit a09d1ad

Please sign in to comment.