You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2010/09/01 20:29:36 UTC
svn commit: r991640 - in /velocity/engine/branches/2.0_Exp/src:
java/org/apache/velocity/app/event/
java/org/apache/velocity/app/event/implement/
java/org/apache/velocity/exception/ java/org/apache/velocity/io/
java/org/apache/velocity/runtime/log/ jav...
Author: nbubna
Date: Wed Sep 1 18:29:35 2010
New Revision: 991640
URL: http://svn.apache.org/viewvc?rev=991640&view=rev
Log:
VELOCITY-751 finish modernizing our exception throwing stuff
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventCartridge.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerMethodExecutor.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerUtil.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/PrintExceptions.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/exception/ParseErrorException.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/exception/VelocityException.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/io/UnicodeInputStream.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/AvalonLogChute.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/CommonsLogLogChute.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/HoldingLogChute.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/Log4JLogChute.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/LogChute.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/LogManager.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/NullLogChute.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/ServletLogChute.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/SystemLogChute.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/UberspectImpl.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/VelMethod.java
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EventHandlingTestCase.java
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/MethodInvocationExceptionTestCase.java
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/WrappedExceptionTestCase.java
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler1.java
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler2.java
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/ExceptionGeneratingEventHandler.java
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/TestLogChute.java
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventCartridge.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventCartridge.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventCartridge.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventCartridge.java Wed Sep 1 18:29:35 2010
@@ -265,10 +265,9 @@ public class EventCartridge
* is executed. Handlers will not be initialized more than once.
*
* @param rs
- * @throws Exception
* @since 1.5
*/
- public void initialize (RuntimeServices rs) throws Exception
+ public void initialize (RuntimeServices rs)
{
for ( Iterator i = referenceHandlers.iterator(); i.hasNext(); )
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerMethodExecutor.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerMethodExecutor.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerMethodExecutor.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerMethodExecutor.java Wed Sep 1 18:29:35 2010
@@ -37,9 +37,8 @@ public interface EventHandlerMethodExecu
* If appropriate, the returned Object will be the return value.
*
* @param handler call the appropriate method on this handler
- * @exception Exception generic exception potentially thrown by event handlers
*/
- public void execute(EventHandler handler) throws Exception;
+ public void execute(EventHandler handler);
/**
* Called after execute() to see if iterating should stop. Should
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerUtil.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerUtil.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerUtil.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/EventHandlerUtil.java Wed Sep 1 18:29:35 2010
@@ -22,8 +22,8 @@ package org.apache.velocity.app.event;
import java.util.Iterator;
import org.apache.velocity.context.InternalContextAdapter;
+import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.RuntimeServices;
-import org.apache.velocity.util.ExceptionUtils;
import org.apache.velocity.util.introspection.Info;
@@ -106,7 +106,7 @@ public class EventHandlerUtil {
}
catch (Exception e)
{
- throw ExceptionUtils.createRuntimeException("Exception in event handler.",e);
+ throw new VelocityException("Exception in event handler.",e);
}
}
@@ -210,7 +210,7 @@ public class EventHandlerUtil {
}
catch (Exception e)
{
- throw ExceptionUtils.createRuntimeException("Exception in event handler.",e);
+ throw new VelocityException("Exception in event handler.",e);
}
}
@@ -323,7 +323,7 @@ public class EventHandlerUtil {
}
catch (Exception e)
{
- throw ExceptionUtils.createRuntimeException("Exception in event handler.",e);
+ throw new VelocityException("Exception in event handler.",e);
}
}
@@ -344,7 +344,7 @@ public class EventHandlerUtil {
}
catch (Exception e)
{
- throw ExceptionUtils.createRuntimeException("Couldn't initialize event cartridge : ", e);
+ throw new VelocityException("Couldn't initialize event cartridge : ", e);
}
}
}
@@ -356,13 +356,11 @@ public class EventHandlerUtil {
* @param applicationEventHandlerIterator Iterator that loops through all global event handlers declared at application level
* @param contextEventHandlerIterator Iterator that loops through all global event handlers attached to context
* @param eventExecutor Strategy object that executes event handler method
- * @exception Exception generic exception potentially thrown by event handlers
*/
private static void callEventHandlers(
Iterator applicationEventHandlerIterator,
Iterator contextEventHandlerIterator,
EventHandlerMethodExecutor eventExecutor)
- throws Exception
{
/**
* First loop through the event handlers configured at the app level
@@ -381,12 +379,10 @@ public class EventHandlerUtil {
*
* @param handlerIterator Iterator that loops through event handlers
* @param eventExecutor Strategy object that executes event handler method
- * @exception Exception generic exception potentially thrown by event handlers
*/
private static void iterateOverEventHandlers(
Iterator handlerIterator,
EventHandlerMethodExecutor eventExecutor)
- throws Exception
{
if (handlerIterator != null)
{
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java Wed Sep 1 18:29:35 2010
@@ -44,10 +44,9 @@ public interface MethodExceptionEventHan
* @param method the method
* @param e the thrown exception
* @return an object to insert in the page
- * @throws Exception an exception to be thrown instead inserting an object
+ * @throws RuntimeException an exception to be thrown instead inserting an object
*/
- public Object methodException( Class claz, String method, Exception e )
- throws Exception;
+ public Object methodException( Class claz, String method, Exception e );
/**
* Defines the execution strategy for methodException
@@ -81,7 +80,7 @@ public interface MethodExceptionEventHan
* @param handler call the appropriate method on this handler
* @exception Exception generic exception thrown by methodException event handler method call
*/
- public void execute(EventHandler handler) throws Exception
+ public void execute(EventHandler handler)
{
MethodExceptionEventHandler eh = (MethodExceptionEventHandler) handler;
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/PrintExceptions.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/PrintExceptions.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/PrintExceptions.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/PrintExceptions.java Wed Sep 1 18:29:35 2010
@@ -55,9 +55,8 @@ public class PrintExceptions implements
* @param method the method
* @param e the thrown exception
* @return an object to insert in the page
- * @throws Exception an exception to be thrown instead inserting an object
*/
- public Object methodException(Class claz, String method, Exception e) throws Exception
+ public Object methodException(Class claz, String method, Exception e)
{
boolean showMessage = rs.getBoolean(SHOW_MESSAGE,false);
boolean showStackTrace = rs.getBoolean(SHOW_STACK_TRACE,false);
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/exception/ParseErrorException.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/exception/ParseErrorException.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/exception/ParseErrorException.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/exception/ParseErrorException.java Wed Sep 1 18:29:35 2010
@@ -151,9 +151,9 @@ public class ParseErrorException extends
lineNumber = xpex.getLineNumber();
templateName = xpex.getTemplateName();
}
- else if (pex.getWrappedThrowable() instanceof ParseException)
+ else if (pex.getCause() instanceof ParseException)
{
- ParseException pex2 = (ParseException) pex.getWrappedThrowable();
+ ParseException pex2 = (ParseException) pex.getCause();
if (pex2.currentToken != null && pex2.currentToken.next != null)
{
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/exception/VelocityException.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/exception/VelocityException.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/exception/VelocityException.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/exception/VelocityException.java Wed Sep 1 18:29:35 2010
@@ -1,7 +1,5 @@
package org.apache.velocity.exception;
-import org.apache.velocity.util.ExceptionUtils;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -28,23 +26,19 @@ import org.apache.velocity.util.Exceptio
* @author <a href="mailto:kdowney@amberarcher.com">Kyle F. Downey</a>
* @version $Id$
*/
-public class VelocityException
- extends RuntimeException
+public class VelocityException extends RuntimeException
{
/**
* Version Id for serializable
*/
private static final long serialVersionUID = 1251243065134956045L;
- private final Throwable wrapped;
-
/**
* @param exceptionMessage The message to register.
*/
public VelocityException(final String exceptionMessage)
{
super(exceptionMessage);
- wrapped = null;
}
/**
@@ -54,9 +48,7 @@ public class VelocityException
*/
public VelocityException(final String exceptionMessage, final Throwable wrapped)
{
- super(exceptionMessage);
- this.wrapped = wrapped;
- ExceptionUtils.setCause(this, wrapped);
+ super(exceptionMessage, wrapped);
}
/**
@@ -65,20 +57,7 @@ public class VelocityException
*/
public VelocityException(final Throwable wrapped)
{
- super();
- this.wrapped = wrapped;
- ExceptionUtils.setCause(this, wrapped);
+ super(wrapped);
}
- /**
- * returns the wrapped Throwable that caused this
- * MethodInvocationException to be thrown
- *
- * @return Throwable thrown by method invocation
- * @since 1.5
- */
- public Throwable getWrappedThrowable()
- {
- return wrapped;
- }
}
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/io/UnicodeInputStream.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/io/UnicodeInputStream.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/io/UnicodeInputStream.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/io/UnicodeInputStream.java Wed Sep 1 18:29:35 2010
@@ -24,8 +24,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.PushbackInputStream;
-import org.apache.velocity.util.ExceptionUtils;
-
/**
* This is an input stream that is unicode BOM aware. This allows you to e.g. read
@@ -117,9 +115,7 @@ public class UnicodeInputStream
}
catch (IOException ioe)
{
- IllegalStateException ex = new IllegalStateException("Could not read BOM from Stream");
- ExceptionUtils.setCause(ex, ioe);
- throw ex;
+ throw new IllegalStateException("Could not read BOM from Stream", ioe);
}
}
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/AvalonLogChute.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/AvalonLogChute.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/AvalonLogChute.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/AvalonLogChute.java Wed Sep 1 18:29:35 2010
@@ -30,6 +30,7 @@ import org.apache.log.LogTarget;
import org.apache.log.Logger;
import org.apache.log.Priority;
import org.apache.log.output.io.FileTarget;
+import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
@@ -67,7 +68,7 @@ public class AvalonLogChute implements L
/**
* @see org.apache.velocity.runtime.log.LogChute#init(org.apache.velocity.runtime.RuntimeServices)
*/
- public void init(RuntimeServices rs) throws Exception
+ public void init(RuntimeServices rs)
{
this.rsvc = rs;
@@ -92,7 +93,7 @@ public class AvalonLogChute implements L
}
// creates a file target using the specified file name
- private void initTarget(final String file, final RuntimeServices rsvc) throws Exception
+ private void initTarget(final String file, final RuntimeServices rsvc)
{
try
{
@@ -116,7 +117,7 @@ public class AvalonLogChute implements L
catch (IOException ioe)
{
rsvc.getLog().error("Unable to create log file for AvalonLogChute", ioe);
- throw new Exception("Error configuring AvalonLogChute : " + ioe);
+ throw new VelocityException("Error configuring AvalonLogChute", ioe);
}
}
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/CommonsLogLogChute.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/CommonsLogLogChute.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/CommonsLogLogChute.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/CommonsLogLogChute.java Wed Sep 1 18:29:35 2010
@@ -63,7 +63,7 @@ public class CommonsLogLogChute implemen
/********** LogChute methods *************/
- public void init(RuntimeServices rs) throws Exception
+ public void init(RuntimeServices rs)
{
String name =
(String)rs.getProperty(LOGCHUTE_COMMONS_LOG_NAME);
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/HoldingLogChute.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/HoldingLogChute.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/HoldingLogChute.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/HoldingLogChute.java Wed Sep 1 18:29:35 2010
@@ -42,7 +42,7 @@ class HoldingLogChute implements LogChut
/**
* @see org.apache.velocity.runtime.log.LogChute#init(org.apache.velocity.runtime.RuntimeServices)
*/
- public void init(RuntimeServices rs) throws Exception
+ public void init(RuntimeServices rs)
{
}
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/Log4JLogChute.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/Log4JLogChute.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/Log4JLogChute.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/Log4JLogChute.java Wed Sep 1 18:29:35 2010
@@ -25,9 +25,9 @@ import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.RollingFileAppender;
+import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
-import org.apache.velocity.util.ExceptionUtils;
/**
* Implementation of a simple log4j system that will either latch onto
@@ -59,7 +59,7 @@ public class Log4JLogChute implements Lo
/**
* @see org.apache.velocity.runtime.log.LogChute#init(org.apache.velocity.runtime.RuntimeServices)
*/
- public void init(RuntimeServices rs) throws Exception
+ public void init(RuntimeServices rs)
{
rsvc = rs;
@@ -109,7 +109,7 @@ public class Log4JLogChute implements Lo
}
// This tries to create a file appender for the specified file name.
- private void initAppender(String file) throws Exception
+ private void initAppender(String file)
{
try
{
@@ -130,7 +130,7 @@ public class Log4JLogChute implements Lo
catch (IOException ioe)
{
rsvc.getLog().error("Could not create file appender '"+file+'\'', ioe);
- throw ExceptionUtils.createRuntimeException("Error configuring Log4JLogChute : ", ioe);
+ throw new VelocityException("Error configuring Log4JLogChute : ", ioe);
}
}
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/LogChute.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/LogChute.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/LogChute.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/LogChute.java Wed Sep 1 18:29:35 2010
@@ -68,7 +68,7 @@ public interface LogChute
* @param rs
* @throws Exception
*/
- void init(RuntimeServices rs) throws Exception;
+ void init(RuntimeServices rs);
/**
* Send a log message from Velocity.
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/LogManager.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/LogManager.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/LogManager.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/LogManager.java Wed Sep 1 18:29:35 2010
@@ -63,7 +63,7 @@ public class LogManager
{
// Creates a new logging system or returns an existing one
// specified by the application.
- private static LogChute createLogChute(RuntimeServices rsvc) throws Exception
+ private static LogChute createLogChute(RuntimeServices rsvc)
{
Log log = rsvc.getLog();
@@ -170,6 +170,20 @@ public class LogManager
ncdfe);
}
}
+ catch(UnsupportedOperationException uoe)
+ {
+ // note these errors for anyone debugging the app
+ if (isProbablyProvidedLogChute(claz))
+ {
+ log.debug("Target log system for " + claz +
+ " is not supported (" + uoe.toString() +
+ "). Falling back to next log system...");
+ }
+ else
+ {
+ log.debug("Couldn't find necessary resources for "+claz, uoe);
+ }
+ }
catch(Exception e)
{
String msg = "Failed to initialize an instance of " + claz +
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/NullLogChute.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/NullLogChute.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/NullLogChute.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/NullLogChute.java Wed Sep 1 18:29:35 2010
@@ -35,7 +35,7 @@ public class NullLogChute implements Log
/**
* @see org.apache.velocity.runtime.log.LogChute#init(org.apache.velocity.runtime.RuntimeServices)
*/
- public void init(RuntimeServices rs) throws Exception
+ public void init(RuntimeServices rs)
{
}
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/ServletLogChute.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/ServletLogChute.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/ServletLogChute.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/ServletLogChute.java Wed Sep 1 18:29:35 2010
@@ -65,7 +65,7 @@ public class ServletLogChute implements
* @throws IllegalStateException if the ServletContext is not available
* in the application attributes under the appropriate key.
*/
- public void init(RuntimeServices rs) throws Exception
+ public void init(RuntimeServices rs)
{
Object obj = rs.getApplicationAttribute(ServletContext.class.getName());
if (obj == null)
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/SystemLogChute.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/SystemLogChute.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/SystemLogChute.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/log/SystemLogChute.java Wed Sep 1 18:29:35 2010
@@ -40,7 +40,7 @@ public class SystemLogChute implements L
private int enabled = WARN_ID;
private int errLevel = TRACE_ID;
- public void init(RuntimeServices rs) throws Exception
+ public void init(RuntimeServices rs)
{
// look for a level config property
String level = (String)rs.getProperty(RUNTIME_LOG_LEVEL_KEY);
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java Wed Sep 1 18:29:35 2010
@@ -28,12 +28,12 @@ import org.apache.velocity.exception.Met
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.TemplateInitException;
+import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.directive.Directive;
import org.apache.velocity.runtime.directive.RuntimeMacro;
import org.apache.velocity.runtime.directive.BlockMacro;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.Parser;
-import org.apache.velocity.util.ExceptionUtils;
/**
* This class is responsible for handling the pluggable
@@ -109,15 +109,15 @@ public class ASTDirective extends Simple
}
catch (InstantiationException e)
{
- throw ExceptionUtils.createRuntimeException("Couldn't initialize " +
- "directive of class " +
+ throw new VelocityException(
+ "Couldn't initialize directive of class " +
parser.getDirective(directiveName).getClass().getName(),
e);
}
catch (IllegalAccessException e)
{
- throw ExceptionUtils.createRuntimeException("Couldn't initialize " +
- "directive of class " +
+ throw new VelocityException(
+ "Couldn't initialize directive of class " +
parser.getDirective(directiveName).getClass().getName(),
e);
}
@@ -142,7 +142,7 @@ public class ASTDirective extends Simple
catch (TemplateInitException die)
{
throw new TemplateInitException(die.getMessage(),
- (ParseException) die.getWrappedThrowable(),
+ (ParseException) die.getCause(),
die.getTemplateName(),
die.getColumnNumber() + getColumn(),
die.getLineNumber() + getLine());
@@ -178,7 +178,7 @@ public class ASTDirective extends Simple
catch (TemplateInitException die)
{
throw new TemplateInitException(die.getMessage(),
- (ParseException) die.getWrappedThrowable(),
+ (ParseException) die.getCause(),
die.getTemplateName(),
die.getColumnNumber() + getColumn(),
die.getLineNumber() + getLine());
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java Wed Sep 1 18:29:35 2010
@@ -26,7 +26,6 @@ import org.apache.commons.lang.StringUti
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.resource.Resource;
import org.apache.velocity.util.ClassUtils;
-import org.apache.velocity.util.ExceptionUtils;
/**
* ClasspathResourceLoader is a simple loader that will load
@@ -120,7 +119,7 @@ public class ClasspathResourceLoader ext
}
catch( Exception fnfe )
{
- throw (ResourceNotFoundException) ExceptionUtils.createWithCause(ResourceNotFoundException.class, "problem with template: " + name, fnfe );
+ throw new ResourceNotFoundException("ClasspathResourceLoader problem with template: " + name, fnfe );
}
if (result == null)
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java Wed Sep 1 18:29:35 2010
@@ -33,7 +33,6 @@ import org.apache.commons.collections.Ex
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.resource.Resource;
-import org.apache.velocity.util.ExceptionUtils;
import org.apache.velocity.util.StringUtils;
/**
@@ -322,7 +321,7 @@ public class DataSourceResourceLoader ex
+ operation + " of '" + name + "': ";
log.error(msg, sqle);
- throw ExceptionUtils.createRuntimeException(msg, sqle);
+ throw new VelocityException(msg, sqle);
}
catch (NamingException ne)
{
@@ -330,7 +329,7 @@ public class DataSourceResourceLoader ex
+ operation + " of '" + name + "': ";
log.error(msg, ne);
- throw ExceptionUtils.createRuntimeException(msg, ne);
+ throw new VelocityException(msg, ne);
}
finally
{
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/UberspectImpl.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/UberspectImpl.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/UberspectImpl.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/UberspectImpl.java Wed Sep 1 18:29:35 2010
@@ -20,6 +20,7 @@ package org.apache.velocity.util.introsp
*/
import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Enumeration;
@@ -219,7 +220,6 @@ public class UberspectImpl implements Ub
* @param identifier
* @param i
* @return A Velocity Getter Method.
- * @throws Exception
*/
public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i)
{
@@ -273,7 +273,6 @@ public class UberspectImpl implements Ub
* @param arg
* @param i
* @return A Velocity Setter method.
- * @throws Exception
*/
public VelPropertySet getPropertySet(Object obj, String identifier,
Object arg, Info i)
@@ -345,7 +344,7 @@ public class UberspectImpl implements Ub
* @see VelMethod#invoke(java.lang.Object, java.lang.Object[])
*/
public Object invoke(Object o, Object[] actual)
- throws Exception
+ throws IllegalAccessException, InvocationTargetException
{
// if we're pretending an array is a list...
if (wrapArray)
@@ -374,7 +373,8 @@ public class UberspectImpl implements Ub
* has already been completed.
* @since 1.6
*/
- protected Object doInvoke(Object o, Object[] actual) throws Exception
+ protected Object doInvoke(Object o, Object[] actual)
+ throws IllegalAccessException, InvocationTargetException
{
return method.invoke(o, actual);
}
@@ -518,7 +518,7 @@ public class UberspectImpl implements Ub
* @see org.apache.velocity.util.introspection.VelPropertyGet#invoke(java.lang.Object)
*/
public Object invoke(Object o)
- throws Exception
+ throws IllegalAccessException, InvocationTargetException
{
return getExecutor.execute(o);
}
@@ -566,10 +566,9 @@ public class UberspectImpl implements Ub
* @param o is the Object to invoke it on.
* @param value in the Value to set.
* @return The resulting Object.
- * @throws Exception
*/
public Object invoke(final Object o, final Object value)
- throws Exception
+ throws IllegalAccessException, InvocationTargetException
{
return setExecutor.execute(o, value);
}
Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/VelMethod.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/VelMethod.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/VelMethod.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/VelMethod.java Wed Sep 1 18:29:35 2010
@@ -1,5 +1,7 @@
package org.apache.velocity.util.introspection;
+import java.lang.reflect.InvocationTargetException;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -36,10 +38,10 @@ public interface VelMethod
* @param o
* @param params
* @return The resulting object.
- * @throws Exception
+ * @throws IllegalAccessException, InvocationTargetException
*/
public Object invoke(Object o, Object[] params)
- throws Exception;
+ throws IllegalAccessException, InvocationTargetException;
/**
* specifies if this VelMethod is cacheable and able to be
Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EventHandlingTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EventHandlingTestCase.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EventHandlingTestCase.java (original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EventHandlingTestCase.java Wed Sep 1 18:29:35 2010
@@ -237,7 +237,6 @@ public class EventHandlingTestCase exten
* Handles exceptions thrown during in-template method access
*/
public Object methodException( Class claz, String method, Exception e )
- throws Exception
{
// as a test, make sure this EventHandler is initialized
if (rs == null)
@@ -253,11 +252,11 @@ public class EventHandlingTestCase exten
return "handler";
}
else
- throw e;
+ throw new RuntimeException(e);
} else
- throw e;
+ throw new RuntimeException(e);
}
Context context;
Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/MethodInvocationExceptionTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/MethodInvocationExceptionTestCase.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/MethodInvocationExceptionTestCase.java (original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/MethodInvocationExceptionTestCase.java Wed Sep 1 18:29:35 2010
@@ -106,7 +106,7 @@ public class MethodInvocationExceptionTe
log(" reference = " + mie.getReferenceName() );
log(" method = " + mie.getMethodName() );
- Throwable t = mie.getWrappedThrowable();
+ Throwable t = mie.getCause();
log(" throwable = " + t );
if( t instanceof Exception)
@@ -143,7 +143,7 @@ public class MethodInvocationExceptionTe
log(" reference = " + mie.getReferenceName() );
log(" method = " + mie.getMethodName() );
- Throwable t = mie.getWrappedThrowable();
+ Throwable t = mie.getCause();
log(" throwable = " + t );
if( t instanceof Exception)
@@ -175,7 +175,7 @@ public class MethodInvocationExceptionTe
log(" reference = " + mie.getReferenceName() );
log(" method = " + mie.getMethodName() );
- Throwable t = mie.getWrappedThrowable();
+ Throwable t = mie.getCause();
log(" throwable = " + t );
if( t instanceof Exception)
@@ -206,7 +206,7 @@ public class MethodInvocationExceptionTe
log(" reference = " + mie.getReferenceName() );
log(" method = " + mie.getMethodName() );
- Throwable t = mie.getWrappedThrowable();
+ Throwable t = mie.getCause();
log(" throwable = " + t );
if( t instanceof Exception)
@@ -244,7 +244,7 @@ public class MethodInvocationExceptionTe
log(" reference = " + mie.getReferenceName() );
log(" method = " + mie.getMethodName() );
- Throwable t = mie.getWrappedThrowable();
+ Throwable t = mie.getCause();
log(" throwable = " + t );
if( t instanceof Exception)
Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/WrappedExceptionTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/WrappedExceptionTestCase.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/WrappedExceptionTestCase.java (original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/WrappedExceptionTestCase.java Wed Sep 1 18:29:35 2010
@@ -27,9 +27,6 @@ import org.apache.velocity.app.VelocityE
import org.apache.velocity.context.Context;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.test.provider.TestProvider;
-import org.apache.velocity.util.ExceptionUtils;
-
-
/**
* Test thrown exceptions include a proper cause (under JDK 1.4+).
@@ -81,11 +78,5 @@ public class WrappedExceptionTestCase ex
}
}
- public void testExceptionUtils()
- {
- Error e = new Error("Inside");
- RuntimeException re = ExceptionUtils.createRuntimeException("Outside", e);
- assertEquals("cause was set", e,re.getCause());
- }
}
Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler1.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler1.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler1.java (original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler1.java Wed Sep 1 18:29:35 2010
@@ -46,9 +46,9 @@ public class Handler1
/**
* throw the exception
*/
- public Object methodException(Class claz, String method, Exception e) throws Exception
+ public Object methodException(Class claz, String method, Exception e)
{
- throw e;
+ throw new RuntimeException(e);
}
/*
Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler2.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler2.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler2.java (original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/eventhandler/Handler2.java Wed Sep 1 18:29:35 2010
@@ -46,7 +46,7 @@ public class Handler2
/**
* print the exception
*/
- public Object methodException(Class claz, String method, Exception e) throws Exception
+ public Object methodException(Class claz, String method, Exception e)
{
return "Exception: " + e;
}
Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/ExceptionGeneratingEventHandler.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/ExceptionGeneratingEventHandler.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/ExceptionGeneratingEventHandler.java (original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/ExceptionGeneratingEventHandler.java Wed Sep 1 18:29:35 2010
@@ -40,7 +40,7 @@ public class ExceptionGeneratingEventHan
throw new RuntimeException("exception");
}
- public Object methodException(Class claz, String method, Exception e) throws Exception
+ public Object methodException(Class claz, String method, Exception e)
{
throw new RuntimeException("exception");
}
Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/TestLogChute.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/TestLogChute.java?rev=991640&r1=991639&r2=991640&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/TestLogChute.java (original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/misc/TestLogChute.java Wed Sep 1 18:29:35 2010
@@ -57,7 +57,6 @@ public class TestLogChute extends System
}
public void init(RuntimeServices rs)
- throws Exception
{
super.init(rs);