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

Freeman Yue Fang resolved CXF-9130.
-----------------------------------
    Fix Version/s: 4.1.2
       Resolution: Fixed

> WrapperClassLoader.generate() should not add null values; 
> createWrapperClass() should log a warning when failing to create wrapper class
> ----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-9130
>                 URL: https://issues.apache.org/jira/browse/CXF-9130
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-WS Runtime
>    Affects Versions: 4.1.1
>         Environment: * Spring Boot 3.4.4
>  * Apache CXF 4.1.1
>  * Java 17 & 21
>  * GraalVM Native Image 24.0.1
> Problem reproducible on both standard JVM and native-image environments.
>            Reporter: Torsten Liermann
>            Assignee: Freeman Yue Fang
>            Priority: Minor
>             Fix For: 4.1.2
>
>
> In `WrapperClassLoader.generate()`, the returned `Set<Class<?>> wrapperBeans` 
> may contain null values if the call to `createWrapperClass(...)` returns null.
> This situation can occur when the service metadata (MessagePartInfo, 
> OperationInfo) is incomplete or when the wrapper class cannot be properly 
> generated due to missing or non-existent generated classes.
> Currently, no warning is logged when `createWrapperClass(...)` fails to find 
> or create a wrapper class.
> This leads to:
> - `null` entries in the wrapperBeans Set
> - Later `NullPointerException`s (e.g., when iterating over the Set)
> - Very difficult diagnosis, especially in GraalVM Native Image mode, but 
> reproducible even on the JVM if using a custom WrapperClassLoader.
> h3. Suggestion
>  * In `createWrapperClass(...)`, if no suitable wrapper class is found after 
> the loop, log a **warning** like: "Failed to find or generate wrapper class 
> for operation '{}', method '{}'. This may lead to runtime errors.", 
>              op.getName(), ....
>  * In {{{}generate(){}}}, add wrapper classes only if they are not {{null}}
> h3. Background
> Initially, this issue appeared while compiling a Spring Boot application with 
> CXF 4.1.1 into a GraalVM Native Image. However, after deeper debugging, the 
> real root cause was reproducible *also in standard JVM mode* when setting a 
> {{WrapperClassLoader}} manually:
> {{bus.setExtension(new WrapperClassLoader(bus), WrapperClassCreator.class);}}
> Incidentally, before I investigated this problem more deeply, I had already 
> opened the [following question | 
> https://stackoverflow.com/questions/79590372/apache-cxf-4-1-1-jax-ws-endpoint-throws-nullpointerexception-at-jaxbutils-scanpa]on
>  Stack Overflow.



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

Reply via email to