From commits-return-18656-archive-asf-public=cust-asf.ponee.io@struts.apache.org Fri Dec 27 08:09:58 2019
Return-Path:
X-Original-To: archive-asf-public@cust-asf.ponee.io
Delivered-To: archive-asf-public@cust-asf.ponee.io
Received: from mail.apache.org (hermes.apache.org [207.244.88.153])
by mx-eu-01.ponee.io (Postfix) with SMTP id EFE07180674
for ; Fri, 27 Dec 2019 09:09:57 +0100 (CET)
Received: (qmail 29309 invoked by uid 500); 27 Dec 2019 08:09:56 -0000
Mailing-List: contact commits-help@struts.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: dev@struts.apache.org
Delivered-To: mailing list commits@struts.apache.org
Received: (qmail 29293 invoked by uid 99); 27 Dec 2019 08:09:56 -0000
Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70)
by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Dec 2019 08:09:56 +0000
Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33)
id A72B18D80F; Fri, 27 Dec 2019 08:09:56 +0000 (UTC)
Date: Fri, 27 Dec 2019 08:09:57 +0000
To: "commits@struts.apache.org"
Subject: [struts] 01/01: WW-5003 Drops XWorkException and uses
StrutsException instead
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
From: lukaszlenart@apache.org
In-Reply-To: <157743419654.30837.5554827792161093320@gitbox.apache.org>
References: <157743419654.30837.5554827792161093320@gitbox.apache.org>
X-Git-Host: gitbox.apache.org
X-Git-Repo: struts
X-Git-Refname: refs/heads/WW-5003-drops-xwork-exception
X-Git-Reftype: branch
X-Git-Rev: 140bea2e1c766b77e4870934f0ec5e619bf8c199
X-Git-NotificationType: diff
X-Git-Multimail-Version: 1.5.dev
Auto-Submitted: auto-generated
Message-Id: <20191227080956.A72B18D80F@gitbox.apache.org>
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch WW-5003-drops-xwork-exception
in repository https://gitbox.apache.org/repos/asf/struts.git
commit 140bea2e1c766b77e4870934f0ec5e619bf8c199
Author: Lukasz Lenart
AuthorDate: Thu Dec 26 15:00:03 2019 +0100
WW-5003 Drops XWorkException and uses StrutsException instead
---
.../com/opensymphony/xwork2/ActionChainResult.java | 3 +-
.../com/opensymphony/xwork2/ActionContext.java | 3 +-
.../xwork2/DefaultActionInvocation.java | 9 +-
.../com/opensymphony/xwork2/UnknownHandler.java | 9 +-
.../com/opensymphony/xwork2/XWorkException.java | 144 ---------------------
.../xwork2/config/ConfigurationException.java | 22 ++--
.../config/providers/XmlConfigurationProvider.java | 4 +-
.../xwork2/conversion/TypeConversionException.java | 13 +-
.../xwork2/conversion/impl/DateConverter.java | 6 +-
.../xwork2/conversion/impl/NumberConverter.java | 20 +--
.../conversion/impl/XWorkBasicConverter.java | 16 +--
.../xwork2/conversion/impl/XWorkList.java | 4 +-
.../interceptor/ScopedModelDrivenInterceptor.java | 4 +-
.../annotations/AnnotationWorkflowInterceptor.java | 4 +-
.../opensymphony/xwork2/ognl/OgnlValueStack.java | 10 +-
.../xwork2/ognl/accessor/CompoundRootAccessor.java | 6 +-
.../ognl/accessor/XWorkListPropertyAccessor.java | 6 +-
.../opensymphony/xwork2/util/ClassPathFinder.java | 4 +-
.../com/opensymphony/xwork2/util/DomHelper.java | 8 +-
.../util/classloader/ReloadingClassLoader.java | 6 +-
.../util/reflection/ReflectionException.java | 4 +-
.../xwork2/validator/DefaultValidatorFactory.java | 4 +-
.../java/org/apache/struts2/StrutsException.java | 49 ++++++-
.../apache/struts2/util/StrutsTypeConverter.java | 2 +-
.../opensymphony/xwork2/ActionInvocationTest.java | 8 +-
.../com/opensymphony/xwork2/ChainResultTest.java | 3 +-
.../config/providers/SomeUnknownHandler.java | 6 +-
.../conversion/impl/XWorkBasicConverterTest.java | 12 +-
.../ExceptionMappingInterceptorTest.java | 57 ++++----
.../com/opensymphony/xwork2/ognl/OgnlUtilTest.java | 4 +-
.../xwork2/ognl/OgnlValueStackTest.java | 9 +-
.../DefaultActionValidatorManagerTest.java | 4 +-
.../validator/DefaultValidatorFileParserTest.java | 10 +-
.../apache/struts2/StrutsExceptionTest.java} | 29 +++--
.../providers/xwork-test-exception-mappings.xml | 2 +-
.../convention/ConventionUnknownHandler.java | 11 +-
.../struts2/convention/DefaultClassFinder.java | 6 +-
37 files changed, 212 insertions(+), 309 deletions(-)
diff --git a/core/src/main/java/com/opensymphony/xwork2/ActionChainResult.java b/core/src/main/java/com/opensymphony/xwork2/ActionChainResult.java
index b842897..9261e61 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ActionChainResult.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ActionChainResult.java
@@ -23,6 +23,7 @@ import com.opensymphony.xwork2.util.TextParseUtil;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.struts2.StrutsException;
import java.util.*;
@@ -212,7 +213,7 @@ public class ActionChainResult implements Result {
if (isInChainHistory(finalNamespace, finalActionName, finalMethodName)) {
addToHistory(finalNamespace, finalActionName, finalMethodName);
- throw new XWorkException("Infinite recursion detected: " + ActionChainResult.getChainHistory().toString());
+ throw new StrutsException("Infinite recursion detected: " + ActionChainResult.getChainHistory().toString());
}
if (ActionChainResult.getChainHistory().isEmpty() && invocation != null && invocation.getProxy() != null) {
diff --git a/core/src/main/java/com/opensymphony/xwork2/ActionContext.java b/core/src/main/java/com/opensymphony/xwork2/ActionContext.java
index f5a020c..757dffd 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ActionContext.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ActionContext.java
@@ -21,6 +21,7 @@ package com.opensymphony.xwork2;
import com.opensymphony.xwork2.conversion.impl.ConversionData;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.util.ValueStack;
+import org.apache.struts2.StrutsException;
import org.apache.struts2.dispatcher.HttpParameters;
import java.io.Serializable;
@@ -323,7 +324,7 @@ public class ActionContext implements Serializable {
if (cont != null) {
return cont.getInstance(type);
} else {
- throw new XWorkException("Cannot find an initialized container for this request.");
+ throw new StrutsException("Cannot find an initialized container for this request.");
}
}
diff --git a/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java b/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
index d8f0be4..caa8d0f 100644
--- a/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
+++ b/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
@@ -34,6 +34,7 @@ import ognl.MethodFailedException;
import ognl.NoSuchPropertyException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.struts2.StrutsException;
import java.util.ArrayList;
import java.util.Iterator;
@@ -224,7 +225,7 @@ public class DefaultActionInvocation implements ActionInvocation {
return objectFactory.buildResult(resultConfig, invocationContext.getContextMap());
} catch (Exception e) {
LOG.error("There was an exception while instantiating the result of type {}", resultConfig.getClassName(), e);
- throw new XWorkException(e, resultConfig);
+ throw new StrutsException(e, resultConfig);
}
} else if (resultCode != null && !Action.NONE.equals(resultCode) && unknownHandlerManager.hasUnknownHandlers()) {
return unknownHandlerManager.handleUnknownResult(invocationContext, proxy.getActionName(), proxy.getConfig(), resultCode);
@@ -297,9 +298,9 @@ public class DefaultActionInvocation implements ActionInvocation {
try {
action = objectFactory.buildAction(proxy.getActionName(), proxy.getNamespace(), proxy.getConfig(), contextMap);
} catch (InstantiationException e) {
- throw new XWorkException("Unable to instantiate Action!", e, proxy.getConfig());
+ throw new StrutsException("Unable to instantiate Action!", e, proxy.getConfig());
} catch (IllegalAccessException e) {
- throw new XWorkException("Illegal access to constructor, is it public?", e, proxy.getConfig());
+ throw new StrutsException("Illegal access to constructor, is it public?", e, proxy.getConfig());
} catch (Exception e) {
String gripe;
@@ -314,7 +315,7 @@ public class DefaultActionInvocation implements ActionInvocation {
}
gripe += (((" -- " + e.getMessage()) != null) ? e.getMessage() : " [no message in exception]");
- throw new XWorkException(gripe, e, proxy.getConfig());
+ throw new StrutsException(gripe, e, proxy.getConfig());
}
if (actionEventListener != null) {
diff --git a/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java b/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java
index 32cb6d3..5ae3802 100644
--- a/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java
+++ b/core/src/main/java/com/opensymphony/xwork2/UnknownHandler.java
@@ -19,6 +19,7 @@
package com.opensymphony.xwork2;
import com.opensymphony.xwork2.config.entities.ActionConfig;
+import org.apache.struts2.StrutsException;
/**
* Handles cases when the result or action is unknown.
@@ -36,9 +37,9 @@ public interface UnknownHandler {
* @param namespace The namespace
* @param actionName The action name
* @return An generated ActionConfig, can return null
- * @throws XWorkException in case of errors
+ * @throws StrutsException in case of errors
*/
- ActionConfig handleUnknownAction(String namespace, String actionName) throws XWorkException;
+ ActionConfig handleUnknownAction(String namespace, String actionName) throws StrutsException;
/**
* Handles the case when a result cannot be found for an action and result code.
@@ -48,9 +49,9 @@ public interface UnknownHandler {
* @param actionConfig The action config
* @param resultCode The returned result code
* @return A result to be executed, can return null
- * @throws XWorkException in case of errors
+ * @throws StrutsException in case of errors
*/
- Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) throws XWorkException;
+ Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) throws StrutsException;
/**
* Handles the case when an action method cannot be found. This method is responsible both for finding the method and executing it.
diff --git a/core/src/main/java/com/opensymphony/xwork2/XWorkException.java b/core/src/main/java/com/opensymphony/xwork2/XWorkException.java
deleted file mode 100644
index 12bdf80..0000000
--- a/core/src/main/java/com/opensymphony/xwork2/XWorkException.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.opensymphony.xwork2;
-
-import com.opensymphony.xwork2.util.location.Locatable;
-import com.opensymphony.xwork2.util.location.Location;
-import com.opensymphony.xwork2.util.location.LocationUtils;
-
-/**
- * A generic runtime exception that optionally contains Location information
- *
- * @author Jason Carreira
- */
-public class XWorkException extends RuntimeException implements Locatable {
-
- private Location location;
-
-
- /**
- * Constructs a XWorkException
with no detail message.
- */
- public XWorkException() {
- }
-
- /**
- * Constructs a XWorkException
with the specified
- * detail message.
- *
- * @param s the detail message.
- */
- public XWorkException(String s) {
- this(s, null, null);
- }
-
- /**
- * Constructs a XWorkException
with the specified
- * detail message and target.
- *
- * @param s the detail message.
- * @param target the target of the exception.
- */
- public XWorkException(String s, Object target) {
- this(s, null, target);
- }
-
- /**
- * Constructs a XWorkException
with the root cause
- *
- * @param cause The wrapped exception
- */
- public XWorkException(Throwable cause) {
- this(null, cause, null);
- }
-
- /**
- * Constructs a XWorkException
with the root cause and target
- *
- * @param cause The wrapped exception
- * @param target The target of the exception
- */
- public XWorkException(Throwable cause, Object target) {
- this(null, cause, target);
- }
-
- /**
- * Constructs a XWorkException
with the specified
- * detail message and exception cause.
- *
- * @param s the detail message.
- * @param cause the wrapped exception
- */
- public XWorkException(String s, Throwable cause) {
- this(s, cause, null);
- }
-
-
- /**
- * Constructs a XWorkException
with the specified
- * detail message, cause, and target
- *
- * @param s the detail message.
- * @param cause The wrapped exception
- * @param target The target of the exception
- */
- public XWorkException(String s, Throwable cause, Object target) {
- super(s, cause);
-
- this.location = LocationUtils.getLocation(target);
- if (this.location == Location.UNKNOWN) {
- this.location = LocationUtils.getLocation(cause);
- }
- }
-
- /**
- * Gets the location of the error, if available
- *
- * @return the location, null if not available
- */
- public Location getLocation() {
- return this.location;
- }
-
-
- /**
- * Returns a short description of this throwable object, including the
- * location. If no detailed message is available, it will use the message
- * of the underlying exception if available.
- *
- * @return a string representation of this Throwable
.
- */
- @Override
- public String toString() {
- String msg = getMessage();
- if (msg == null && getCause() != null) {
- msg = getCause().getMessage();
- }
-
- if (location != null) {
- if (msg != null) {
- return msg + " - " + location.toString();
- } else {
- return location.toString();
- }
- } else {
- return msg;
- }
- }
-}
diff --git a/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationException.java b/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationException.java
index a150a0a..b9c3424 100644
--- a/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationException.java
+++ b/core/src/main/java/com/opensymphony/xwork2/config/ConfigurationException.java
@@ -18,15 +18,14 @@
*/
package com.opensymphony.xwork2.config;
-import com.opensymphony.xwork2.XWorkException;
-
+import org.apache.struts2.StrutsException;
/**
* ConfigurationException
*
* @author Jason Carreira
*/
-public class ConfigurationException extends XWorkException {
+public class ConfigurationException extends StrutsException {
/**
* Constructs a ConfigurationException
with no detail message.
@@ -43,12 +42,12 @@ public class ConfigurationException extends XWorkException {
public ConfigurationException(String s) {
super(s);
}
-
+
/**
* Constructs a ConfigurationException
with the specified
* detail message.
*
- * @param s the detail message.
+ * @param s the detail message.
* @param target the target object
*/
public ConfigurationException(String s, Object target) {
@@ -63,10 +62,11 @@ public class ConfigurationException extends XWorkException {
public ConfigurationException(Throwable cause) {
super(cause);
}
-
+
/**
* Constructs a ConfigurationException
with no detail message.
- * @param cause the cause of the exception
+ *
+ * @param cause the cause of the exception
* @param target the target object
*/
public ConfigurationException(Throwable cause, Object target) {
@@ -77,19 +77,19 @@ public class ConfigurationException extends XWorkException {
* Constructs a ConfigurationException
with the specified
* detail message.
*
- * @param s the detail message.
+ * @param s the detail message.
* @param cause the cause of the exception
*/
public ConfigurationException(String s, Throwable cause) {
super(s, cause);
}
-
+
/**
* Constructs a ConfigurationException
with the specified
* detail message.
*
- * @param s the detail message.
- * @param cause the cause of the exception
+ * @param s the detail message.
+ * @param cause the cause of the exception
* @param target the target object
*/
public ConfigurationException(String s, Throwable cause, Object target) {
diff --git a/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java b/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java
index 1613ae2..24d388e 100644
--- a/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java
+++ b/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java
@@ -22,7 +22,6 @@ import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.FileManager;
import com.opensymphony.xwork2.FileManagerFactory;
import com.opensymphony.xwork2.ObjectFactory;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.ConfigurationProvider;
@@ -52,6 +51,7 @@ import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.struts2.StrutsException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -1080,7 +1080,7 @@ public class XmlConfigurationProvider implements ConfigurationProvider {
docs.add(DomHelper.parse(in, dtdMappings));
loadedFileUrls.add(url.toString());
- } catch (XWorkException e) {
+ } catch (StrutsException e) {
if (includeElement != null) {
throw new ConfigurationException("Unable to load " + url, e, includeElement);
} else {
diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/TypeConversionException.java b/core/src/main/java/com/opensymphony/xwork2/conversion/TypeConversionException.java
index 5e8acdf..73db264 100644
--- a/core/src/main/java/com/opensymphony/xwork2/conversion/TypeConversionException.java
+++ b/core/src/main/java/com/opensymphony/xwork2/conversion/TypeConversionException.java
@@ -18,8 +18,7 @@
*/
package com.opensymphony.xwork2.conversion;
-import com.opensymphony.xwork2.XWorkException;
-
+import org.apache.struts2.StrutsException;
/**
* TypeConversionException should be thrown by any TypeConverters which fail to convert values
@@ -27,16 +26,16 @@ import com.opensymphony.xwork2.XWorkException;
* @author Jason Carreira
* Created Oct 3, 2003 12:18:33 AM
*/
-public class TypeConversionException extends XWorkException {
+public class TypeConversionException extends StrutsException {
/**
- * Constructs a XWorkException
with no detail message.
+ * Constructs a StrutsException
with no detail message.
*/
public TypeConversionException() {
}
/**
- * Constructs a XWorkException
with the specified
+ * Constructs a StrutsException
with the specified
* detail message.
*
* @param s the detail message.
@@ -46,7 +45,7 @@ public class TypeConversionException extends XWorkException {
}
/**
- * Constructs a XWorkException
with no detail message.
+ * Constructs a StrutsException
with no detail message.
* @param cause the cause
*/
public TypeConversionException(Throwable cause) {
@@ -54,7 +53,7 @@ public class TypeConversionException extends XWorkException {
}
/**
- * Constructs a XWorkException
with the specified
+ * Constructs a StrutsException
with the specified
* detail message.
*
* @param s the detail message.
diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java
index bc812d1..9639205 100644
--- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java
+++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java
@@ -18,7 +18,7 @@
*/
package com.opensymphony.xwork2.conversion.impl;
-import com.opensymphony.xwork2.XWorkException;
+import org.apache.struts2.StrutsException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Member;
@@ -90,11 +90,11 @@ public class DateConverter extends DefaultTypeConverter {
Constructor constructor = toType.getConstructor(new Class[]{long.class});
return constructor.newInstance(new Object[]{Long.valueOf(result.getTime())});
} catch (Exception e) {
- throw new XWorkException("Couldn't create class " + toType + " using default (long) constructor", e);
+ throw new StrutsException("Couldn't create class " + toType + " using default (long) constructor", e);
}
}
} catch (ParseException e) {
- throw new XWorkException("Could not parse date", e);
+ throw new StrutsException("Could not parse date", e);
}
} else if (Date.class.isAssignableFrom(value.getClass())) {
result = (Date) value;
diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java
index ec7c29b..92c5e7d 100644
--- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java
+++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java
@@ -18,9 +18,9 @@
*/
package com.opensymphony.xwork2.conversion.impl;
-import com.opensymphony.xwork2.XWorkException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.struts2.StrutsException;
import java.lang.reflect.Member;
import java.math.BigDecimal;
@@ -51,7 +51,7 @@ public class NumberConverter extends DefaultTypeConverter {
Object convertedValue = super.convertValue(context, value, toType);
if (!isInRange((Number) convertedValue, stringValue, toType))
- throw new XWorkException("Overflow or underflow casting: \"" + stringValue + "\" into class " + convertedValue.getClass().getName());
+ throw new StrutsException("Overflow or underflow casting: \"" + stringValue + "\" into class " + convertedValue.getClass().getName());
return convertedValue;
} else {
@@ -67,11 +67,11 @@ public class NumberConverter extends DefaultTypeConverter {
Number number = numFormat.parse(stringValue, parsePos);
if (parsePos.getIndex() != stringValue.length()) {
- throw new XWorkException("Unparseable number: \"" + stringValue + "\" at position "
- + parsePos.getIndex());
+ throw new StrutsException("Unparseable number: \"" + stringValue + "\" at position "
+ + parsePos.getIndex());
} else {
if (!isInRange(number, stringValue, toType))
- throw new XWorkException("Overflow or underflow casting: \"" + stringValue + "\" into class " + number.getClass().getName());
+ throw new StrutsException("Overflow or underflow casting: \"" + stringValue + "\" into class " + number.getClass().getName());
value = super.convertValue(context, number, toType);
}
@@ -103,7 +103,7 @@ public class NumberConverter extends DefaultTypeConverter {
Number number = format.parse(stringValue, parsePosition);
if (parsePosition.getIndex() != stringValue.length()) {
- throw new XWorkException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex());
+ throw new StrutsException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex());
}
return number;
@@ -123,11 +123,11 @@ public class NumberConverter extends DefaultTypeConverter {
Number number = format.parse(stringValue, parsePosition);
if (parsePosition.getIndex() != stringValue.length()) {
- throw new XWorkException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex());
+ throw new StrutsException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex());
}
if (!isInRange(number, stringValue, Double.class)) {
- throw new XWorkException("Overflow or underflow converting: \"" + stringValue + "\" into class " + number.getClass().getName());
+ throw new StrutsException("Overflow or underflow converting: \"" + stringValue + "\" into class " + number.getClass().getName());
}
if (number != null) {
@@ -151,11 +151,11 @@ public class NumberConverter extends DefaultTypeConverter {
Number number = format.parse(stringValue, parsePosition);
if (parsePosition.getIndex() != stringValue.length()) {
- throw new XWorkException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex());
+ throw new StrutsException("Unparseable number: \"" + stringValue + "\" at position " + parsePosition.getIndex());
}
if (!isInRange(number, stringValue, Float.class)) {
- throw new XWorkException("Overflow or underflow converting: \"" + stringValue + "\" into class " + number.getClass().getName());
+ throw new StrutsException("Overflow or underflow converting: \"" + stringValue + "\" into class " + number.getClass().getName());
}
if (number != null) {
diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java
index 973c160..23129a6 100644
--- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java
+++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverter.java
@@ -18,11 +18,11 @@
*/
package com.opensymphony.xwork2.conversion.impl;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.conversion.TypeConverter;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.StrutsException;
import java.lang.reflect.Member;
import java.util.Calendar;
@@ -130,7 +130,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
}
if (result == null && value != null && !"".equals(value)) {
- throw new XWorkException("Cannot create type " + toType + " from value " + value);
+ throw new StrutsException("Cannot create type " + toType + " from value " + value);
}
}
@@ -170,7 +170,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
try {
clazz = Class.forName((String) value);
} catch (ClassNotFoundException e) {
- throw new XWorkException(e.getLocalizedMessage(), e);
+ throw new StrutsException(e.getLocalizedMessage(), e);
}
}
return clazz;
@@ -179,7 +179,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
private Object doConvertToCollection(Map context, Object o, Member member, String prop, Object value, Class toType) {
TypeConverter converter = container.getInstance(CollectionConverter.class);
if (converter == null) {
- throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_COLLECTION);
+ throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_COLLECTION);
}
return converter.convertValue(context, o, member, prop, value, toType);
}
@@ -187,7 +187,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
private Object doConvertToArray(Map context, Object o, Member member, String prop, Object value, Class toType) {
TypeConverter converter = container.getInstance(ArrayConverter.class);
if (converter == null) {
- throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_ARRAY);
+ throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_ARRAY);
}
return converter.convertValue(context, o, member, prop, value, toType);
}
@@ -195,7 +195,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
private Object doConvertToDate(Map context, Object value, Class toType) {
TypeConverter converter = container.getInstance(DateConverter.class);
if (converter == null) {
- throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_DATE);
+ throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_DATE);
}
return converter.convertValue(context, null, null, null, value, toType);
}
@@ -203,7 +203,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
private Object doConvertToNumber(Map context, Object value, Class toType) {
TypeConverter converter = container.getInstance(NumberConverter.class);
if (converter == null) {
- throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_NUMBER);
+ throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_NUMBER);
}
return converter.convertValue(context, null, null, null, value, toType);
}
@@ -211,7 +211,7 @@ public class XWorkBasicConverter extends DefaultTypeConverter {
private Object doConvertToString(Map context, Object value) {
TypeConverter converter = container.getInstance(StringConverter.class);
if (converter == null) {
- throw new XWorkException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_STRING);
+ throw new StrutsException("TypeConverter with name [#0] must be registered first!", StrutsConstants.STRUTS_CONVERTER_STRING);
}
return converter.convertValue(context, null, null, null, value, null);
}
diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkList.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkList.java
index 38da102..6243c10 100644
--- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkList.java
+++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkList.java
@@ -20,10 +20,10 @@ package com.opensymphony.xwork2.conversion.impl;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ObjectFactory;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.conversion.TypeConverter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.struts2.StrutsException;
import java.util.ArrayList;
import java.util.Collection;
@@ -188,7 +188,7 @@ public class XWorkList extends ArrayList {
try {
this.add(getObjectFactory().buildBean(clazz, ActionContext.getContext().getContextMap()));
} catch (Exception e) {
- throw new XWorkException(e);
+ throw new StrutsException(e);
}
}
diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptor.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptor.java
index 8519aa2..22da179 100644
--- a/core/src/main/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptor.java
+++ b/core/src/main/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptor.java
@@ -21,9 +21,9 @@ package com.opensymphony.xwork2.interceptor;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ObjectFactory;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.inject.Inject;
+import org.apache.struts2.StrutsException;
import java.lang.reflect.Method;
import java.util.Map;
@@ -127,7 +127,7 @@ public class ScopedModelDrivenInterceptor extends AbstractInterceptor {
Class cls = method.getReturnType();
cName = cls.getName();
} catch (NoSuchMethodException e) {
- throw new XWorkException("The " + GET_MODEL + "() is not defined in action " + action.getClass() + "", config);
+ throw new StrutsException("The " + GET_MODEL + "() is not defined in action " + action.getClass() + "", config);
}
}
String modelName = name;
diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptor.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptor.java
index 4cbfc7a..39b1252 100644
--- a/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptor.java
+++ b/core/src/main/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptor.java
@@ -19,10 +19,10 @@
package com.opensymphony.xwork2.interceptor.annotations;
import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.opensymphony.xwork2.interceptor.PreResultListener;
import org.apache.commons.lang3.reflect.MethodUtils;
+import org.apache.struts2.StrutsException;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -191,7 +191,7 @@ public class AnnotationWorkflowInterceptor extends AbstractInterceptor implement
try {
MethodUtils.invokeMethod(action, true, m.getName());
} catch (Exception e) {
- throw new XWorkException(e);
+ throw new StrutsException(e);
}
}
}
diff --git a/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java b/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
index c610c42..5aec937 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
@@ -20,7 +20,6 @@ package com.opensymphony.xwork2.ognl;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.TextProvider;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.inject.Inject;
@@ -35,6 +34,7 @@ import org.apache.commons.lang3.BooleanUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.StrutsException;
import java.io.Serializable;
import java.util.HashMap;
@@ -196,7 +196,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
String message = ErrorMessageBuilder.create()
.errorSettingExpressionWithValue(expr, value)
.build();
- throw new XWorkException(message, re);
+ throw new StrutsException(message, re);
} else {
LOG.warn("Error setting value [{}] with expression [{}]", value, expr, re);
}
@@ -216,7 +216,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
}
if (throwExceptionOnFailure) {
- throw new XWorkException(msg, e);
+ throw new StrutsException(msg, e);
}
}
@@ -264,7 +264,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
logLookupFailure(expr, e);
if (throwExceptionOnFailure)
- throw new XWorkException(e);
+ throw new StrutsException(e);
return findInContext(expr);
}
@@ -339,7 +339,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
LOG.warn("Could not find property [{}]!", expr, e);
}
if (throwExceptionOnFailure) {
- throw new XWorkException(e);
+ throw new StrutsException(e);
}
}
return ret;
diff --git a/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java b/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java
index 811b008..8d83e33 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/CompoundRootAccessor.java
@@ -18,7 +18,6 @@
*/
package com.opensymphony.xwork2.ognl.accessor;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.ognl.OgnlValueStack;
import com.opensymphony.xwork2.util.CompoundRoot;
@@ -28,6 +27,7 @@ import org.apache.commons.lang3.BooleanUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.StrutsException;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
@@ -111,7 +111,7 @@ public class CompoundRootAccessor implements PropertyAccessor, MethodAccessor, C
final String msg = format("No object in the CompoundRoot has a publicly accessible property named '%s' " +
"(no setter could be found).", name);
if (reportError) {
- throw new XWorkException(msg);
+ throw new StrutsException(msg);
} else {
LOG.warn(msg);
}
@@ -146,7 +146,7 @@ public class CompoundRootAccessor implements PropertyAccessor, MethodAccessor, C
} catch (OgnlException e) {
if (e.getReason() != null) {
final String msg = "Caught an Ognl exception while getting property " + name;
- throw new XWorkException(msg, e);
+ throw new StrutsException(msg, e);
}
} catch (IntrospectionException e) {
// this is OK if this happens, we'll just keep trying the next
diff --git a/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java b/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java
index 242d097..6f3a682 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ognl/accessor/XWorkListPropertyAccessor.java
@@ -19,7 +19,6 @@
package com.opensymphony.xwork2.ognl.accessor;
import com.opensymphony.xwork2.ObjectFactory;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer;
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
import com.opensymphony.xwork2.inject.Inject;
@@ -29,6 +28,7 @@ import ognl.ListPropertyAccessor;
import ognl.OgnlException;
import ognl.PropertyAccessor;
import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.StrutsException;
import java.util.Collection;
import java.util.List;
@@ -121,7 +121,7 @@ public class XWorkListPropertyAccessor extends ListPropertyAccessor {
try {
list.add(index, result = objectFactory.buildBean(beanClass, context));
} catch (Exception exc) {
- throw new XWorkException(exc);
+ throw new StrutsException(exc);
}
return result;
} else if (list.get(index) == null) {
@@ -129,7 +129,7 @@ public class XWorkListPropertyAccessor extends ListPropertyAccessor {
try {
list.set(index, result = objectFactory.buildBean(beanClass, context));
} catch (Exception exc) {
- throw new XWorkException(exc);
+ throw new StrutsException(exc);
}
return result;
}
diff --git a/core/src/main/java/com/opensymphony/xwork2/util/ClassPathFinder.java b/core/src/main/java/com/opensymphony/xwork2/util/ClassPathFinder.java
index 2bcbfb0..7ab188c 100644
--- a/core/src/main/java/com/opensymphony/xwork2/util/ClassPathFinder.java
+++ b/core/src/main/java/com/opensymphony/xwork2/util/ClassPathFinder.java
@@ -18,7 +18,7 @@
*/
package com.opensymphony.xwork2.util;
-import com.opensymphony.xwork2.XWorkException;
+import org.apache.struts2.StrutsException;
import java.io.File;
import java.io.FileInputStream;
@@ -178,7 +178,7 @@ public class ClassPathFinder {
try {
urls = Collections.list(loader.getResources("")).toArray(new URL[0]);
} catch (IOException e) {
- throw new XWorkException("unable to get ClassLoader URLs", e);
+ throw new StrutsException("unable to get ClassLoader URLs", e);
}
}
diff --git a/core/src/main/java/com/opensymphony/xwork2/util/DomHelper.java b/core/src/main/java/com/opensymphony/xwork2/util/DomHelper.java
index b818764..f1021dc 100644
--- a/core/src/main/java/com/opensymphony/xwork2/util/DomHelper.java
+++ b/core/src/main/java/com/opensymphony/xwork2/util/DomHelper.java
@@ -20,11 +20,11 @@ package com.opensymphony.xwork2.util;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ObjectFactory;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.util.location.Location;
import com.opensymphony.xwork2.util.location.LocationAttributes;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.struts2.StrutsException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -105,7 +105,7 @@ public class DomHelper {
try {
parser = factory.newSAXParser();
} catch (Exception ex) {
- throw new XWorkException("Unable to create SAX parser", ex);
+ throw new StrutsException("Unable to create SAX parser", ex);
}
@@ -117,7 +117,7 @@ public class DomHelper {
try {
parser.parse(inputSource, new StartHandler(locationHandler, dtdMappings));
} catch (Exception ex) {
- throw new XWorkException(ex);
+ throw new StrutsException(ex);
}
return builder.getDocument();
@@ -212,7 +212,7 @@ public class DomHelper {
}
handler.setResult(this.result);
} catch (javax.xml.transform.TransformerException local) {
- throw new XWorkException("Fatal-Error: Unable to get transformer handler", local);
+ throw new StrutsException("Fatal-Error: Unable to get transformer handler", local);
}
}
diff --git a/core/src/main/java/com/opensymphony/xwork2/util/classloader/ReloadingClassLoader.java b/core/src/main/java/com/opensymphony/xwork2/util/classloader/ReloadingClassLoader.java
index c1a83e8..159e57b 100644
--- a/core/src/main/java/com/opensymphony/xwork2/util/classloader/ReloadingClassLoader.java
+++ b/core/src/main/java/com/opensymphony/xwork2/util/classloader/ReloadingClassLoader.java
@@ -21,10 +21,10 @@ package com.opensymphony.xwork2.util.classloader;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.FileManager;
import com.opensymphony.xwork2.FileManagerFactory;
-import com.opensymphony.xwork2.XWorkException;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.struts2.StrutsException;
import java.io.File;
import java.io.InputStream;
@@ -66,10 +66,10 @@ public class ReloadingClassLoader extends ClassLoader {
if (root != null) {
stores = new ResourceStore[]{new FileResourceStore(new File(root.toURI()))};
} else {
- throw new XWorkException("Unable to start the reloadable class loader, consider setting 'struts.convention.classes.reload' to false");
+ throw new StrutsException("Unable to start the reloadable class loader, consider setting 'struts.convention.classes.reload' to false");
}
} catch (URISyntaxException e) {
- throw new XWorkException("Unable to start the reloadable class loader, consider setting 'struts.convention.classes.reload' to false", e);
+ throw new StrutsException("Unable to start the reloadable class loader, consider setting 'struts.convention.classes.reload' to false", e);
} catch (RuntimeException e) {
// see WW-3121
// TODO: Fix this for a reloading mechanism to be marked as stable
diff --git a/core/src/main/java/com/opensymphony/xwork2/util/reflection/ReflectionException.java b/core/src/main/java/com/opensymphony/xwork2/util/reflection/ReflectionException.java
index a1159bd..9809d80 100644
--- a/core/src/main/java/com/opensymphony/xwork2/util/reflection/ReflectionException.java
+++ b/core/src/main/java/com/opensymphony/xwork2/util/reflection/ReflectionException.java
@@ -18,9 +18,9 @@
*/
package com.opensymphony.xwork2.util.reflection;
-import com.opensymphony.xwork2.XWorkException;
+import org.apache.struts2.StrutsException;
-public class ReflectionException extends XWorkException {
+public class ReflectionException extends StrutsException {
public ReflectionException() {
// TODO Auto-generated constructor stub
diff --git a/core/src/main/java/com/opensymphony/xwork2/validator/DefaultValidatorFactory.java b/core/src/main/java/com/opensymphony/xwork2/validator/DefaultValidatorFactory.java
index ca11235..f5f781e 100644
--- a/core/src/main/java/com/opensymphony/xwork2/validator/DefaultValidatorFactory.java
+++ b/core/src/main/java/com/opensymphony/xwork2/validator/DefaultValidatorFactory.java
@@ -20,13 +20,13 @@ package com.opensymphony.xwork2.validator;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ObjectFactory;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.inject.Initializable;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ClassLoaderUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.struts2.StrutsException;
import java.io.File;
import java.io.FilenameFilter;
@@ -75,7 +75,7 @@ public class DefaultValidatorFactory implements ValidatorFactory, Initializable
validator = objectFactory.buildValidator(className, cfg.getParams(), ActionContext.getContext().getContextMap());
} catch (Exception e) {
final String msg = "There was a problem creating a Validator of type " + className + " : caused by " + e.getMessage();
- throw new XWorkException(msg, e, cfg);
+ throw new StrutsException(msg, e, cfg);
}
// set other configured properties
diff --git a/core/src/main/java/org/apache/struts2/StrutsException.java b/core/src/main/java/org/apache/struts2/StrutsException.java
index 4cff275..2838f40 100644
--- a/core/src/main/java/org/apache/struts2/StrutsException.java
+++ b/core/src/main/java/org/apache/struts2/StrutsException.java
@@ -18,16 +18,16 @@
*/
package org.apache.struts2;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.util.location.Locatable;
+import com.opensymphony.xwork2.util.location.Location;
+import com.opensymphony.xwork2.util.location.LocationUtils;
/**
* A generic runtime exception that optionally contains Location information
*/
-public class StrutsException extends XWorkException implements Locatable {
-
- private static final long serialVersionUID = 888724366243600135L;
+public class StrutsException extends RuntimeException implements Locatable {
+ private Location location;
/**
* Constructs a StrutsException
with no detail message.
@@ -96,6 +96,45 @@ public class StrutsException extends XWorkException implements Locatable {
* @param target The target of the exception
*/
public StrutsException(String s, Throwable cause, Object target) {
- super(s, cause, target);
+ super(s, cause);
+
+ this.location = LocationUtils.getLocation(target);
+ if (this.location == Location.UNKNOWN) {
+ this.location = LocationUtils.getLocation(cause);
+ }
+ }
+
+ /**
+ * Gets the location of the error, if available
+ *
+ * @return the location, null if not available
+ */
+ public Location getLocation() {
+ return this.location;
+ }
+
+ /**
+ * Returns a short description of this throwable object, including the
+ * location. If no detailed message is available, it will use the message
+ * of the underlying exception if available.
+ *
+ * @return a string representation of this Throwable
.
+ */
+ @Override
+ public String toString() {
+ String msg = getMessage();
+ if (msg == null && getCause() != null) {
+ msg = getCause().getMessage();
+ }
+
+ if (location != null) {
+ if (msg != null) {
+ return msg + " - " + location.toString();
+ } else {
+ return location.toString();
+ }
+ } else {
+ return msg;
+ }
}
}
\ No newline at end of file
diff --git a/core/src/main/java/org/apache/struts2/util/StrutsTypeConverter.java b/core/src/main/java/org/apache/struts2/util/StrutsTypeConverter.java
index d9c887b..655eeab 100644
--- a/core/src/main/java/org/apache/struts2/util/StrutsTypeConverter.java
+++ b/core/src/main/java/org/apache/struts2/util/StrutsTypeConverter.java
@@ -38,7 +38,7 @@ import com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter;
* failed. By default it just ask its super class (Ognl's DefaultTypeConverter) to do the conversion.
*
*
- * To allow the framework to recognize that a conversion error has occurred, throw an XWorkException or
+ *
To allow the framework to recognize that a conversion error has occurred, throw an StrutsException or
* preferable a TypeConversionException.
*
*
diff --git a/core/src/test/java/com/opensymphony/xwork2/ActionInvocationTest.java b/core/src/test/java/com/opensymphony/xwork2/ActionInvocationTest.java
index 55956e3..ce93c3f 100644
--- a/core/src/test/java/com/opensymphony/xwork2/ActionInvocationTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/ActionInvocationTest.java
@@ -20,12 +20,12 @@ package com.opensymphony.xwork2;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
+import org.apache.struts2.StrutsException;
import org.apache.struts2.dispatcher.HttpParameters;
import com.opensymphony.xwork2.mock.MockResult;
import java.util.HashMap;
-
/**
* @author $Author$
* @version $Revision$
@@ -51,12 +51,12 @@ public class ActionInvocationTest extends XWorkTestCase {
public void testCommandInvocationUnknownHandler() throws Exception {
UnknownHandler unknownHandler = new UnknownHandler() {
- public ActionConfig handleUnknownAction(String namespace, String actionName) throws XWorkException {
+ public ActionConfig handleUnknownAction(String namespace, String actionName) throws StrutsException {
return new ActionConfig.Builder("test", actionName, ActionSupport.class.getName())
.addAllowedMethod("unknownmethod")
.build();
}
- public Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) throws XWorkException {
+ public Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig, String resultCode) throws StrutsException {
return new MockResult();
}
public Object handleUnknownActionMethod(Object action, String methodName) {
@@ -84,7 +84,7 @@ public class ActionInvocationTest extends XWorkTestCase {
public void testResultReturnInvocationAndWired() throws Exception {
ActionProxy baseActionProxy = actionProxyFactory.createActionProxy(
"baz", "resultAction", null, null);
- assertEquals(null, baseActionProxy.execute());
+ assertNull(baseActionProxy.execute());
assertTrue(SimpleAction.resultCalled);
}
diff --git a/core/src/test/java/com/opensymphony/xwork2/ChainResultTest.java b/core/src/test/java/com/opensymphony/xwork2/ChainResultTest.java
index 9c2208e..2d6ac54 100644
--- a/core/src/test/java/com/opensymphony/xwork2/ChainResultTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/ChainResultTest.java
@@ -22,6 +22,7 @@ import com.mockobjects.dynamic.Mock;
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
import com.opensymphony.xwork2.util.ValueStack;
import junit.framework.TestCase;
+import org.apache.struts2.StrutsException;
import java.util.HashMap;
import java.util.Map;
@@ -113,7 +114,7 @@ public class ChainResultTest extends XWorkTestCase {
try {
proxy.execute();
fail("did not detected repeated chain to an action");
- } catch (XWorkException e) {
+ } catch (StrutsException e) {
assertTrue(true);
}
}
diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/SomeUnknownHandler.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/SomeUnknownHandler.java
index 1f1b006..865bcde 100644
--- a/core/src/test/java/com/opensymphony/xwork2/config/providers/SomeUnknownHandler.java
+++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/SomeUnknownHandler.java
@@ -21,14 +21,14 @@ package com.opensymphony.xwork2.config.providers;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.Result;
import com.opensymphony.xwork2.UnknownHandler;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.config.entities.ActionConfig;
+import org.apache.struts2.StrutsException;
public class SomeUnknownHandler implements UnknownHandler{
private ActionConfig actionConfig;
private String actionMethodResult;
- public ActionConfig handleUnknownAction(String namespace, String actionName) throws XWorkException {
+ public ActionConfig handleUnknownAction(String namespace, String actionName) throws StrutsException {
return actionConfig;
}
@@ -37,7 +37,7 @@ public class SomeUnknownHandler implements UnknownHandler{
}
public Result handleUnknownResult(ActionContext actionContext, String actionName, ActionConfig actionConfig,
- String resultCode) throws XWorkException {
+ String resultCode) throws StrutsException {
return null;
}
diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java
index f8c3e7e..e171261 100644
--- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java
@@ -19,9 +19,9 @@
package com.opensymphony.xwork2.conversion.impl;
import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.XWorkTestCase;
import com.opensymphony.xwork2.test.annotations.Person;
+import org.apache.struts2.StrutsException;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -45,15 +45,15 @@ public class XWorkBasicConverterTest extends XWorkTestCase {
public void testDateConversionWithEmptyValue() {
Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, "", Date.class);
- // we must not get XWorkException as that will caused a conversion error
+ // we must not get StrutsException as that will caused a conversion error
assertNull(convertedObject);
}
public void testDateConversionWithInvalidValue() throws Exception {
try {
basicConverter.convertValue(new HashMap(), null, null, null, "asdsd", Date.class);
- fail("XWorkException expected - conversion error occurred");
- } catch (XWorkException e) {
+ fail("StrutsException expected - conversion error occurred");
+ } catch (StrutsException e) {
// we MUST get this exception as this is a conversion error
}
}
@@ -119,7 +119,7 @@ public class XWorkBasicConverterTest extends XWorkTestCase {
public void testEmptyArrayConversion() throws Exception {
Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, new Object[]{}, Object[].class);
- // we must not get XWorkException as that will caused a conversion error
+ // we must not get StrutsException as that will caused a conversion error
assertEquals(Object[].class, convertedObject.getClass());
Object[] obj = (Object[]) convertedObject;
assertEquals(0, obj.length);
@@ -127,7 +127,7 @@ public class XWorkBasicConverterTest extends XWorkTestCase {
public void testNullArrayConversion() throws Exception {
Object convertedObject = basicConverter.convertValue(new HashMap(), null, null, null, null, Object[].class);
- // we must not get XWorkException as that will caused a conversion error
+ // we must not get StrutsException as that will caused a conversion error
assertNull(convertedObject);
}
diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/ExceptionMappingInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/ExceptionMappingInterceptorTest.java
index 6ea92db..8c759d5 100644
--- a/core/src/test/java/com/opensymphony/xwork2/interceptor/ExceptionMappingInterceptorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/ExceptionMappingInterceptorTest.java
@@ -24,6 +24,7 @@ import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.ExceptionMappingConfig;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.validator.ValidationException;
+import org.apache.struts2.StrutsException;
import java.util.HashMap;
@@ -44,9 +45,9 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
this.setUpWithExceptionMappings();
Mock action = new Mock(Action.class);
- Exception exception = new XWorkException("test");
+ Exception exception = new StrutsException("test");
mockInvocation.expectAndThrow("invoke", exception);
- mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
+ mockInvocation.matchAndReturn("getAction", action.proxy());
String result = interceptor.intercept(invocation);
assertNotNull(stack.findValue("exception"));
assertEquals(stack.findValue("exception"), exception);
@@ -61,7 +62,7 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
Mock action = new Mock(Action.class);
Exception exception = new ValidationException("test");
mockInvocation.expectAndThrow("invoke", exception);
- mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
+ mockInvocation.matchAndReturn("getAction", action.proxy());
String result = interceptor.intercept(invocation);
assertNotNull(stack.findValue("exception"));
assertEquals(stack.findValue("exception"), exception);
@@ -73,19 +74,19 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
Mock action = new Mock(Action.class);
mockInvocation.expectAndReturn("invoke", Action.SUCCESS);
- mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
+ mockInvocation.matchAndReturn("getAction", action.proxy());
String result = interceptor.intercept(invocation);
assertEquals(result, Action.SUCCESS);
assertNull(stack.findValue("exception"));
}
- public void testThrownExceptionNoMatch() throws Exception {
+ public void testThrownExceptionNoMatch() {
this.setupWithoutExceptionMappings();
Mock action = new Mock(Action.class);
Exception exception = new Exception("test");
mockInvocation.expectAndThrow("invoke", exception);
- mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
+ mockInvocation.matchAndReturn("getAction", action.proxy());
try {
interceptor.intercept(invocation);
@@ -95,13 +96,13 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
}
}
- public void testThrownExceptionNoMatchLogging() throws Exception {
+ public void testThrownExceptionNoMatchLogging() {
this.setupWithoutExceptionMappings();
Mock action = new Mock(Action.class);
Exception exception = new Exception("test");
mockInvocation.expectAndThrow("invoke", exception);
- mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
+ mockInvocation.matchAndReturn("getAction", action.proxy());
try {
interceptor.setLogEnabled(true);
@@ -112,13 +113,13 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
}
}
- public void testThrownExceptionNoMatchLoggingCategory() throws Exception {
+ public void testThrownExceptionNoMatchLoggingCategory() {
this.setupWithoutExceptionMappings();
Mock action = new Mock(Action.class);
Exception exception = new Exception("test");
mockInvocation.expectAndThrow("invoke", exception);
- mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
+ mockInvocation.matchAndReturn("getAction", action.proxy());
try {
interceptor.setLogEnabled(true);
@@ -130,13 +131,13 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
}
}
- public void testThrownExceptionNoMatchLoggingCategoryLevelFatal() throws Exception {
+ public void testThrownExceptionNoMatchLoggingCategoryLevelFatal() {
this.setupWithoutExceptionMappings();
Mock action = new Mock(Action.class);
Exception exception = new Exception("test");
mockInvocation.expectAndThrow("invoke", exception);
- mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
+ mockInvocation.matchAndReturn("getAction", action.proxy());
try {
interceptor.setLogEnabled(true);
@@ -149,17 +150,17 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
}
assertEquals("fatal", interceptor.getLogLevel());
- assertEquals(true, interceptor.isLogEnabled());
+ assertTrue(interceptor.isLogEnabled());
assertEquals("showcase.unhandled", interceptor.getLogCategory());
}
- public void testThrownExceptionNoMatchLoggingCategoryLevelError() throws Exception {
+ public void testThrownExceptionNoMatchLoggingCategoryLevelError() {
this.setupWithoutExceptionMappings();
Mock action = new Mock(Action.class);
Exception exception = new Exception("test");
mockInvocation.expectAndThrow("invoke", exception);
- mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
+ mockInvocation.matchAndReturn("getAction", action.proxy());
try {
interceptor.setLogEnabled(true);
@@ -172,13 +173,13 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
}
}
- public void testThrownExceptionNoMatchLoggingCategoryLevelWarn() throws Exception {
+ public void testThrownExceptionNoMatchLoggingCategoryLevelWarn() {
this.setupWithoutExceptionMappings();
Mock action = new Mock(Action.class);
Exception exception = new Exception("test");
mockInvocation.expectAndThrow("invoke", exception);
- mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
+ mockInvocation.matchAndReturn("getAction", action.proxy());
try {
interceptor.setLogEnabled(true);
@@ -191,13 +192,13 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
}
}
- public void testThrownExceptionNoMatchLoggingCategoryLevelInfo() throws Exception {
+ public void testThrownExceptionNoMatchLoggingCategoryLevelInfo() {
this.setupWithoutExceptionMappings();
Mock action = new Mock(Action.class);
Exception exception = new Exception("test");
mockInvocation.expectAndThrow("invoke", exception);
- mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
+ mockInvocation.matchAndReturn("getAction", action.proxy());
try {
interceptor.setLogEnabled(true);
@@ -210,13 +211,13 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
}
}
- public void testThrownExceptionNoMatchLoggingCategoryLevelDebug() throws Exception {
+ public void testThrownExceptionNoMatchLoggingCategoryLevelDebug() {
this.setupWithoutExceptionMappings();
Mock action = new Mock(Action.class);
Exception exception = new Exception("test");
mockInvocation.expectAndThrow("invoke", exception);
- mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
+ mockInvocation.matchAndReturn("getAction", action.proxy());
try {
interceptor.setLogEnabled(true);
@@ -229,13 +230,13 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
}
}
- public void testThrownExceptionNoMatchLoggingCategoryLevelTrace() throws Exception {
+ public void testThrownExceptionNoMatchLoggingCategoryLevelTrace() {
this.setupWithoutExceptionMappings();
Mock action = new Mock(Action.class);
Exception exception = new Exception("test");
mockInvocation.expectAndThrow("invoke", exception);
- mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
+ mockInvocation.matchAndReturn("getAction", action.proxy());
try {
interceptor.setLogEnabled(true);
@@ -254,7 +255,7 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
Mock action = new Mock(Action.class);
Exception exception = new Exception("test");
mockInvocation.expectAndThrow("invoke", exception);
- mockInvocation.matchAndReturn("getAction", ((Action) action.proxy()));
+ mockInvocation.matchAndReturn("getAction", action.proxy());
try {
interceptor.setLogEnabled(true);
@@ -270,18 +271,18 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
ActionConfig actionConfig = new ActionConfig.Builder("", "", "").build();
Mock actionProxy = new Mock(ActionProxy.class);
actionProxy.expectAndReturn("getConfig", actionConfig);
- mockInvocation.expectAndReturn("getProxy", ((ActionProxy) actionProxy.proxy()));
+ mockInvocation.expectAndReturn("getProxy", actionProxy.proxy());
invocation = (ActionInvocation) mockInvocation.proxy();
}
private void setUpWithExceptionMappings() {
ActionConfig actionConfig = new ActionConfig.Builder("", "", "")
- .addExceptionMapping(new ExceptionMappingConfig.Builder("xwork", "com.opensymphony.xwork2.XWorkException", "spooky").build())
+ .addExceptionMapping(new ExceptionMappingConfig.Builder("xwork", "org.apache.struts2.StrutsException", "spooky").build())
.addExceptionMapping(new ExceptionMappingConfig.Builder("throwable", "java.lang.Throwable", "throwable").build())
.build();
Mock actionProxy = new Mock(ActionProxy.class);
actionProxy.expectAndReturn("getConfig", actionConfig);
- mockInvocation.expectAndReturn("getProxy", ((ActionProxy) actionProxy.proxy()));
+ mockInvocation.expectAndReturn("getProxy", actionProxy.proxy());
invocation = (ActionInvocation) mockInvocation.proxy();
}
@@ -292,7 +293,7 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase {
stack = ActionContext.getContext().getValueStack();
mockInvocation = new Mock(ActionInvocation.class);
mockInvocation.expectAndReturn("getStack", stack);
- mockInvocation.expectAndReturn("getInvocationContext", new ActionContext(new HashMap()));
+ mockInvocation.expectAndReturn("getInvocationContext", new ActionContext(new HashMap<>()));
interceptor = new ExceptionMappingInterceptor();
interceptor.init();
}
diff --git a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
index 5efccbf..ed6896a 100644
--- a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
@@ -19,7 +19,6 @@
package com.opensymphony.xwork2.ognl;
import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.XWorkTestCase;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
@@ -33,6 +32,7 @@ import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
import java.beans.IntrospectionException;
import ognl.*;
import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.StrutsException;
import java.lang.reflect.Method;
import java.text.DateFormat;
@@ -1537,7 +1537,7 @@ public class OgnlUtilTest extends XWorkTestCase {
try {
this.add(clazz.newInstance());
} catch (Exception e) {
- throw new XWorkException(e);
+ throw new StrutsException(e);
}
}
diff --git a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java
index 8fd8cfb..e84956b 100644
--- a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java
@@ -47,6 +47,7 @@ import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.StrutsException;
import org.apache.struts2.config.DefaultPropertiesProvider;
@@ -774,7 +775,7 @@ public class OgnlValueStackTest extends XWorkTestCase {
try {
vs.setValue("count2", "a", true);
fail("Expected an exception for mismatched getter and setter");
- } catch (XWorkException e) {
+ } catch (StrutsException e) {
//expected
}
}
@@ -792,7 +793,7 @@ public class OgnlValueStackTest extends XWorkTestCase {
try {
vs.setValue("count2", "a", true);
fail("Expected an exception for mismatched getter and setter");
- } catch (XWorkException e) {
+ } catch (StrutsException e) {
//expected
}
}
@@ -874,7 +875,7 @@ public class OgnlValueStackTest extends XWorkTestCase {
try {
stack.setValue("bean", "foobar", true);
fail("Should have thrown a type conversion exception");
- } catch (XWorkException e) {
+ } catch (StrutsException e) {
// expected
}
@@ -1172,7 +1173,7 @@ public class OgnlValueStackTest extends XWorkTestCase {
try {
stack.setValue("count", "a", true);
fail("Should have thrown a type conversion exception");
- } catch (XWorkException e) {
+ } catch (StrutsException e) {
// expected
}
diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java
index 623480d..814b8d8 100644
--- a/core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java
@@ -25,7 +25,6 @@ import com.opensymphony.xwork2.FileManagerFactory;
import com.opensymphony.xwork2.SimpleAction;
import com.opensymphony.xwork2.StubValueStack;
import com.opensymphony.xwork2.TestBean;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.XWorkTestCase;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.test.DataAware2;
@@ -34,6 +33,7 @@ import com.opensymphony.xwork2.test.SimpleAction3;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.fs.DefaultFileManager;
import com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory;
+import org.apache.struts2.StrutsException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -111,7 +111,7 @@ public class DefaultActionValidatorManagerTest extends XWorkTestCase {
C.args(C.IS_NOT_NULL, C.IS_NOT_NULL, C.eq("com/opensymphony/xwork2/TestBean-badtest-validation.xml")),
new ConfigurationException());
List validatorList = actionValidatorManager.getValidators(TestBean.class, "badtest");
- } catch (XWorkException ex) {
+ } catch (StrutsException ex) {
pass = true;
}
mockValidatorFileParser.verify();
diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/DefaultValidatorFileParserTest.java b/core/src/test/java/com/opensymphony/xwork2/validator/DefaultValidatorFileParserTest.java
index 89363bf..3c41b9f 100644
--- a/core/src/test/java/com/opensymphony/xwork2/validator/DefaultValidatorFileParserTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/validator/DefaultValidatorFileParserTest.java
@@ -20,10 +20,10 @@ package com.opensymphony.xwork2.validator;
import com.mockobjects.dynamic.C;
import com.mockobjects.dynamic.Mock;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.util.ClassLoaderUtil;
import com.opensymphony.xwork2.validator.validators.*;
import junit.framework.TestCase;
+import org.apache.struts2.StrutsException;
import java.io.InputStream;
import java.util.List;
@@ -123,7 +123,7 @@ public class DefaultValidatorFileParserTest extends TestCase {
boolean pass = false;
try {
parser.parseActionValidatorConfigs((ValidatorFactory) mockValidatorFactory.proxy(), is, testFileName3);
- } catch (XWorkException ex) {
+ } catch (StrutsException ex) {
assertTrue("Wrong line number", 24 == ex.getLocation().getLineNumber());
pass = true;
}
@@ -136,7 +136,7 @@ public class DefaultValidatorFileParserTest extends TestCase {
boolean pass = false;
try {
parser.parseActionValidatorConfigs((ValidatorFactory) mockValidatorFactory.proxy(), is, testFileName4);
- } catch (XWorkException ex) {
+ } catch (StrutsException ex) {
assertTrue("Wrong line number: " + ex.getLocation(), 34 == ex.getLocation().getLineNumber());
pass = true;
}
@@ -149,7 +149,7 @@ public class DefaultValidatorFileParserTest extends TestCase {
boolean pass = false;
try {
parser.parseActionValidatorConfigs((ValidatorFactory) mockValidatorFactory.proxy(), is, testFileNameFail);
- } catch (XWorkException ex) {
+ } catch (StrutsException ex) {
assertTrue("Wrong line number: " + ex.getLocation(), 28 == ex.getLocation().getLineNumber());
pass = true;
}
@@ -162,7 +162,7 @@ public class DefaultValidatorFileParserTest extends TestCase {
boolean pass = false;
try {
parser.parseActionValidatorConfigs((ValidatorFactory) mockValidatorFactory.proxy(), is, testFileName5);
- } catch (XWorkException ex) {
+ } catch (StrutsException ex) {
assertTrue("Wrong line number", 24 == ex.getLocation().getLineNumber());
pass = true;
}
diff --git a/core/src/test/java/com/opensymphony/xwork2/XWorkExceptionTest.java b/core/src/test/java/org/apache/struts2/StrutsExceptionTest.java
similarity index 66%
rename from core/src/test/java/com/opensymphony/xwork2/XWorkExceptionTest.java
rename to core/src/test/java/org/apache/struts2/StrutsExceptionTest.java
index 8904d75..59e4859 100644
--- a/core/src/test/java/com/opensymphony/xwork2/XWorkExceptionTest.java
+++ b/core/src/test/java/org/apache/struts2/StrutsExceptionTest.java
@@ -16,33 +16,34 @@
* specific language governing permissions and limitations
* under the License.
*/
-package com.opensymphony.xwork2;
+package org.apache.struts2;
+import com.opensymphony.xwork2.XWorkTestCase;
import com.opensymphony.xwork2.util.location.Location;
-public class XWorkExceptionTest extends XWorkTestCase {
+public class StrutsExceptionTest extends XWorkTestCase {
- public void testUnknown() throws Exception {
- XWorkException e = new XWorkException("testXXX", this);
+ public void testUnknown() {
+ StrutsException e = new StrutsException("testXXX", this);
assertEquals(Location.UNKNOWN, e.getLocation());
}
public void testThrowable() {
- XWorkException e = new XWorkException("testThrowable", new IllegalArgumentException("Arg is null"));
- assertEquals("com/opensymphony/xwork2/XWorkExceptionTest.java", e.getLocation().getURI());
+ StrutsException e = new StrutsException("testThrowable", new IllegalArgumentException("Arg is null"));
+ assertEquals("org/apache/struts2/StrutsExceptionTest.java", e.getLocation().getURI());
String s = e.getLocation().toString();
assertTrue(s.contains("Method: testThrowable"));
}
public void testCauseAndTarget() {
- XWorkException e = new XWorkException(new IllegalArgumentException("Arg is null"), this);
- assertEquals("com/opensymphony/xwork2/XWorkExceptionTest.java", e.getLocation().getURI());
+ StrutsException e = new StrutsException(new IllegalArgumentException("Arg is null"), this);
+ assertEquals("org/apache/struts2/StrutsExceptionTest.java", e.getLocation().getURI());
String s = e.getLocation().toString();
assertTrue(s.contains("Method: testCauseAndTarget"));
}
public void testDefaultConstructor() {
- XWorkException e = new XWorkException();
+ StrutsException e = new StrutsException();
assertNull(e.getCause());
assertNull(e.getMessage());
@@ -52,7 +53,7 @@ public class XWorkExceptionTest extends XWorkTestCase {
}
public void testMessageOnly() {
- XWorkException e = new XWorkException("Hello World");
+ StrutsException e = new StrutsException("Hello World");
assertNull(e.getCause());
assertEquals("Hello World", e.getMessage());
@@ -60,22 +61,22 @@ public class XWorkExceptionTest extends XWorkTestCase {
}
public void testCauseOnly() {
- XWorkException e = new XWorkException(new IllegalArgumentException("Arg is null"));
+ StrutsException e = new StrutsException(new IllegalArgumentException("Arg is null"));
assertNotNull(e.getCause());
assertNotNull(e.getLocation());
- assertEquals("com/opensymphony/xwork2/XWorkExceptionTest.java", e.getLocation().getURI());
+ assertEquals("org/apache/struts2/StrutsExceptionTest.java", e.getLocation().getURI());
String s = e.getLocation().toString();
assertTrue(s.contains("Method: testCauseOnly"));
assertTrue(e.toString().contains("Arg is null"));
}
public void testCauseOnlyNoMessage() {
- XWorkException e = new XWorkException(new IllegalArgumentException());
+ StrutsException e = new StrutsException(new IllegalArgumentException());
assertNotNull(e.getCause());
assertNotNull(e.getLocation());
- assertEquals("com/opensymphony/xwork2/XWorkExceptionTest.java", e.getLocation().getURI());
+ assertEquals("org/apache/struts2/StrutsExceptionTest.java", e.getLocation().getURI());
String s = e.getLocation().toString();
assertTrue(s.contains("Method: testCauseOnly"));
assertTrue(e.toString().contains("Method: testCauseOnly"));
diff --git a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-exception-mappings.xml b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-exception-mappings.xml
index f31b53c..b7f955e 100644
--- a/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-exception-mappings.xml
+++ b/core/src/test/resources/com/opensymphony/xwork2/config/providers/xwork-test-exception-mappings.xml
@@ -39,7 +39,7 @@
-
+
diff --git a/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java b/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java
index 3ad275d9..92e32ae 100644
--- a/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java
+++ b/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java
@@ -30,6 +30,7 @@ import com.opensymphony.xwork2.util.TextParseUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.struts2.StrutsException;
import javax.servlet.ServletContext;
import java.net.MalformedURLException;
@@ -72,7 +73,7 @@ public class ConventionUnknownHandler implements UnknownHandler {
private ConventionsService conventionsService;
private String nameSeparator;
- protected Set allowedMethods = new HashSet<>();
+ protected Set allowedMethods;
/**
* Constructs the unknown handler.
@@ -114,7 +115,7 @@ public class ConventionUnknownHandler implements UnknownHandler {
}
public ActionConfig handleUnknownAction(String namespace, String actionName)
- throws XWorkException {
+ throws StrutsException {
// Strip the namespace if it is just a slash
if (namespace == null || "/".equals(namespace)) {
namespace = "";
@@ -217,7 +218,7 @@ public class ConventionUnknownHandler implements UnknownHandler {
params.put(resultTypeConfig.getDefaultResultParam(), path);
PackageConfig pkg = configuration.getPackageConfig(defaultParentPackageName);
- List interceptors = InterceptorBuilder.constructInterceptorReference(pkg, pkg.getFullDefaultInterceptorRef(), Collections.emptyMap(), null, objectFactory);
+ List interceptors = InterceptorBuilder.constructInterceptorReference(pkg, pkg.getFullDefaultInterceptorRef(), Collections.emptyMap(), null, objectFactory);
ResultConfig config = new ResultConfig.Builder(Action.SUCCESS, resultTypeConfig.getClassName()).
addParams(params).build();
results.put(Action.SUCCESS, config);
@@ -265,7 +266,7 @@ public class ConventionUnknownHandler implements UnknownHandler {
}
public Result handleUnknownResult(ActionContext actionContext, String actionName,
- ActionConfig actionConfig, String resultCode) throws XWorkException {
+ ActionConfig actionConfig, String resultCode) throws StrutsException {
PackageConfig pkg = configuration.getPackageConfig(actionConfig.getPackageName());
String ns = pkg.getNamespace();
@@ -351,7 +352,7 @@ public class ConventionUnknownHandler implements UnknownHandler {
try {
return objectFactory.buildResult(resultConfig, invocationContext.getContextMap());
} catch (Exception e) {
- throw new XWorkException("Unable to build convention result", e, resultConfig);
+ throw new StrutsException("Unable to build convention result", e, resultConfig);
}
}
diff --git a/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultClassFinder.java b/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultClassFinder.java
index 3aaad59..54d5358 100644
--- a/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultClassFinder.java
+++ b/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultClassFinder.java
@@ -21,13 +21,13 @@ package org.apache.struts2.convention;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.FileManager;
import com.opensymphony.xwork2.FileManagerFactory;
-import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.util.finder.ClassFinder;
import com.opensymphony.xwork2.util.finder.ClassLoaderInterface;
import com.opensymphony.xwork2.util.finder.Test;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.struts2.StrutsException;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
@@ -445,10 +445,10 @@ public class DefaultClassFinder implements ClassFinder {
classReader.accept(new InfoBuildingVisitor(this), ClassReader.SKIP_DEBUG);
}
} else {
- throw new XWorkException("Could not load " + className);
+ throw new StrutsException("Could not load " + className);
}
} catch (IOException e) {
- throw new XWorkException("Could not load " + className, e);
+ throw new StrutsException("Could not load " + className, e);
}
}