You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wink.apache.org by "Bryant Luk (JIRA)" <ji...@apache.org> on 2009/09/18 00:33:57 UTC

[jira] Created: (WINK-201) Fix precedence on custom type conversion

Fix precedence on custom type conversion
----------------------------------------

                 Key: WINK-201
                 URL: https://issues.apache.org/jira/browse/WINK-201
             Project: Wink
          Issue Type: Bug
          Components: Common
    Affects Versions: 0.2
            Reporter: Bryant Luk
            Assignee: Bryant Luk
             Fix For: 0.2


Re-reading the JAX-RS spec, the implied ordering for the type conversion is constructor then valueOf() (and now fromString()).  Will change the ordering to give constructors precedence.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Reopened: (WINK-201) Fix precedence on custom type conversion

Posted by Michael Elman <ta...@gmail.com>.
To tell the truth, I run it for the first time since the 0.1 release.
Should do it more frequently.

On Fri, Oct 2, 2009 at 6:32 PM, Nicholas L Gallardo <nl...@us.ibm.com>wrote:

> Michael,
>
> Out of curiosity, are you regularly running the TCK? Or just now that we're
> getting close to the end of the release?
>
> Either way, thanks for doing that...
>
> -Nick
>
>
>
> Nicholas Gallardo
> WebSphere - REST & WebServices Development
> nlgallar@us.ibm.com
> Phone: 512-286-6258
> Building: 903 / 5G-016
>
> [image: Inactive hide details for "Michael Elman (JIRA)" ---10/01/2009
> 03:40:53 AM---[ https://issues.apache.org/jira/browse/WINK-201?p]"Michael
> Elman (JIRA)" ---10/01/2009 03:40:53 AM---[
> https://issues.apache.org/jira/browse/WINK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
>
>
>     *"Michael Elman (JIRA)" <ji...@apache.org>*
>
>             10/01/2009 03:40 AM
>             Please respond to
>             wink-dev@incubator.apache.org
>
>
> To
>
> wink-dev@incubator.apache.org
> cc
>
>
> Subject
>
> [jira] Reopened: (WINK-201) Fix precedence on custom type conversion
>
>
>     [
> https://issues.apache.org/jira/browse/WINK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
>  ]
>
> Michael Elman reopened WINK-201:
> --------------------------------
>
>
> bq. Also sort values before doing the conversion so that a consistent value
> is used if there are multiple values.
> This causes some TCK tests to fail.
> I'll attach patch with demonstration.
>
> > Fix precedence on custom type conversion
> > ----------------------------------------
> >
> >                 Key: WINK-201
> >                 URL: https://issues.apache.org/jira/browse/WINK-201
> >             Project: Wink
> >          Issue Type: Bug
> >          Components: Common
> >    Affects Versions: 0.2
> >            Reporter: Bryant Luk
> >            Assignee: Bryant Luk
> >             Fix For: 0.2
> >
> >
> > Re-reading the JAX-RS spec, the implied ordering for the type conversion
> is constructor then valueOf() (and now fromString()).  Will change the
> ordering to give constructors precedence.
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>
>

Re: [jira] Reopened: (WINK-201) Fix precedence on custom type conversion

Posted by Nicholas L Gallardo <nl...@us.ibm.com>.
Michael,

Out of curiosity, are you regularly running the TCK?  Or just now that
we're getting close to the end of the release?

Either way, thanks for doing that...

-Nick



Nicholas Gallardo
WebSphere  - REST & WebServices Development
nlgallar@us.ibm.com
Phone: 512-286-6258
Building: 903 / 5G-016


                                                                           
             "Michael Elman                                                
             (JIRA)"                                                       
             <ji...@apache.org>                                          To 
                                       wink-dev@incubator.apache.org       
             10/01/2009 03:40                                           cc 
             AM                                                            
                                                                   Subject 
                                       [jira] Reopened: (WINK-201) Fix     
             Please respond to         precedence on custom type           
             wink-dev@incubato         conversion                          
               r.apache.org                                                
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           





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

Michael Elman reopened WINK-201:
--------------------------------


bq. Also sort values before doing the conversion so that a consistent value
is used if there are multiple values.
This causes some TCK tests to fail.
I'll attach patch with demonstration.

> Fix precedence on custom type conversion
> ----------------------------------------
>
>                 Key: WINK-201
>                 URL: https://issues.apache.org/jira/browse/WINK-201
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>            Assignee: Bryant Luk
>             Fix For: 0.2
>
>
> Re-reading the JAX-RS spec, the implied ordering for the type conversion
is constructor then valueOf() (and now fromString()).  Will change the
ordering to give constructors precedence.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WINK-201) Fix precedence on custom type conversion

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12756854#action_12756854 ] 

Hudson commented on WINK-201:
-----------------------------

Integrated in Wink-Trunk-JDK1.5 #162 (See [http://hudson.zones.apache.org/hudson/job/Wink-Trunk-JDK1.5/162/])
    Give constructors precedence over valueOf

See []


> Fix precedence on custom type conversion
> ----------------------------------------
>
>                 Key: WINK-201
>                 URL: https://issues.apache.org/jira/browse/WINK-201
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>            Assignee: Bryant Luk
>             Fix For: 0.2
>
>
> Re-reading the JAX-RS spec, the implied ordering for the type conversion is constructor then valueOf() (and now fromString()).  Will change the ordering to give constructors precedence.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WINK-201) Fix precedence on custom type conversion

Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761312#action_12761312 ] 

