You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was using porcupine to create an ExecutorService in my project. When I would send in my first round of Runnables into the executor everything worked as expected. I then tried added another round of Runnables into the executor and was running into permissions issues. I checked the logs and the second round of runnables were running as the original user. I had to use a ManagedExecutorService instead to get the SessionContext to properly propagate into the Runnables. I wrote a stackoverflow question that provides a more clear example: http://stackoverflow.com/questions/40002010/how-to-avoid-executorservice-from-overridding-security-principal-of-a-runnable
Are the ExecutorService and the generated threads supposed to be container manager or is that an invalid assumption that I made?
The text was updated successfully, but these errors were encountered:
I think this is a flaw that prevents procupine from being used in alot of cases.
Citing ManagedThreadFactory Javadoc:
"The Runnable task ... will run with the application component context of the component instance that created (looked-up) this ManagedThreadFactory instance."
Porcupine seems to assume the context to be capured from the thread that invokes managedThreadFactory.newThread(runnable), which is not the case - the context is captured form the point at which the ManagedThreadFactory was looked up or injected. The same context is applied to each new thread created by the ManagedThreadFactory.
So this code, executed inside a thread from ManagedThreadFactory,
will always return the name of the user that first invoked the ManagedThreadFactory, even if currently another user uses the ManagedThreadFactory.
The only solution i know of is to use ManagedExecutorService as you already stated - but then you do not need porcupine, since these can not be configured during runtime.
I was using porcupine to create an ExecutorService in my project. When I would send in my first round of Runnables into the executor everything worked as expected. I then tried added another round of Runnables into the executor and was running into permissions issues. I checked the logs and the second round of runnables were running as the original user. I had to use a ManagedExecutorService instead to get the SessionContext to properly propagate into the Runnables. I wrote a stackoverflow question that provides a more clear example: http://stackoverflow.com/questions/40002010/how-to-avoid-executorservice-from-overridding-security-principal-of-a-runnable
Are the ExecutorService and the generated threads supposed to be container manager or is that an invalid assumption that I made?
The text was updated successfully, but these errors were encountered: