New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global context #447
Global context #447
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, can we branch deploy the renderer and run a diff test to see if this causes any issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure you can dynamically register new functions or filters. I believe that's why the list of disabled features had to be implemented separately.
@@ -123,6 +127,10 @@ public Context getGlobalContext() { | |||
return globalContext; | |||
} | |||
|
|||
public Context getGlobalContextReadOnly() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public Context getGlobalContextReadOnly() { | |
public Context getGlobalContextCopy() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used to use getGlobalContextCopy
, thought the readOnly one is better :).
Thanks for this. Looks like it will resolve the issue I introduced here. Was that your intention or did I just get lucky here? I was also going to introduce a flag on Context that would identify it as the global. Not sure if you might consider that useful here so we can easily avoid adding to the context if we know its the global one. |
Created PR to add global context flag to this: #448 |
Do you plan on merging this soon? |
The branch deploy was good. Planing to merge early next week. I wanted to do a bit more debugging before we stop sharing the global context. |
Sounds good! I'll wait for your changes before merging mine. They give me an extra layer of safety for my changes. |
JinJava can be a singleton and shared by multiple threads. The JinJava rendering context is scoped, but the root of the context -- the global context -- is shared. However, the context should not be shared, especially they can be modified during the rendering. To alleviate the issue,
Drawback is once the JinJava's
renderForResult
is started, updating the global content (registering new filter, etc) has no effect. It might actually be desired.