(struts) 01/01: WW-5451 Fixes NPE when iterator starts with null

2024-07-31 Thread lukaszlenart
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch feature/WW-5451-null-iterator
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 479a9d86ed3b37db10c8322045887be293f14cd6
Author: Lukasz Lenart 
AuthorDate: Wed Jul 31 16:53:01 2024 +0200

WW-5451 Fixes NPE when iterator starts with null
---
 .../struts2/components/IteratorComponent.java  |  5 ++-
 .../struts2/components/IteratorComponentTest.java  | 36 ++
 .../apache/struts2/views/jsp/IteratorTagTest.java  | 36 +-
 3 files changed, 75 insertions(+), 2 deletions(-)

diff --git 
a/core/src/main/java/org/apache/struts2/components/IteratorComponent.java 
b/core/src/main/java/org/apache/struts2/components/IteratorComponent.java
index 7ff83bd45..1659e6c6e 100644
--- a/core/src/main/java/org/apache/struts2/components/IteratorComponent.java
+++ b/core/src/main/java/org/apache/struts2/components/IteratorComponent.java
@@ -306,7 +306,10 @@ public class IteratorComponent extends ContextBean {
 if ((iterator != null) && iterator.hasNext()) {
 Object currentValue = iterator.next();
 stack.push(currentValue);
-threadAllowlist.allowClass(currentValue.getClass());
+
+if (currentValue != null) {
+threadAllowlist.allowClass(currentValue.getClass());
+}
 
 String var = getVar();
 
diff --git 
a/core/src/test/java/org/apache/struts2/components/IteratorComponentTest.java 
b/core/src/test/java/org/apache/struts2/components/IteratorComponentTest.java
index 7f08ef64e..077510a71 100644
--- 
a/core/src/test/java/org/apache/struts2/components/IteratorComponentTest.java
+++ 
b/core/src/test/java/org/apache/struts2/components/IteratorComponentTest.java
@@ -184,6 +184,42 @@ public class IteratorComponentTest extends 
StrutsInternalTestCase {
 assertEquals("1, 2, , 4, ", out.getBuffer().toString());
 }
 
+public void testIteratorWithNullsOnly() {
+// given
+stack.push(new FooAction() {
+private final List items = Arrays.asList(null, null, null);
+
+public List getItems() {
+return items;
+}
+});
+
+StringWriter out = new StringWriter();
+
+ic.setValue("items");
+ic.setVar("val");
+Property prop = new Property(stack);
+
+ic.getComponentStack().push(prop);
+ic.getComponentStack().push(prop);
+ic.getComponentStack().push(prop);
+ic.getComponentStack().push(prop);
+
+String body = ", ";
+
+// when
+assertTrue(ic.start(out));
+
+for (int i = 0; i < 3; i++) {
+prop.start(out);
+prop.end(out, body);
+ic.end(out, null);
+}
+
+// then
+assertEquals(", , , ", out.getBuffer().toString());
+}
+
 public void testIteratorWithDifferentLocale() {
 // given
 ActionContext.getContext().withLocale(new Locale("fa_IR"));
diff --git 
a/core/src/test/java/org/apache/struts2/views/jsp/IteratorTagTest.java 
b/core/src/test/java/org/apache/struts2/views/jsp/IteratorTagTest.java
index fd3fc9587..acb4fa053 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/IteratorTagTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/IteratorTagTest.java
@@ -20,7 +20,6 @@ package org.apache.struts2.views.jsp;
 
 import com.mockobjects.servlet.MockBodyContent;
 import com.mockobjects.servlet.MockJspWriter;
-import com.opensymphony.xwork2.ActionContext;
 import org.apache.commons.collections.ListUtils;
 
 import javax.servlet.jsp.JspException;
@@ -722,6 +721,41 @@ public class IteratorTagTest extends AbstractUITagTest {
 validateCounter(new String[]{"a", "b", "c"});
 }
 
+public void testNullElements() throws JspException {
+Foo foo = new Foo();
+foo.setArray(new String[3]);
+
+stack.push(foo);
+tag.setValue("array");
+tag.setVar("anId");
+
+// one
+int result = tag.doStartTag();
+assertEquals(TagSupport.EVAL_BODY_INCLUDE, result);
+assertNull(stack.peek());
+assertNull(stack.getContext().get("anId"));
+
+tag.doInitBody();
+
+// two
+result = tag.doAfterBody();
+assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
+assertNull(stack.peek());
+assertNull(stack.getContext().get("anId"));
+
+// three
+result = tag.doAfterBody();
+assertEquals(TagSupport.EVAL_BODY_AGAIN, result);
+assertNull(stack.peek());
+assertNull(stack.getContext().get("anId"));
+
+result = tag.doAfterBody();
+assertEquals(TagSupport.SKIP_BODY, result);
+
+result = tag.doEndTag();
+assertEquals(TagSupport.EVAL_PAGE, result);
+}
+
 public void testCounterWithArray() throws JspException {
 Foo foo = new Foo();
 foo.setArray(new St

(struts) branch feature/WW-5451-null-iterator created (now 479a9d86e)

2024-07-31 Thread lukaszlenart
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a change to branch feature/WW-5451-null-iterator
in repository https://gitbox.apache.org/repos/asf/struts.git


  at 479a9d86e WW-5451 Fixes NPE when iterator starts with null

This branch includes the following new commits:

 new 479a9d86e WW-5451 Fixes NPE when iterator starts with null

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.




Build failed in Jenkins: Struts ยป Struts-master-JDK8-dependency-check #204

2024-07-31 Thread Apache Jenkins Server
See 


Changes:

[github] Bump org.apache.commons:commons-lang3 from 3.14.0 to 3.15.0


--
Started by timer
Running as SYSTEM
[EnvInject] - Loading node environment variables.
Building remotely on builds29 (ubuntu) in workspace 

The recommended git tool is: NONE
No credentials specified
Cloning the remote Git repository
Cloning repository https://gitbox.apache.org/repos/asf/struts.git
 > git init 
 > 
 >  # timeout=10
Fetching upstream changes from https://gitbox.apache.org/repos/asf/struts.git
 > git --version # timeout=10
 > git --version # 'git version 2.34.1'
 > git fetch --tags --force --progress -- 
 > https://gitbox.apache.org/repos/asf/struts.git 
 > +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url https://gitbox.apache.org/repos/asf/struts.git 
 > # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # 
 > timeout=10
Avoid second fetch
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision e3e854a67b6a72843a3af3476aacec7efc1c0a56 
(refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f e3e854a67b6a72843a3af3476aacec7efc1c0a56 # timeout=10
Commit message: "Merge pull request #1000 from 
apache/dependabot/maven/org.apache.commons-commons-lang3-3.15.0"
 > git rev-list --no-walk f977f0c0e5c69f8d95b897fcf012cb8ba204d938 # timeout=10
ERROR: No tool found matching MAVEN_3_LATEST__HOME
Setting MAVEN_3_LATEST_HOME=/home/jenkins/tools/maven/latest3
[Struts-master-JDK8-dependency-check] $ /bin/sh -xe 
/tmp/jenkins4876566699384428495.sh
+ export MAVEN_OPTS=-Xms2g -Xmx2g -XX:+CMSClassUnloadingEnabled
+ /home/jenkins/tools/maven/latest3/bin/mvn verify -Pdependency-check
[INFO] Scanning for projects...
[INFO] 
[INFO] Reactor Build Order:
[INFO] 
[INFO] Struts 2   [pom]
[INFO] Struts 2 Bill of Materials [pom]
[INFO] Struts 2 Core  [jar]
[INFO] Struts 2 Plugins   [pom]
[INFO] Struts 2 Async Plugin  [jar]
[INFO] Struts 2 Bean Validation Plugin[jar]
[INFO] Struts 2 CDI Plugin[jar]
[INFO] Struts 2 Spring Plugin [jar]
[INFO] Struts 2 JUnit Plugin  [jar]
[INFO] Struts 2 Velocity Plugin   [jar]
[INFO] Struts 2 Configuration Browser Plugin  [jar]
[INFO] Struts 2 Convention Plugin [jar]
[INFO] Struts 2 DWR Plugin[jar]
[INFO] DEPRECATED: Struts 2 Embedded JSP Plugin, since 6.0.0  [jar]
[INFO] DEPRECATED: Struts 2 GXP Plugin - since 6.0.0  [jar]
[INFO] Struts 2 Jasper Reports Plugin [jar]
[INFO] Struts 2 Java Templates Plugin [jar]
[INFO] Struts 2 JFreeChart Plugin [jar]
[INFO] Struts 2 JSON Plugin   [jar]
[INFO] DEPRECATED: Struts 2 OSGi Plugin - since 6.0.0 [jar]
[INFO] DEPRECATED: Struts 2 OVal Plugin, since 6.0.0  [jar]
[INFO] DEPRECATED: Struts 2 Pell Multipart Plugin - since 6.2.0   [jar]
[INFO] DEPRECATED: Struts 2 Plexus Plugin - since 6.0.0   [jar]
[INFO] DEPRECATED: Struts 2 Portlet Mocks Plugin - since 6.0.0[jar]
[INFO] DEPRECATED: Struts 2 Portlet Plugin - since 6.0.0  [jar]
[INFO] DEPRECATED: Struts 2 Portlet JUnit Plugin - since 6.3.0[jar]
[INFO] Struts 2 Tiles Plugin  [jar]
[INFO] DEPRECATED: Struts 2 Portlet Tiles Plugin - since 6.0.0[jar]
[INFO] Struts 2 REST Plugin   [jar]
[INFO] Struts 2 Sitemesh Plugin   [jar]
[INFO] Struts 2 TestNG Plugin [jar]
[INFO] Struts 2 XSLT Plugin   [jar]
[INFO] DEPRECATED: Struts 2 OSGi Bundles - since 6.0.0[pom]
[INFO] DEPRECATED: Struts 2 OSGi Admin Bundle - since 6.0.0[bundle]
[INFO] DEPRECATED: Struts 2 OSGi Demo Bundle - since 6.0.0 [bu