packageConfi
}
}
+ @Override
public void destroy() {
loadedFileUrls.clear();
+ providerAllowlist.clearAllowlist(this);
}
+ @Override
public boolean needsReload() {
if (devMode && reload) {
for (String url : loadedFileUrls) {
diff --git a/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java b/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java
index c44ca335a7..1643ce7ae5 100644
--- a/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java
+++ b/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java
@@ -18,9 +18,21 @@
*/
package org.apache.struts2.convention;
-import com.opensymphony.xwork2.*;
+import com.opensymphony.xwork2.ActionChainResult;
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.FileManager;
+import com.opensymphony.xwork2.FileManagerFactory;
+import com.opensymphony.xwork2.ObjectFactory;
+import com.opensymphony.xwork2.Result;
import com.opensymphony.xwork2.config.Configuration;
-import com.opensymphony.xwork2.config.entities.*;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+import com.opensymphony.xwork2.config.entities.ExceptionMappingConfig;
+import com.opensymphony.xwork2.config.entities.InterceptorConfig;
+import com.opensymphony.xwork2.config.entities.InterceptorMapping;
+import com.opensymphony.xwork2.config.entities.InterceptorStackConfig;
+import com.opensymphony.xwork2.config.entities.PackageConfig;
+import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.config.entities.ResultTypeConfig;
import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
import com.opensymphony.xwork2.factory.DefaultInterceptorFactory;
import com.opensymphony.xwork2.factory.DefaultResultFactory;
@@ -32,12 +44,20 @@
import com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory;
import com.opensymphony.xwork2.util.reflection.ReflectionException;
import junit.framework.TestCase;
-
import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.convention.actions.DefaultResultPathAction;
import org.apache.struts2.convention.actions.NoAnnotationAction;
import org.apache.struts2.convention.actions.Skip;
-import org.apache.struts2.convention.actions.action.*;
+import org.apache.struts2.convention.actions.action.ActionNameAction;
+import org.apache.struts2.convention.actions.action.ActionNamesAction;
+import org.apache.struts2.convention.actions.action.ClassLevelAnnotationAction;
+import org.apache.struts2.convention.actions.action.ClassLevelAnnotationDefaultMethodAction;
+import org.apache.struts2.convention.actions.action.ClassLevelAnnotationsAction;
+import org.apache.struts2.convention.actions.action.ClassLevelAnnotationsDefaultMethodAction;
+import org.apache.struts2.convention.actions.action.ClassNameAction;
+import org.apache.struts2.convention.actions.action.SingleActionNameAction;
+import org.apache.struts2.convention.actions.action.TestAction;
+import org.apache.struts2.convention.actions.action.TestExtends;
import org.apache.struts2.convention.actions.allowedmethods.ClassLevelAllowedMethodsAction;
import org.apache.struts2.convention.actions.allowedmethods.PackageLevelAllowedMethodsAction;
import org.apache.struts2.convention.actions.allowedmethods.sub.PackageLevelAllowedMethodsChildAction;
@@ -61,7 +81,15 @@
import org.apache.struts2.convention.actions.parentpackage.PackageLevelParentPackageAction;
import org.apache.struts2.convention.actions.parentpackage.sub.ClassLevelParentPackageChildAction;
import org.apache.struts2.convention.actions.parentpackage.sub.PackageLevelParentPackageChildAction;
-import org.apache.struts2.convention.actions.result.*;
+import org.apache.struts2.convention.actions.result.ActionLevelResultAction;
+import org.apache.struts2.convention.actions.result.ActionLevelResultsAction;
+import org.apache.struts2.convention.actions.result.ActionLevelResultsNamesAction;
+import org.apache.struts2.convention.actions.result.ClassLevelResultAction;
+import org.apache.struts2.convention.actions.result.ClassLevelResultsAction;
+import org.apache.struts2.convention.actions.result.GlobalResultAction;
+import org.apache.struts2.convention.actions.result.GlobalResultOverrideAction;
+import org.apache.struts2.convention.actions.result.InheritedResultExtends;
+import org.apache.struts2.convention.actions.result.OverrideResultAction;
import org.apache.struts2.convention.actions.resultpath.ClassLevelResultPathAction;
import org.apache.struts2.convention.actions.resultpath.PackageLevelResultPathAction;
import org.apache.struts2.convention.actions.skip.Index;
@@ -69,15 +97,24 @@
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.dontfind.DontFindMeAction;
+import org.apache.struts2.ognl.ProviderAllowlist;
import org.apache.struts2.result.ServletDispatcherResult;
import org.easymock.EasyMock;
import javax.servlet.ServletContext;
import java.net.MalformedURLException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import static org.apache.struts2.convention.ReflectionTools.getAnnotation;
-import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.checkOrder;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.verify;
/**
*
@@ -388,6 +425,7 @@ public Container getContainer() {
fileManagerFactory.setFileManager(new DefaultFileManager());
builder.setFileManagerFactory(fileManagerFactory);
builder.setPackageLocatorsBase("org.apache.struts2.convention.actions");
+ builder.setProviderAllowlist(new ProviderAllowlist());
builder.buildActionConfigs();
verify(resultMapBuilder);
From 27e4d0d47aded060f12fd2121273d6a4eb69c206 Mon Sep 17 00:00:00 2001
From: Kusal Kithul-Godage
Date: Sat, 13 Jul 2024 23:25:31 +1000
Subject: [PATCH 6/6] WW-5440 Fix inconsistent indenting
---
.../showcase/action/AbstractCRUDAction.java | 92 +++++++++----------
1 file changed, 46 insertions(+), 46 deletions(-)
diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/action/AbstractCRUDAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/action/AbstractCRUDAction.java
index 2880f36581..e5204a1fad 100644
--- a/apps/showcase/src/main/java/org/apache/struts2/showcase/action/AbstractCRUDAction.java
+++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/action/AbstractCRUDAction.java
@@ -34,62 +34,62 @@
public abstract class AbstractCRUDAction extends ActionSupport {
- private static final Logger log = LogManager.getLogger(AbstractCRUDAction.class);
+ private static final Logger log = LogManager.getLogger(AbstractCRUDAction.class);
- private Collection availableItems;
- private String[] toDelete;
+ private Collection availableItems;
+ private String[] toDelete;
- protected abstract Dao getDao();
+ protected abstract Dao getDao();
- public Collection getAvailableItems() {
- return availableItems;
- }
+ public Collection getAvailableItems() {
+ return availableItems;
+ }
- public String[] getToDelete() {
- return toDelete;
- }
+ public String[] getToDelete() {
+ return toDelete;
+ }
- @StrutsParameter
- public void setToDelete(String[] toDelete) {
- this.toDelete = toDelete;
- }
+ @StrutsParameter
+ public void setToDelete(String[] toDelete) {
+ this.toDelete = toDelete;
+ }
- public String list() throws Exception {
- this.availableItems = getDao().findAll();
- if (log.isDebugEnabled()) {
- log.debug("AbstractCRUDAction - [list]: " + (availableItems != null ? "" + availableItems.size() : "no") + " items found");
- }
- return execute();
- }
+ public String list() throws Exception {
+ this.availableItems = getDao().findAll();
+ if (log.isDebugEnabled()) {
+ log.debug("AbstractCRUDAction - [list]: " + (availableItems != null ? "" + availableItems.size() : "no") + " items found");
+ }
+ return execute();
+ }
- public String delete() throws Exception {
- if (toDelete != null) {
- int count = 0;
+ public String delete() throws Exception {
+ if (toDelete != null) {
+ int count = 0;
for (String s : toDelete) {
count = count + getDao().delete(s);
}
- if (log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
log.debug("AbstractCRUDAction - [delete]: {} items deleted.", count);
- }
- }
- return SUCCESS;
- }
+ }
+ }
+ return SUCCESS;
+ }
- /**
- * Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle.
- *
- * @param tryId The id to try to get persistent object for
- * @param tryObject The object, induced by first params invocation, possibly containing id to try to get persistent
- * object for
- * @return The persistent object, if found. null otherwise.
- */
- protected IdEntity fetch(Serializable tryId, IdEntity tryObject) {
- IdEntity result = null;
- if (tryId != null) {
- result = getDao().get(tryId);
- } else if (tryObject != null) {
- result = getDao().get(tryObject.getId());
- }
- return result;
- }
+ /**
+ * Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle.
+ *
+ * @param tryId The id to try to get persistent object for
+ * @param tryObject The object, induced by first params invocation, possibly containing id to try to get persistent
+ * object for
+ * @return The persistent object, if found. null otherwise.
+ */
+ protected IdEntity fetch(Serializable tryId, IdEntity tryObject) {
+ IdEntity result = null;
+ if (tryId != null) {
+ result = getDao().get(tryId);
+ } else if (tryObject != null) {
+ result = getDao().get(tryObject.getId());
+ }
+ return result;
+ }
}