You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2023/12/12 08:48:53 UTC

(struts) branch feature/http-params-case updated (7bea06045 -> 4eaab8a79)

This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a change to branch feature/http-params-case
in repository https://gitbox.apache.org/repos/asf/struts.git


 discard 7bea06045 WW-5370 Simplifies code
     new 4eaab8a79 WW-5370 Simplifies code

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (7bea06045)
            \
             N -- N -- N   refs/heads/feature/http-params-case (4eaab8a79)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java | 1 -
 1 file changed, 1 deletion(-)


(struts) 01/01: WW-5370 Simplifies code

Posted by lu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch feature/http-params-case
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 4eaab8a79d3674f4e519ca726f96fd7576180799
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Tue Dec 12 09:46:38 2023 +0100

    WW-5370 Simplifies code
---
 .../java/org/apache/struts2/dispatcher/HttpParameters.java |  9 ++++-----
 .../org/apache/struts2/dispatcher/HttpParametersTest.java  | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java b/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java
index e44f06273..a2d4675e0 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java
@@ -49,7 +49,7 @@ public class HttpParameters implements Map<String, Parameter> {
 
     public HttpParameters remove(Set<String> paramsToRemove) {
         for (String paramName : paramsToRemove) {
-            parameters.entrySet().removeIf(p -> p.getKey().equalsIgnoreCase(paramName));
+            parameters.remove(paramName);
         }
         return this;
     }
@@ -85,7 +85,6 @@ public class HttpParameters implements Map<String, Parameter> {
      * @return a current instance of {@link HttpParameters}
      */
     public HttpParameters appendAll(Map<String, Parameter> newParams) {
-        remove(newParams.keySet());
         parameters.putAll(newParams);
         return this;
     }
@@ -112,10 +111,10 @@ public class HttpParameters implements Map<String, Parameter> {
 
     @Override
     public Parameter get(Object key) {
-        if (key != null && contains(String.valueOf(key))) {
-            return parameters.get(key);
+        if (key != null) {
+            return parameters.get(String.valueOf(key));
         } else {
-            return new Parameter.Empty(String.valueOf(key));
+            return null;
         }
     }
 
diff --git a/core/src/test/java/org/apache/struts2/dispatcher/HttpParametersTest.java b/core/src/test/java/org/apache/struts2/dispatcher/HttpParametersTest.java
index 7c2efbc12..b8b0a3038 100644
--- a/core/src/test/java/org/apache/struts2/dispatcher/HttpParametersTest.java
+++ b/core/src/test/java/org/apache/struts2/dispatcher/HttpParametersTest.java
@@ -23,6 +23,8 @@ import org.junit.Test;
 import java.util.HashMap;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 public class HttpParametersTest {
@@ -40,6 +42,18 @@ public class HttpParametersTest {
         assertEquals("value1", params.get("pAraM1").getValue());
     }
 
+    @Test
+    public void shouldRemoveBeCaseInsensitive() {
+        // given
+        HttpParameters params = HttpParameters.create(new HashMap<String, Object>() {{
+            put("param1", "value1");
+        }}).build();
+
+        // then
+        assertFalse(params.remove("Param1").contains("param1"));
+        assertNull(params.get("param1"));
+    }
+
     @Test
     public void shouldAppendSameParamsIgnoringCase() {
         // given