Compare commits

...

4 Commits

Author SHA1 Message Date
Lukasz Lenart 9841b848c8 [maven-release-plugin] prepare for next development iteration 2023-12-05 07:04:12 +01:00
Lukasz Lenart ad95ab30f2 [maven-release-plugin] prepare release STRUTS_6_3_0_2 2023-12-05 07:04:02 +01:00
Lukasz Lenart 2eecd16888 Sets a proper SNAPSHOT version 2023-12-04 06:43:08 +01:00
Lukasz Lenart d8c69691ef Makes HttpParameters case-insensitive 2023-12-04 06:41:51 +01:00
41 changed files with 131 additions and 51 deletions
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-apps</artifactId>
<packaging>pom</packaging>
+2 -2
View File
@@ -24,12 +24,12 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-rest-showcase</artifactId>
<packaging>war</packaging>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
<name>Struts 2 Rest Showcase Webapp</name>
<description>Struts 2 Rest Showcase Example</description>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-showcase</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-assembly</artifactId>
+3 -3
View File
@@ -25,11 +25,11 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-bom</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Struts 2 Bill of Materials</name>
@@ -44,7 +44,7 @@
</licenses>
<properties>
<struts-version.version>6.3.0.1</struts-version.version>
<struts-version.version>6.3.0.3-SNAPSHOT</struts-version.version>
<maven.site.skip>true</maven.site.skip>
<maven.site.deploy.skip>true</maven.site.deploy.skip>
</properties>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-osgi-bundles</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-osgi-admin-bundle</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-osgi-bundles</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-osgi-demo-bundle</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-osgi-bundles</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-core</artifactId>
<packaging>jar</packaging>
@@ -29,7 +29,7 @@ import java.util.TreeMap;
import java.util.TreeSet;
@SuppressWarnings("unchecked")
public class HttpParameters implements Map<String, Parameter>, Cloneable {
public class HttpParameters implements Map<String, Parameter> {
final private Map<String, Parameter> parameters;
@@ -37,6 +37,7 @@ public class HttpParameters implements Map<String, Parameter>, Cloneable {
this.parameters = parameters;
}
@SuppressWarnings("rawtypes")
public static Builder create(Map requestParameterMap) {
return new Builder(requestParameterMap);
}
@@ -47,7 +48,7 @@ public class HttpParameters implements Map<String, Parameter>, Cloneable {
public HttpParameters remove(Set<String> paramsToRemove) {
for (String paramName : paramsToRemove) {
parameters.remove(paramName);
parameters.entrySet().removeIf(p -> p.getKey().equalsIgnoreCase(paramName));
}
return this;
}
@@ -59,12 +60,15 @@ public class HttpParameters implements Map<String, Parameter>, Cloneable {
}
public boolean contains(String name) {
return parameters.containsKey(name);
return parameters.keySet().stream().anyMatch(p -> p.equalsIgnoreCase(name));
}
/**
* Access to this method can be potentially dangerous as it allows access to raw parameter values.
*
* @deprecated since 6.4.0, it will be removed with a new major release
*/
@Deprecated
private Map<String, String[]> toMap() {
final Map<String, String[]> result = new HashMap<>(parameters.size());
for (Map.Entry<String, Parameter> entry : parameters.entrySet()) {
@@ -73,7 +77,14 @@ public class HttpParameters implements Map<String, Parameter>, Cloneable {
return result;
}
/**
* Appends all the parameters by overriding any existing params in a case-insensitive manner
*
* @param newParams A new params to append
* @return a current instance of {@link HttpParameters}
*/
public HttpParameters appendAll(Map<String, Parameter> newParams) {
remove(newParams.keySet());
parameters.putAll(newParams);
return this;
}
@@ -100,8 +111,11 @@ public class HttpParameters implements Map<String, Parameter>, Cloneable {
@Override
public Parameter get(Object key) {
if (parameters.containsKey(key)) {
return parameters.get(key);
if (key != null && contains(String.valueOf(key))) {
return parameters.entrySet().stream()
.filter(p -> p.getKey().equalsIgnoreCase(String.valueOf(key)))
.findFirst().map(Entry::getValue)
.orElse(new Parameter.Empty(String.valueOf(key)));
} else {
return new Parameter.Empty(String.valueOf(key));
}
@@ -177,8 +191,8 @@ public class HttpParameters implements Map<String, Parameter>, Cloneable {
public HttpParameters build() {
Map<String, Parameter> parameters = (parent == null)
? new HashMap<>()
: new HashMap<>(parent.parameters);
? new HashMap<>()
: new HashMap<>(parent.parameters);
for (Map.Entry<String, Object> entry : requestParameterMap.entrySet()) {
String name = entry.getKey();
@@ -197,8 +211,9 @@ public class HttpParameters implements Map<String, Parameter>, Cloneable {
* Alternate Builder method which avoids wrapping any parameters that are already
* a {@link Parameter} element within another {@link Parameter} wrapper.
*
* @return
* @deprecated since 6.4.0, use {@link #build()} instead
*/
@Deprecated
public HttpParameters buildNoNestedWrapping() {
Map<String, Parameter> parameters = (parent == null)
? new HashMap<>()
@@ -0,0 +1,65 @@
/*
* 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 org.apache.struts2.dispatcher;
import org.junit.Test;
import java.util.HashMap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class HttpParametersTest {
@Test
public void shouldGetBeCaseInsensitive() {
// given
HttpParameters params = HttpParameters.create(new HashMap<String, Object>() {{
put("param1", "value1");
}}).build();
// then
assertEquals("value1", params.get("Param1").getValue());
assertEquals("value1", params.get("paraM1").getValue());
assertEquals("value1", params.get("pAraM1").getValue());
}
@Test
public void shouldAppendSameParamsIgnoringCase() {
// given
HttpParameters params = HttpParameters.create(new HashMap<String, Object>() {{
put("param1", "value1");
}}).build();
// when
assertEquals("value1", params.get("param1").getValue());
params = params.appendAll(HttpParameters.create(new HashMap<String, String>() {{
put("Param1", "Value1");
}}).build());
// then
assertTrue(params.contains("param1"));
assertTrue(params.contains("Param1"));
assertEquals("Value1", params.get("param1").getValue());
assertEquals("Value1", params.get("Param1").getValue());
}
}
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-async-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
+1 -1
View File
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-cdi-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-config-browser-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-convention-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-dwr-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-embeddedjsp-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-gxp-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-jasperreports-plugin</artifactId>
+1 -1
View File
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-javatemplates-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-jfreechart-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-json-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-junit-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-osgi-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-oval-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-pell-multipart-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-plexus-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-plugins</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-portlet-junit-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-portlet-mocks-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-portlet-tiles-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-portlet-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-rest-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-sitemesh-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-spring-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-testng-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-tiles-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-velocity-plugin</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-xslt-plugin</artifactId>
+2 -2
View File
@@ -29,7 +29,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>struts2-parent</artifactId>
<version>6.3.0.1</version>
<version>6.3.0.3-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Struts 2</name>
<url>https://struts.apache.org/</url>
@@ -104,7 +104,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputTimestamp>2023-09-11T07:44:35Z</project.build.outputTimestamp>
<project.build.outputTimestamp>2023-12-05T06:04:11Z</project.build.outputTimestamp>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>