mirror of
https://github.com/apache/struts.git
synced 2026-08-05 14:47:09 +00:00
WW-5411 Misc code cleanup
This commit is contained in:
+13
-10
@@ -31,6 +31,7 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
@@ -41,6 +42,7 @@ import java.util.Date;
|
||||
@Service
|
||||
public class TestDataProvider implements Serializable, InitializingBean {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger log = LogManager.getLogger(TestDataProvider.class);
|
||||
|
||||
@@ -64,9 +66,9 @@ public class TestDataProvider implements Serializable, InitializingBean {
|
||||
};
|
||||
|
||||
public static final Employee[] TEST_EMPLOYEES = {
|
||||
new Employee(new Long(1), "Alan", "Smithee", new Date(), new Float(2000f), true, POSITIONS[0],
|
||||
new Employee(1L, "Alan", "Smithee", new Date(), 2000f, true, POSITIONS[0],
|
||||
TEST_SKILLS[0], null, "alan", LEVELS[0], "Nice guy"),
|
||||
new Employee(new Long(2), "Robert", "Robson", new Date(), new Float(10000f), false, POSITIONS[1],
|
||||
new Employee(2L, "Robert", "Robson", new Date(), 10000f, false, POSITIONS[1],
|
||||
TEST_SKILLS[1], Arrays.asList(TEST_SKILLS).subList(1, TEST_SKILLS.length), "rob", LEVELS[1], "Smart guy")
|
||||
};
|
||||
|
||||
@@ -78,27 +80,27 @@ public class TestDataProvider implements Serializable, InitializingBean {
|
||||
|
||||
protected void addTestSkills() {
|
||||
try {
|
||||
for (int i = 0, j = TEST_SKILLS.length; i < j; i++) {
|
||||
skillDao.merge(TEST_SKILLS[i]);
|
||||
}
|
||||
for (Skill testSkill : TEST_SKILLS) {
|
||||
skillDao.merge(testSkill);
|
||||
}
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("TestDataProvider - [addTestSkills]: Added test skill data.");
|
||||
}
|
||||
} catch (StorageException e) {
|
||||
log.error("TestDataProvider - [addTestSkills]: Exception catched: " + e.getMessage());
|
||||
log.error("TestDataProvider - [addTestSkills]: Exception caught: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void addTestEmployees() {
|
||||
try {
|
||||
for (int i = 0, j = TEST_EMPLOYEES.length; i < j; i++) {
|
||||
employeeDao.merge(TEST_EMPLOYEES[i]);
|
||||
}
|
||||
for (Employee testEmployee : TEST_EMPLOYEES) {
|
||||
employeeDao.merge(testEmployee);
|
||||
}
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("TestDataProvider - [addTestEmployees]: Added test employee data.");
|
||||
}
|
||||
} catch (StorageException e) {
|
||||
log.error("TestDataProvider - [addTestEmployees]: Exception catched: " + e.getMessage());
|
||||
log.error("TestDataProvider - [addTestEmployees]: Exception caught: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +109,7 @@ public class TestDataProvider implements Serializable, InitializingBean {
|
||||
addTestEmployees();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
addTestData();
|
||||
}
|
||||
|
||||
@@ -20,40 +20,29 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.hangman;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Hangman implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 8566954355839652509L;
|
||||
|
||||
private Vocab vocab;
|
||||
private final Vocab vocab;
|
||||
|
||||
private Boolean win = false;
|
||||
|
||||
private int guessLeft = 5;
|
||||
public List<Character> charactersAvailable;
|
||||
public final List<Character> charactersAvailable;
|
||||
public List<Character> charactersGuessed;
|
||||
|
||||
public Hangman(Vocab vocab) {
|
||||
// Arrays.asList(...) returns List that doesn't support remove(), hence
|
||||
// we wrap it with an ArrayList to avoid UnsupportedOperationException
|
||||
// when doing a remove()
|
||||
charactersAvailable = new ArrayList<Character>(Arrays.asList(
|
||||
new Character[]{
|
||||
Character.valueOf('A'), Character.valueOf('B'), Character.valueOf('C'),
|
||||
Character.valueOf('D'), Character.valueOf('E'), Character.valueOf('F'),
|
||||
Character.valueOf('G'), Character.valueOf('H'), Character.valueOf('I'),
|
||||
Character.valueOf('J'), Character.valueOf('K'), Character.valueOf('L'),
|
||||
Character.valueOf('M'), Character.valueOf('N'), Character.valueOf('O'),
|
||||
Character.valueOf('P'), Character.valueOf('Q'), Character.valueOf('R'),
|
||||
Character.valueOf('S'), Character.valueOf('T'), Character.valueOf('U'),
|
||||
Character.valueOf('V'), Character.valueOf('W'), Character.valueOf('X'),
|
||||
Character.valueOf('Y'), Character.valueOf('Z')
|
||||
}));
|
||||
charactersGuessed = new ArrayList<Character>();
|
||||
charactersAvailable = new ArrayList<>(List.of(
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
||||
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'));
|
||||
charactersGuessed = new ArrayList<>();
|
||||
this.vocab = vocab;
|
||||
}
|
||||
|
||||
@@ -98,7 +87,7 @@ public class Hangman implements Serializable {
|
||||
|
||||
public List<Character> getCharactersAvailable() {
|
||||
synchronized (charactersAvailable) {
|
||||
return new ArrayList<Character>(charactersAvailable);
|
||||
return new ArrayList<>(charactersAvailable);
|
||||
//return charactersAvailable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,17 +20,19 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.hangman;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class Vocab implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String vocab;
|
||||
private String hint;
|
||||
private final String vocab;
|
||||
private final String hint;
|
||||
private Character[] characters; // character this vocab is made up of
|
||||
|
||||
public Vocab(String vocab, String hint) {
|
||||
@@ -52,7 +54,7 @@ public class Vocab implements Serializable {
|
||||
public Boolean containCharacter(Character character) {
|
||||
assert (character != null);
|
||||
|
||||
return (vocab.contains(character.toString())) ? true : false;
|
||||
return vocab.contains(character.toString());
|
||||
}
|
||||
|
||||
public Character[] inCharacters() {
|
||||
@@ -60,32 +62,21 @@ public class Vocab implements Serializable {
|
||||
char[] c = vocab.toCharArray();
|
||||
characters = new Character[c.length];
|
||||
for (int a = 0; a < c.length; a++) {
|
||||
characters[a] = Character.valueOf(c[a]);
|
||||
characters[a] = c[a];
|
||||
}
|
||||
}
|
||||
return characters;
|
||||
}
|
||||
|
||||
public boolean containsAllCharacter(List<Character> charactersGuessed) {
|
||||
Character[] chars = inCharacters();
|
||||
List<Character> tmpChars = Arrays.asList(chars);
|
||||
return charactersGuessed.containsAll(tmpChars);
|
||||
return new HashSet<>(charactersGuessed).containsAll(Arrays.asList(inCharacters()));
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Vocab v = new Vocab("JAVA", "a java word");
|
||||
|
||||
List<Character> list1 = new ArrayList<Character>();
|
||||
list1.add(new Character('J'));
|
||||
list1.add(new Character('V'));
|
||||
|
||||
List<Character> list2 = new ArrayList<Character>();
|
||||
list2.add(new Character('J'));
|
||||
list2.add(new Character('V'));
|
||||
list2.add(new Character('A'));
|
||||
|
||||
System.out.println(v.containsAllCharacter(list1));
|
||||
System.out.println(v.containsAllCharacter(list2));
|
||||
System.out.println(v.containsAllCharacter(List.of('J', 'V')));
|
||||
System.out.println(v.containsAllCharacter(List.of('J', 'V', 'A')));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,11 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Provides a default implementation for the most common actions.
|
||||
@@ -160,7 +164,7 @@ public class ActionSupport implements Action, Validateable, ValidationAware, Tex
|
||||
} else {
|
||||
final ValueStack valueStack = ActionContext.getContext().getValueStack();
|
||||
final Object val = valueStack.findValue(expr);
|
||||
return getText(key, Arrays.asList(val));
|
||||
return getText(key, List.of(val));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class DefaultTextProvider implements TextProvider, Serializable, Unchaina
|
||||
|
||||
return format.format(params);
|
||||
}
|
||||
return text;
|
||||
return text;
|
||||
}
|
||||
|
||||
public String getText(String key, String defaultValue, String[] args) {
|
||||
@@ -136,7 +136,7 @@ public class DefaultTextProvider implements TextProvider, Serializable, Unchaina
|
||||
|
||||
public String getText(String key, String defaultValue, String[] args, ValueStack stack) {
|
||||
//we're not using the value stack here
|
||||
List<Object> values = new ArrayList<Object>(Arrays.asList(args));
|
||||
List<Object> values = new ArrayList<>(Arrays.asList(args));
|
||||
return getText(key, defaultValue, values);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ class ContainerImpl implements Container {
|
||||
}
|
||||
|
||||
void addInjectorsForMethods(Method[] methods, boolean statics, List<Injector> injectors) {
|
||||
addInjectorsForMembers(Arrays.asList(methods), statics, injectors, MethodInjector::new);
|
||||
addInjectorsForMembers(List.of(methods), statics, injectors, MethodInjector::new);
|
||||
}
|
||||
|
||||
void addInjectorsForFields(Field[] fields, boolean statics, List<Injector> injectors) {
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -61,6 +62,7 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(OgnlValueStack.class);
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 370737852934925530L;
|
||||
|
||||
private static final String MAP_IDENTIFIER_KEY = "com.opensymphony.xwork2.util.OgnlValueStack.MAP_IDENTIFIER_KEY";
|
||||
|
||||
@@ -33,13 +33,12 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static com.opensymphony.xwork2.util.ConfigParseUtil.toClassObjectsSet;
|
||||
import static com.opensymphony.xwork2.util.ConfigParseUtil.toClassesSet;
|
||||
@@ -49,8 +48,6 @@ import static com.opensymphony.xwork2.util.ConfigParseUtil.toNewPatternsSet;
|
||||
import static com.opensymphony.xwork2.util.ConfigParseUtil.toPackageNamesSet;
|
||||
import static java.text.MessageFormat.format;
|
||||
import static java.util.Collections.emptySet;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.apache.struts2.StrutsConstants.STRUTS_ALLOWLIST_CLASSES;
|
||||
import static org.apache.struts2.StrutsConstants.STRUTS_ALLOWLIST_PACKAGE_NAMES;
|
||||
|
||||
@@ -62,20 +59,20 @@ public class SecurityMemberAccess implements MemberAccess {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(SecurityMemberAccess.class);
|
||||
|
||||
private static final Set<String> ALLOWLIST_REQUIRED_PACKAGES = unmodifiableSet(new HashSet<>(Arrays.asList(
|
||||
private static final Set<String> ALLOWLIST_REQUIRED_PACKAGES = Set.of(
|
||||
"com.opensymphony.xwork2.validator.validators",
|
||||
"org.apache.struts2.components",
|
||||
"org.apache.struts2.views.jsp"
|
||||
)));
|
||||
);
|
||||
|
||||
private static final Set<Class<?>> ALLOWLIST_REQUIRED_CLASSES = unmodifiableSet(new HashSet<>(Arrays.asList(
|
||||
private static final Set<Class<?>> ALLOWLIST_REQUIRED_CLASSES = Set.of(
|
||||
java.lang.Enum.class,
|
||||
java.lang.String.class,
|
||||
java.util.Date.class,
|
||||
java.util.HashMap.class,
|
||||
java.util.Map.class,
|
||||
java.util.Map.Entry.class
|
||||
)));
|
||||
);
|
||||
|
||||
private final ProviderAllowlist providerAllowlist;
|
||||
private final ThreadAllowlist threadAllowlist;
|
||||
@@ -85,7 +82,7 @@ public class SecurityMemberAccess implements MemberAccess {
|
||||
private Set<Pattern> excludeProperties = emptySet();
|
||||
private Set<Pattern> acceptProperties = emptySet();
|
||||
|
||||
private Set<String> excludedClasses = unmodifiableSet(new HashSet<>(singletonList(Object.class.getName())));
|
||||
private Set<String> excludedClasses = Set.of(Object.class.getName());
|
||||
private Set<Pattern> excludedPackageNamePatterns = emptySet();
|
||||
private Set<String> excludedPackageNames = emptySet();
|
||||
private Set<String> excludedPackageExemptClasses = emptySet();
|
||||
@@ -93,7 +90,7 @@ public class SecurityMemberAccess implements MemberAccess {
|
||||
private static volatile boolean isDevModeLogged = false;
|
||||
private volatile boolean isDevModeInit;
|
||||
private boolean isDevMode;
|
||||
private Set<String> devModeExcludedClasses = unmodifiableSet(new HashSet<>(singletonList(Object.class.getName())));
|
||||
private Set<String> devModeExcludedClasses = Set.of(Object.class.getName());
|
||||
private Set<Pattern> devModeExcludedPackageNamePatterns = emptySet();
|
||||
private Set<String> devModeExcludedPackageNames = emptySet();
|
||||
private Set<String> devModeExcludedPackageExemptClasses = emptySet();
|
||||
@@ -395,14 +392,10 @@ public class SecurityMemberAccess implements MemberAccess {
|
||||
}
|
||||
|
||||
public static boolean isClassBelongsToPackages(Class<?> clazz, Set<String> matchingPackages) {
|
||||
List<String> packageParts = Arrays.asList(toPackageName(clazz).split("\\."));
|
||||
for (int i = 0; i < packageParts.size(); i++) {
|
||||
String parentPackage = String.join(".", packageParts.subList(0, i + 1));
|
||||
if (matchingPackages.contains(parentPackage)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
List<String> packageParts = List.of(toPackageName(clazz).split("\\."));
|
||||
return IntStream.range(0, packageParts.size())
|
||||
.mapToObj(i -> String.join(".", packageParts.subList(0, i + 1)))
|
||||
.anyMatch(matchingPackages::contains);
|
||||
}
|
||||
|
||||
protected boolean isClassExcluded(Class<?> clazz) {
|
||||
|
||||
@@ -26,7 +26,12 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -158,7 +163,7 @@ public class DefaultFileManager implements FileManager {
|
||||
}
|
||||
|
||||
public Collection<? extends URL> getAllPhysicalUrls(URL url) throws IOException {
|
||||
return Arrays.asList(url);
|
||||
return List.of(url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,15 +20,12 @@ package org.apache.struts2.factory;
|
||||
|
||||
import com.opensymphony.xwork2.ActionProxy;
|
||||
import com.opensymphony.xwork2.ActionProxyFactory;
|
||||
import com.opensymphony.xwork2.DefaultActionProxyFactory;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.Initializable;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@@ -63,18 +60,13 @@ public class PrefixBasedActionProxyFactory extends StrutsActionProxyFactory impl
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(PrefixBasedActionProxyFactory.class);
|
||||
|
||||
private Map<String, ActionProxyFactory> actionProxyFactories = new HashMap<>();
|
||||
private final Map<String, ActionProxyFactory> actionProxyFactories = new HashMap<>();
|
||||
private Set<String> prefixes = new HashSet<>();
|
||||
|
||||
@Inject
|
||||
public void setContainer(Container container) {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Inject(StrutsConstants.PREFIX_BASED_MAPPER_CONFIGURATION)
|
||||
public void setPrefixBasedActionProxyFactories(String list) {
|
||||
if (list != null) {
|
||||
prefixes = new HashSet<>(Arrays.asList(list.split(",")));
|
||||
prefixes = Set.of(list.split(","));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-5
@@ -25,6 +25,7 @@ import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import com.opensymphony.xwork2.interceptor.PreResultListener;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
@@ -36,21 +37,20 @@ import org.apache.struts2.dispatcher.RequestMap;
|
||||
import org.apache.struts2.views.freemarker.FreemarkerManager;
|
||||
import org.apache.struts2.views.freemarker.FreemarkerResult;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Serial;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
@@ -95,17 +95,18 @@ import java.util.Map;
|
||||
*/
|
||||
public class DebuggingInterceptor extends AbstractInterceptor {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -3097324155953078783L;
|
||||
|
||||
private final static Logger LOG = LogManager.getLogger(DebuggingInterceptor.class);
|
||||
|
||||
private final String[] ignorePrefixes = new String[]{"org.apache.struts.", "com.opensymphony.xwork2.", "xwork."};
|
||||
private final HashSet<String> ignoreKeys = new HashSet<>(Arrays.asList(
|
||||
private final Set<String> ignoreKeys = Set.of(
|
||||
DispatcherConstants.APPLICATION,
|
||||
DispatcherConstants.SESSION,
|
||||
DispatcherConstants.PARAMETERS,
|
||||
DispatcherConstants.REQUEST
|
||||
));
|
||||
);
|
||||
|
||||
private final static String XML_MODE = "xml";
|
||||
private final static String CONSOLE_MODE = "console";
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapper;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -210,7 +209,7 @@ public class ServletActionRedirectResult extends ServletRedirectResult implement
|
||||
}
|
||||
|
||||
protected List<String> getProhibitedResultParams() {
|
||||
return Arrays.asList(
|
||||
return List.of(
|
||||
DEFAULT_PARAM,
|
||||
"namespace",
|
||||
"method",
|
||||
|
||||
@@ -24,6 +24,8 @@ import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionException;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.dispatcher.Dispatcher;
|
||||
@@ -31,13 +33,10 @@ import org.apache.struts2.dispatcher.mapper.ActionMapper;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
import org.apache.struts2.url.QueryStringBuilder;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -217,7 +216,7 @@ public class ServletRedirectResult extends StrutsResultSupport implements Reflec
|
||||
}
|
||||
|
||||
protected List<String> getProhibitedResultParams() {
|
||||
return Arrays.asList(
|
||||
return List.of(
|
||||
DEFAULT_PARAM,
|
||||
"namespace",
|
||||
"method",
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -123,7 +122,7 @@ public class StrutsQueryStringParser implements QueryStringParser {
|
||||
} else {
|
||||
String[] currentParamValues = (String[]) currentParam;
|
||||
if (currentParamValues != null) {
|
||||
List<String> paramList = new ArrayList<>(Arrays.asList(currentParamValues));
|
||||
List<String> paramList = new ArrayList<>(List.of(currentParamValues));
|
||||
paramList.add(value);
|
||||
queryParams.put(name, paramList.toArray(new String[0]));
|
||||
} else {
|
||||
|
||||
@@ -22,9 +22,9 @@ import org.apache.struts2.util.IteratorFilterSupport.EnumerationIterator;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ public class MakeIterator {
|
||||
} else if (value instanceof Enumeration) {
|
||||
iterator = new EnumerationIterator((Enumeration) value);
|
||||
} else {
|
||||
iterator = Arrays.asList(value).iterator();
|
||||
iterator = List.of(value).iterator();
|
||||
}
|
||||
|
||||
return iterator;
|
||||
|
||||
+7
-6
@@ -26,11 +26,11 @@ import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.config.entities.ResultTypeConfig;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.TextParseUtil;
|
||||
import com.opensymphony.xwork2.util.finder.ClassLoaderInterface;
|
||||
import com.opensymphony.xwork2.util.finder.ClassLoaderInterfaceDelegate;
|
||||
import com.opensymphony.xwork2.util.finder.ResourceFinder;
|
||||
import com.opensymphony.xwork2.util.finder.Test;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -39,10 +39,11 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.convention.annotation.Result;
|
||||
import org.apache.struts2.convention.annotation.Results;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -115,8 +116,8 @@ import java.util.*;
|
||||
public class DefaultResultMapBuilder implements ResultMapBuilder {
|
||||
private static final Logger LOG = LogManager.getLogger(DefaultResultMapBuilder.class);
|
||||
private final ServletContext servletContext;
|
||||
private Set<String> relativeResultTypes;
|
||||
private ConventionsService conventionsService;
|
||||
private final Set<String> relativeResultTypes;
|
||||
private final ConventionsService conventionsService;
|
||||
private boolean flatResultLayout = true;
|
||||
|
||||
/**
|
||||
@@ -131,7 +132,7 @@ public class DefaultResultMapBuilder implements ResultMapBuilder {
|
||||
public DefaultResultMapBuilder(ServletContext servletContext, Container container,
|
||||
@Inject(ConventionConstants.CONVENTION_RELATIVE_RESULT_TYPES) String relativeResultTypes) {
|
||||
this.servletContext = servletContext;
|
||||
this.relativeResultTypes = new HashSet<>(Arrays.asList(relativeResultTypes.split("\\s*[,]\\s*")));
|
||||
this.relativeResultTypes = Set.of(relativeResultTypes.split("\\s*[,]\\s*"));
|
||||
this.conventionsService = container.getInstance(ConventionsService.class, container.getInstance(String.class, ConventionConstants.CONVENTION_CONVENTIONS_SERVICE));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user