SLING-9206 - Add support for executing precompiled JSP scripts
* Synchronize on this for jsp runtime context creation
diff --git a/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java b/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
index 63db5b1..34c49f1 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
@@ -197,7 +197,6 @@
private SlingTldLocationsCache tldLocationsCache;
private JspRuntimeContext jspRuntimeContext;
- private ReentrantReadWriteLock jspRuntimeContextLock = new ReentrantReadWriteLock();
private JspServletOptions options;
@@ -643,23 +642,16 @@
}
private JspRuntimeContext getJspRuntimeContext() {
- jspRuntimeContextLock.readLock().lock();
- if (jspRuntimeContext == null) {
- jspRuntimeContextLock.readLock().unlock();
- jspRuntimeContextLock.writeLock().lock();
- try {
- jspRuntimeContext = new JspRuntimeContext(slingServletContext,
+ if ( this.jspRuntimeContext == null ) {
+ synchronized ( this ) {
+ if ( this.jspRuntimeContext == null ) {
+ // Initialize the JSP Runtime Context
+ this.jspRuntimeContext = new JspRuntimeContext(slingServletContext,
options, ioProvider);
- jspRuntimeContextLock.readLock().lock();
- } finally {
- jspRuntimeContextLock.writeLock().unlock();
+ }
}
}
- try {
- return jspRuntimeContext;
- } finally {
- jspRuntimeContextLock.readLock().unlock();
- }
+ return this.jspRuntimeContext;
}
/**