Bryant Luk commented on WINK-201:
---------------------------------

I'll back out the change later today.  However, I thought I remember reading this in the JavaDoc for HeaderParam, QueryParam and MatrixParam.  Probably made a bad fix though.  Thanks for the test Michael.

> Fix precedence on custom type conversion
> ----------------------------------------
>
>                 Key: WINK-201
>                 URL: https://issues.apache.org/jira/browse/WINK-201
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>            Assignee: Bryant Luk
>            Priority: Critical
>             Fix For: 0.2
>
>
> Re-reading the JAX-RS spec, the implied ordering for the type conversion is constructor then valueOf() (and now fromString()).  Will change the ordering to give constructors precedence.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (WINK-201) Fix precedence on custom type conversion

Posted by "Michael Elman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761148#action_12761148 ] 

Michael Elman edited comment on WINK-201 at 10/1/09 2:34 AM:
-------------------------------------------------------------

Removing the sort functionality from ValueConvertor.SingleValueConvertor makes all TCK tests to pass successfully:
{code}
    private static abstract class SingleValueConvertor extends ValueConvertor {

        RuntimeException createConversionException(String value, Class<?> targetClass, Throwable e) {
            if (e instanceof WebApplicationException) {
                return (RuntimeException)e;
            }
            String message = String.format("Cannot convert value '%s' to %s", value, targetClass);
            return new ConversionException(message, e);
        }

        public Object convert(List<String> values) throws WebApplicationException {
            if (values == null || values.size() == 0) {
                return convert((String)null);
            }
            List<String> valuesSorted = new ArrayList<String>(values);
//            Collections.sort(valuesSorted);
            return convert(valuesSorted.get(0));
        }
    }
{code}

      was (Author: elman):
    Removing the sort functionality makes all TCK tests to pass successfully:
{code}
    private static abstract class SingleValueConvertor extends ValueConvertor {

        RuntimeException createConversionException(String value, Class<?> targetClass, Throwable e) {
            if (e instanceof WebApplicationException) {
                return (RuntimeException)e;
            }
            String message = String.format("Cannot convert value '%s' to %s", value, targetClass);
            return new ConversionException(message, e);
        }

        public Object convert(List<String> values) throws WebApplicationException {
            if (values == null || values.size() == 0) {
                return convert((String)null);
            }
            List<String> valuesSorted = new ArrayList<String>(values);
//            Collections.sort(valuesSorted);
            return convert(valuesSorted.get(0));
        }
    }
{code}
  
> Fix precedence on custom type conversion
> ----------------------------------------
>
>                 Key: WINK-201
>                 URL: https://issues.apache.org/jira/browse/WINK-201
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>            Assignee: Bryant Luk
>            Priority: Critical
>             Fix For: 0.2
>
>
> Re-reading the JAX-RS spec, the implied ordering for the type conversion is constructor then valueOf() (and now fromString()).  Will change the ordering to give constructors precedence.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WINK-201) Fix precedence on custom type conversion

Posted by "Michael Elman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761148#action_12761148 ] 

Michael Elman commented on WINK-201:
------------------------------------

Removing the sort functionality makes all TCK tests to pass successfully:
{code}
    private static abstract class SingleValueConvertor extends ValueConvertor {

        RuntimeException createConversionException(String value, Class<?> targetClass, Throwable e) {
            if (e instanceof WebApplicationException) {
                return (RuntimeException)e;
            }
            String message = String.format("Cannot convert value '%s' to %s", value, targetClass);
            return new ConversionException(message, e);
        }

        public Object convert(List<String> values) throws WebApplicationException {
            if (values == null || values.size() == 0) {
                return convert((String)null);
            }
            List<String> valuesSorted = new ArrayList<String>(values);
//            Collections.sort(valuesSorted);
            return convert(valuesSorted.get(0));
        }
    }
{code}

> Fix precedence on custom type conversion
> ----------------------------------------
>
>                 Key: WINK-201
>                 URL: https://issues.apache.org/jira/browse/WINK-201
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>            Assignee: Bryant Luk
>            Priority: Critical
>             Fix For: 0.2
>
>
> Re-reading the JAX-RS spec, the implied ordering for the type conversion is constructor then valueOf() (and now fromString()).  Will change the ordering to give constructors precedence.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WINK-201) Fix precedence on custom type conversion

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761447#action_12761447 ] 

Hudson commented on WINK-201:
-----------------------------

Integrated in Wink-Trunk-JDK1.5 #194 (See [http://hudson.zones.apache.org/hudson/job/Wink-Trunk-JDK1.5/194/])
    Stop the sort during multivalued params

