[ 
https://issues.apache.org/jira/browse/WW-3427?focusedWorklogId=1032274&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1032274
 ]

ASF GitHub Bot logged work on WW-3427:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Jul/26 08:18
            Start Date: 26/Jul/26 08:18
    Worklog Time Spent: 10m 
      Work Description: lukaszlenart opened a new pull request, #1814:
URL: https://github.com/apache/struts/pull/1814

   Fixes [WW-3427](https://issues.apache.org/jira/browse/WW-3427)
   
   ## What
   
   Adds a regression test proving that a conversion error thrown while binding 
an **aliased** property (via `AliasInterceptor`) is reported, exactly as it 
would be for a non-aliased property.
   
   The original report (against 2.1.8.1) was that when an aliased property's 
custom `TypeConverter` throws `TypeConversionException`, the error is never 
caught by `ConversionErrorInterceptor` / `ConversionErrorFieldValidator`.
   
   ## Why this is test-only
   
   The defect is already fixed in current code. `AliasInterceptor` binds the 
alias on a secure child stack with `setReportingConversionErrors(context, 
true)` and then copies the resulting conversion errors back into the original 
`ActionContext`:
   
   ```java
   if (clearableStack) {
       
stack.getActionContext().withConversionErrors(newStack.getActionContext().getConversionErrors());
   }
   ```
   
   `XWorkConverter.handleConversionException` records the 
`TypeConversionException` into that context, so `ConversionErrorInterceptor` 
picks it up downstream. This path was simply never covered by a test, and the 
ticket was never verified/closed.
   
   ## The test
   
   `AliasInterceptorTest#testConversionErrorOnAliasedPropertyIsReported` drives 
an action through `params -> alias -> conversionError` with an aliased 
`BigDecimal` property bound through a converter that always throws, and asserts 
the failure surfaces both in `ActionContext.getConversionErrors()` and as a 
field error on the aliased property.
   
   It genuinely guards the behavior: removing the copy-back in 
`AliasInterceptor` makes the test fail with `"conversion error for aliased 
property was swallowed"`, reproducing the original WW-3427 symptom.
   
   ## Files
   
   - `AliasInterceptorTest.java` — new test method
   - `AliasConversionAction.java` — action with an aliased `BigDecimal 
aliasDest`
   - `ThrowingTypeConverter.java` — converter that always throws 
`TypeConversionException`
   - `AliasConversionAction-conversion.properties` — registers the converter 
for `aliasDest`
   - `xwork-alias-conversion.xml` — dedicated config (`params -> alias -> 
conversionError`)
   
   No production changes.
   
   ## Testing
   
   `mvn test -DskipAssembly -pl core -Dtest=AliasInterceptorTest` — 8/8 passing.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)




Issue Time Tracking
-------------------

            Worklog Id:     (was: 1032274)
    Remaining Estimate: 0h
            Time Spent: 10m

> If you alias a property that uses a custom TypeConverter and it throws 
> TypeConversionException the error is never caught
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-3427
>                 URL: https://issues.apache.org/jira/browse/WW-3427
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Interceptors
>    Affects Versions: 2.1.8.1
>         Environment: Windows
>            Reporter: Sloan Seaman
>            Assignee: Lukasz Lenart
>            Priority: Major
>              Labels: conversion, struts, type
>             Fix For: 7.3.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> If you define an alias to a property like so:
> {code:java}
> @Actions({
>   @Action(
>     value="/icc/saveScan",
>     interceptorRefs=@InterceptorRef("ptiDefault"),
>     results={
>       @Result(name="input", location="/error.jsp"), 
>       @Result(name="success", location="/success.jsp")
>     },
>     params={"aliases", 
>       "#{\"plateId\" : \"plate\", " +
>         "\"machineAbbr\" : \"machine\", "+
>         "\"imageFiles\" : \"scanData\"}"
>     }
>     */
>   )
> })
> {code}
> and the property (say imageFiles/scanData) has a custom TypeConverter 
> configured like so:
> {code:java}
>       @ConversionErrorFieldValidator(type = ValidatorType.FIELD, 
>               key="invalid.fieldvalue.xxx",
>               message = "well not found or imageFiles not in format: 
> file,wellId|file,wellId|...",
>               shortCircuit=true)
>       @TypeConversion(rule = ConversionRule.COLLECTION, 
>               converter = "com.ptilabs.icc.action.ScanData")
>       public void setScanData(List<ScanData> imageFiles) {
>               this.imageFiles = imageFiles;
>       }
> {code}{
> If the {{TypeConverter}} throws a {{TypeConversionException}} the exception 
> is never caught by the {{ConversionErrorInterceptor}} or 
> {{ConversionErrorFieldValidator}}.
> If I disable the aliasing and rename the method {{setImageFiles}} everything 
> works correctly.
> I'm trying to debug on my own but I can't find the class responsible for 
> catching the {{TypeConversionException}} and placing it in the 
> {{invocationContext.getConversionErrors()}}
>               



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to