You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by cb...@apache.org on 2016/07/17 11:14:08 UTC
svn commit: r1753058 - in /velocity/engine/trunk: src/changes/changes.xml
velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
Author: cbrisson
Date: Sun Jul 17 11:14:08 2016
New Revision: 1753058
URL: http://svn.apache.org/viewvc?rev=1753058&view=rev
Log:
[engine] proper handling of 'initializing' and internal state when a problem occurs during initialization
Modified:
velocity/engine/trunk/src/changes/changes.xml
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
Modified: velocity/engine/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/changes/changes.xml?rev=1753058&r1=1753057&r2=1753058&view=diff
==============================================================================
--- velocity/engine/trunk/src/changes/changes.xml (original)
+++ velocity/engine/trunk/src/changes/changes.xml Sun Jul 17 11:14:08 2016
@@ -27,6 +27,10 @@
<body>
<release version="2.0" date="In Subversion">
+ <action type="fix" dev="cbrisson" issue="VELOCITY-804" due-to="Felipe Maschio">
+ Don't leave 'initializing' to true if a problem occurs during initialization.
+ </action>
+
<action type="add" dev="cbrisson" issue="VELOCITY-790">
Remove dependency upon commons-collections-3 (except at compile-time for deprecated methods and classes
which are needed for backward compatibility), use our own ExtProperties object.
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java?rev=1753058&r1=1753057&r2=1753058&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java Sun Jul 17 11:14:08 2016
@@ -224,32 +224,49 @@ public class RuntimeInstance implements
{
if (!initialized && !initializing)
{
- log.debug("Initializing Velocity, Calling init()...");
- initializing = true;
-
- log.trace("*******************************************************************");
- log.debug("Starting Apache Velocity v2.0-dev (compiled: 2009-02-05 07:40:05)");
- log.trace("RuntimeInstance initializing.");
-
- initializeProperties();
- initializeLog();
- initializeResourceManager();
- initializeDirectives();
- initializeEventHandlers();
- initializeParserPool();
-
- initializeIntrospection();
- initializeEvaluateScopeSettings();
- /*
- * initialize the VM Factory. It will use the properties
- * accessible from Runtime, so keep this here at the end.
- */
- vmFactory.initVelocimacro();
-
- log.trace("RuntimeInstance successfully initialized.");
-
- initialized = true;
- initializing = false;
+ try
+ {
+ log.debug("Initializing Velocity, Calling init()...");
+ initializing = true;
+
+ log.trace("*******************************************************************");
+ log.debug("Starting Apache Velocity v2.0-dev (compiled: 2009-02-05 07:40:05)");
+ log.trace("RuntimeInstance initializing.");
+
+ initializeProperties();
+ initializeLog();
+ initializeResourceManager();
+ initializeDirectives();
+ initializeEventHandlers();
+ initializeParserPool();
+
+ initializeIntrospection();
+ initializeEvaluateScopeSettings();
+ /*
+ * initialize the VM Factory. It will use the properties
+ * accessible from Runtime, so keep this here at the end.
+ */
+ vmFactory.initVelocimacro();
+
+ log.trace("RuntimeInstance successfully initialized.");
+
+ initialized = true;
+ initializing = false;
+ }
+ catch(RuntimeException re)
+ {
+ // initialization failed at some point... try to reset everything
+ try
+ {
+ reset();
+ }
+ catch(RuntimeException re2) {} // prefer throwing the original exception
+ throw re;
+ }
+ finally
+ {
+ initializing = false;
+ }
}
}