cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel H. Peger (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CXF-7267) Member names must match bean attribute for BeanParam to work
Date Mon, 06 Mar 2017 08:48:32 GMT

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

Daniel H. Peger updated CXF-7267:
---------------------------------
    Description: 
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
field 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.

  was:
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(PathParameters.PATH_APPLICATION_ID)
  private String mApplicationId;

  @PathParam(PathParameters.PATH_PROJECT_ID)
  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
field 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.


> 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
>            Priority: Minor
>
> 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 field 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.



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

Mime
View raw message