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 2026/08/14 11:25:48 UTC
(struts-examples) 10/13: Add missing @StrutsParameter annotations found by whole-branch review
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch feat/struts-730-modernization
in repository https://gitbox.apache.org/repos/asf/struts-examples.git
commit 5cb54f0af3d2f2bfef01a8e502a3069ab03f630a
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Fri Aug 14 13:05:45 2026 +0200
Add missing @StrutsParameter annotations found by whole-branch review
The original audit matched only name= on <s:*> tags (missing key=,
which also sets the parameter name) and did not consider accessors
inherited from a superclass. This let three modules silently drop
every submitted parameter: bean-validation and themes-override
(EditAction.getPersonBean(), whose JSPs use key=) and mailreader2
(MailreaderSupport, the shared base class for RegistrationAction,
SubscriptionAction, and LoginAction). Adds 9 annotations across the
three modules, bringing the running total to 17 across 8 modules, and
corrects the two now-false claims in the modernization plan doc.
Co-Authored-By: Claude Opus 5 <no...@anthropic.com>
---
.../src/main/java/org/apache/struts/edit/action/EditAction.java | 2 ++
docs/superpowers/plans/2026-08-14-struts-730-modernization.md | 6 ++++--
.../org/apache/struts/examples/mailreader2/MailreaderSupport.java | 8 ++++++++
.../src/main/java/org/apache/struts/edit/action/EditAction.java | 2 ++
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/bean-validation/src/main/java/org/apache/struts/edit/action/EditAction.java b/bean-validation/src/main/java/org/apache/struts/edit/action/EditAction.java
index 04179b3..e63e345 100755
--- a/bean-validation/src/main/java/org/apache/struts/edit/action/EditAction.java
+++ b/bean-validation/src/main/java/org/apache/struts/edit/action/EditAction.java
@@ -6,6 +6,7 @@ import org.apache.struts.edit.model.State;
import org.apache.struts.edit.service.EditService;
import org.apache.struts.edit.service.EditServiceInMemory;
import org.apache.struts2.ActionSupport;
+import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -40,6 +41,7 @@ public class EditAction extends ActionSupport {
return INPUT;
}
+ @StrutsParameter(depth = 1)
public Person getPersonBean() {
return personBean;
}
diff --git a/docs/superpowers/plans/2026-08-14-struts-730-modernization.md b/docs/superpowers/plans/2026-08-14-struts-730-modernization.md
index 2478f47..20fadda 100644
--- a/docs/superpowers/plans/2026-08-14-struts-730-modernization.md
+++ b/docs/superpowers/plans/2026-08-14-struts-730-modernization.md
@@ -311,7 +311,9 @@ Co-Authored-By: Claude Opus 5 <no...@anthropic.com>"
### Task 4: Fix missing `@StrutsParameter` annotations
-Eight fixes across five classes in four modules. Each was hand-verified against the submitting JSP form. **Do not add annotations beyond these eight** — the audit confirmed every other action is either correct, ModelDriven-exempt, or has a property that is never submitted (annotating those would wrongly widen the injection surface).
+Eight fixes across five classes in four modules. Each was hand-verified against the submitting JSP form.
+
+**Correction (added after the final whole-branch review):** the audit above was not exhaustive. It matched only `name=` on `<s:*>` tags — missing `key=`, which also sets the parameter name — and it did not consider accessors inherited from a superclass. This let three modules slip through with every submitted parameter silently dropped: `bean-validation` and `themes-override` (`EditAction.getPersonBean()`, JSPs use `key=`) and `mailreader2` (`MailreaderSupport`, the shared base class for [...]
Rules being applied, from `ParametersInterceptor.hasValidAnnotatedPropertyDescriptor`:
- depth 0 → annotation goes on the **setter**
@@ -764,4 +766,4 @@ Expected: roughly 140–150 files. The per-task counts are the authoritative che
- `text-provider` — `SystemAction.setTextProvider` is `@Inject`-driven, not a request parameter.
- `file-upload` and `sitemesh3` — `UploadAction implements UploadedFilesAware` and receives files via `withUploadedFiles(List<UploadedFile>)`. There is no `setUpload`; `<s:file>` is consumed by the file-upload interceptor, not `ParametersInterceptor`.
- `struts-parameter` — `users[%{#status.index}].id` evaluates to `users[0].id`, depth 2. The existing `@StrutsParameter(depth = 2)` is already correct.
-- **No `unverified` rows.** Every action's parameters were traceable to a JSP form, a validation descriptor, or an assignment in `execute()`.
+- **No `unverified` rows** — but this was not accurate: the audit missed three modules by matching only `name=` on `<s:*>` tags (not `key=`) and by not considering accessors inherited from a superclass. The final whole-branch review caught `bean-validation`, `themes-override`, and `mailreader2` and added 9 further annotations, bringing the total to 17 across 8 modules.
diff --git a/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/MailreaderSupport.java b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/MailreaderSupport.java
index e112c29..c6a6edf 100644
--- a/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/MailreaderSupport.java
+++ b/mailreader2/src/main/java/org/apache/struts/examples/mailreader2/MailreaderSupport.java
@@ -30,6 +30,7 @@ import org.apache.struts.examples.mailreader2.dao.impl.memory.MemoryUser;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.ApplicationAware;
import org.apache.struts2.action.SessionAware;
+import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.Map;
@@ -160,6 +161,7 @@ public class MailreaderSupport extends ActionSupport implements SessionAware, Ap
*
* @param value The task to set.
*/
+ @StrutsParameter
public void setTask(String value) {
task = value;
}
@@ -216,6 +218,7 @@ public class MailreaderSupport extends ActionSupport implements SessionAware, Ap
*
* @param value
*/
+ @StrutsParameter
public void setHost(String value) {
host = value;
}
@@ -245,6 +248,7 @@ public class MailreaderSupport extends ActionSupport implements SessionAware, Ap
*
* @param value The password to set.
*/
+ @StrutsParameter
public void setPassword(String value) {
password = value;
}
@@ -275,6 +279,7 @@ public class MailreaderSupport extends ActionSupport implements SessionAware, Ap
*
* @param value The confirmation password to set.
*/
+ @StrutsParameter
public void setPassword2(String value) {
password2 = value;
}
@@ -304,6 +309,7 @@ public class MailreaderSupport extends ActionSupport implements SessionAware, Ap
*
* @param value The username to set.
*/
+ @StrutsParameter
public void setUsername(String value) {
username = value;
}
@@ -341,6 +347,7 @@ public class MailreaderSupport extends ActionSupport implements SessionAware, Ap
*
* @return User object for authenticated user.
*/
+ @StrutsParameter(depth = 1)
public User getUser() {
return (User) getSession().get(Constants.USER_KEY);
}
@@ -465,6 +472,7 @@ public class MailreaderSupport extends ActionSupport implements SessionAware, Ap
*
* @return Cached Subscription object or null
*/
+ @StrutsParameter(depth = 1)
public Subscription getSubscription() {
return (Subscription) getSession().get(Constants.SUBSCRIPTION_KEY);
}
diff --git a/themes-override/src/main/java/org/apache/struts/edit/action/EditAction.java b/themes-override/src/main/java/org/apache/struts/edit/action/EditAction.java
index 728a4fc..3fb99b2 100644
--- a/themes-override/src/main/java/org/apache/struts/edit/action/EditAction.java
+++ b/themes-override/src/main/java/org/apache/struts/edit/action/EditAction.java
@@ -5,6 +5,7 @@ import org.apache.struts.edit.model.State;
import org.apache.struts.edit.service.EditService;
import org.apache.struts.edit.service.EditServiceInMemory;
import org.apache.struts2.ActionSupport;
+import org.apache.struts2.interceptor.parameter.StrutsParameter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -48,6 +49,7 @@ public class EditAction extends ActionSupport {
return INPUT;
}
+ @StrutsParameter(depth = 1)
public Person getPersonBean() {