cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (CXF-7267) Member names must match bean attribute for BeanParam to work
Date Fri, 24 Mar 2017 15:45:42 GMT

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

Sergey Beryozkin resolved CXF-7267.
-----------------------------------
       Resolution: Fixed
         Assignee: Sergey Beryozkin
    Fix Version/s: 3.1.11
                   3.2.0

> Member names must match bean attribute for BeanParam to work
> ------------------------------------------------------------
>
>                 Key: CXF-7267
>                 URL: https://issues.apache.org/jira/browse/CXF-7267
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 3.1.4
>            Reporter: Daniel H. Peger
>            Assignee: Sergey Beryozkin
>            Priority: Minor
>             Fix For: 3.2.0, 3.1.11
>
>
> I just ran into this problem on my first attempt to use {{@BeanParam}} and got this exception:
> {noformat}
> java.lang.IllegalArgumentException: Unresolved variables; only 0 value(s) given for 2
unique variable(s)
> 	at org.apache.cxf.jaxrs.impl.UriBuilderImpl.substituteVarargs(UriBuilderImpl.java:285)
> 	at org.apache.cxf.jaxrs.impl.UriBuilderImpl.doBuildUriParts(UriBuilderImpl.java:121)
> ...
> {noformat}
> My parameter bean looked like this:
> {code}package com.recommind.common.rest;
> import javax.ws.rs.PathParam;
> public final class ApplicationIdentifierParameter
> {
>   @PathParam("applicationId")
>   private String mApplicationId;
>   @PathParam("projectId")
>   private String mProjectId;
>   public String getApplicationId()
>   {
>     return mApplicationId;
>   }
>   public void setApplicationId(String aApplicationId)
>   {
>     mApplicationId = aApplicationId;
>   }
>   public String getProjectId()
>   {
>     return mProjectId;
>   }
>   public void setProjectId(String aProjectId)
>   {
>     mProjectId = aProjectId;
>   }
> }
> {code}
> I debugged {{UriBuilderImpl}} and found that in {{ClientProxyImpl:514}} the to be evaluated
members are identified by the names of the corresponding setters.
> I think this is wrong - or at least inconvenient - as it is totally valid for a bean's
internals fields to have different names than the corresponding bean attribute. To my knowledge
the Bean spec only requires setters and getters to match and does not care about the internal
representation of the attributes.
> Rather than looking at the setters {{ClientProxyImpl}} should iterate over the bean's
fields, look for fields annotated with {{@PathParam}} and update the field using reflection.
> *Workaround:*
> Annotate the setters with the {{@XXXParam}} annotations.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message