facebookarchive / nailgun

Nailgun is a client, protocol, and server for running Java programs from the command line without incurring the JVM startup overhead.
https://github.com/facebook/nailgun
Other
731 stars 138 forks source link

Add thread locals for system properties #129

Closed jvican closed 6 years ago

jvican commented 6 years ago

The system properties (remoteEnv in the code) depend on the nailgun client. They are accessible in the nailgun context. However, they need to be accessed explicitly at the use site: that code (which can come from dependencies) depending on java.lang.System.getProperty won't work.

I think for user-defined system properties to be usable, Nailgun should have thread locals and update the system-wide properties with the user-defined properties per ngsession.

jvican commented 6 years ago

Doing this would require hijacking System.getenv() reflectively to get java.lang.ProcessEnvironment et al, just like in https://stackoverflow.com/questions/9997292/how-to-read-environment-variables-in-scala.

Then, we would create an subclass of map that would get the environment map with a thread local. Since this is a pretty complicated process, I'm closing this ticket, as it's unlikely to be done in nailgun itself.