[See ]


> Fix precedence on custom type conversion
> ----------------------------------------
>
>                 Key: WINK-201
>                 URL: https://issues.apache.org/jira/browse/WINK-201
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>            Assignee: Bryant Luk
>            Priority: Critical
>             Fix For: 0.2
>
>
> Re-reading the JAX-RS spec, the implied ordering for the type conversion is constructor then valueOf() (and now fromString()).  Will change the ordering to give constructors precedence.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WINK-201) Fix precedence on custom type conversion

Posted by "Michael Elman (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Elman updated WINK-201:
-------------------------------

    Priority: Critical  (was: Major)

See this test:
{code}
public class HeaderTest extends MockServletInvocationTest {

    @Override
    protected Class<?>[] getClasses() {
        return new Class<?>[] {Resource.class};
    }

    @Path(value = "/test")
    public static class Resource {

        @GET
        public String stringParamHandling(@HeaderParam("A") boolean a,
                                          @HeaderParam("B") boolean b) {
            StringBuilder sb = new StringBuilder();
            if (a) {
                sb.append("a=" + a);
            }
            if (b) {
                sb.append("b=" + b);
            }
            return sb.toString();
        }
    }

    public void testHeaders() throws Exception {

        testHeader(new String[][] {{"a", "true"}},
                   "a=true");
     
        testHeader(new String[][] { {"a", "true"},
            {"a", "false"}}, "a=true");

        testHeader(new String[][] { {"a", "false"},
            {"b", "true"}}, "b=true");

        testHeader(new String[][] { {"a", "true"},
            {"b", "false"},
            {"a", "false"}}, "a=true");

    }

    private void testHeader(String[][] headers, String expected) throws Exception {
        MockHttpServletRequest request =
            MockRequestConstructor.constructMockRequest("GET",
                                                        "/test",
                                                        MediaType.WILDCARD);
        for (String[] header : headers) {
            request.addHeader(header[0], header[1]);

        }
        MockHttpServletResponse response = invoke(request);
        assertEquals(200, response.getStatus());
        assertTrue(response.getContentAsString().contains(expected));
    }
}
{code}

> Fix precedence on custom type conversion
> ----------------------------------------
>
>                 Key: WINK-201
>                 URL: https://issues.apache.org/jira/browse/WINK-201
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>            Assignee: Bryant Luk
>            Priority: Critical
>             Fix For: 0.2
>
>
> Re-reading the JAX-RS spec, the implied ordering for the type conversion is constructor then valueOf() (and now fromString()).  Will change the ordering to give constructors precedence.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WINK-201) Fix precedence on custom type conversion

Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryant Luk resolved WINK-201.
-----------------------------

    Resolution: Fixed

I've removed the change as suggested.  Thanks Michael.

> Fix precedence on custom type conversion
> ----------------------------------------
>
>                 Key: WINK-201
>                 URL: https://issues.apache.org/jira/browse/WINK-201
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>            Assignee: Bryant Luk
>            Priority: Critical
>             Fix For: 0.2
>
>
> Re-reading the JAX-RS spec, the implied ordering for the type conversion is constructor then valueOf() (and now fromString()).  Will change the ordering to give constructors precedence.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WINK-201) Fix precedence on custom type conversion

Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryant Luk resolved WINK-201.
-----------------------------

    Resolution: Fixed

Also sort values before doing the conversion so that a consistent value is used if there are multiple values.

> Fix precedence on custom type conversion
> ----------------------------------------
>
>                 Key: WINK-201
>                 URL: https://issues.apache.org/jira/browse/WINK-201
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>            Assignee: Bryant Luk
>             Fix For: 0.2
>
>
> Re-reading the JAX-RS spec, the implied ordering for the type conversion is constructor then valueOf() (and now fromString()).  Will change the ordering to give constructors precedence.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (WINK-201) Fix precedence on custom type conversion

Posted by "Michael Elman (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Elman reopened WINK-201:
--------------------------------


bq. Also sort values before doing the conversion so that a consistent value is used if there are multiple values. 
This causes some TCK tests to fail.
I'll attach patch with demonstration.

> Fix precedence on custom type conversion
> ----------------------------------------
>
>                 Key: WINK-201
>                 URL: https://issues.apache.org/jira/browse/WINK-201
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>            Assignee: Bryant Luk
>             Fix For: 0.2
>
>
> Re-reading the JAX-RS spec, the implied ordering for the type conversion is constructor then valueOf() (and now fromString()).  Will change the ordering to give constructors precedence.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (WINK-201) Fix precedence on custom type conversion

Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryant Luk closed WINK-201.
---------------------------


> Fix precedence on custom type conversion
> ----------------------------------------
>
>                 Key: WINK-201
>                 URL: https://issues.apache.org/jira/browse/WINK-201
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>            Assignee: Bryant Luk
>            Priority: Critical
>             Fix For: 0.2
>
>
> Re-reading the JAX-RS spec, the implied ordering for the type conversion is constructor then valueOf() (and now fromString()).  Will change the ordering to give constructors precedence.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.