You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (Jira)" <ji...@apache.org> on 2022/10/22 13:22:00 UTC

[jira] [Updated] (WW-3427) If you alias a property that uses a custom TypeConverter and it throws TypeConversionException the error is never caught

     [ https://issues.apache.org/jira/browse/WW-3427?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart updated WW-3427:
------------------------------
    Description: 
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()}}
		

  was:
If you define an alias to a property like so:
@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\"}"}
		 */
			)
		})


and the property (say imageFiles/scanData) has a custom TypeConverter configured like so:
	@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;
	}

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()
		


> 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
>            Priority: Major
>              Labels: conversion, struts, type
>             Fix For: 6.1.0
>
>
> 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)