You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wink.apache.org by "Ingo Marahrens (JIRA)" <ji...@apache.org> on 2010/06/01 08:40:37 UTC

[jira] Created: (WINK-289) URISyntaxException when using "[" brackets in query string

URISyntaxException when using "[" brackets in query string
----------------------------------------------------------

                 Key: WINK-289
                 URL: https://issues.apache.org/jira/browse/WINK-289
             Project: Wink
          Issue Type: Bug
          Components: Common
    Affects Versions: 1.1
         Environment: Java 5, Spring, Rest Client to access ATOM based Rest Services
            Reporter: Ingo Marahrens


I am using Wink to query/read several backend services using the Atom Protocol.
One of those produces farely ugly URLs with "[" and "]" within the URL strings. 
When reading from a feed these URLs are already escaped like this          http://myserver/dm/atom/library/%5B@Pgistest/@RMain.nsf%5D/feed .
This way I can use them directly to read the next feed:

URI uri = URI.create(uriString);
new RestClient().resource(uri);

At this point everything is fine, but as it continues an exception is thrown 

java.lang.IllegalArgumentException: schemeSpecificPart is invalid
	at org.apache.wink.common.internal.UriBuilderImpl.schemeSpecificPart(UriBuilderImpl.java:867)
	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.CGLIB$schemeSpecificPart$24(<generated>)
	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec$$FastClassByCGLIB$$10e694a6.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
	at de.gish.lc.services.wink.RuntimeDelegateImpl$1.intercept(RuntimeDelegateImpl.java:39)
	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.schemeSpecificPart(<generated>)
	at org.apache.wink.common.internal.UriBuilderImpl.uri(UriBuilderImpl.java:961)
	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.CGLIB$uri$0(<generated>)
	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec$$FastClassByCGLIB$$10e694a6.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
	at de.gish.lc.services.wink.RuntimeDelegateImpl$1.intercept(RuntimeDelegateImpl.java:39)
	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.uri(<generated>)
	at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:81)
	at org.apache.wink.client.internal.ResourceImpl.<init>(ResourceImpl.java:72)
	at org.apache.wink.client.RestClient.resource(RestClient.java:99)
	at de.gish.lc.rest.connection.impl.StaticUserLoginBasedConnectionFactory.getResource(StaticUserLoginBasedConnectionFactory.java:105)
	at de.gish.lc.services.wink.AbstractWinkService.readAtomFeed(AbstractWinkService.java:175)
	at de.gish.lc.services.wink.QuickrServiceWink.readFeed(QuickrServiceWink.java:47)
	at de.gish.lc.services.wink.QuickrServiceWink.readLibraryFeedForEntry(QuickrServiceWink.java:119)
	at de.gish.lc.services.QuickrServiceTest.readLibraryFeedForEntry(QuickrServiceTest.java:74)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.net.URISyntaxException: Illegal character in path at index 39: https://quickr.gish.de/dm/atom/library/[@Pgistest/@RMain.nsf]/feed
	at java.net.URI$Parser.fail(URI.java:2809)
	at java.net.URI$Parser.checkChars(URI.java:2982)
	at java.net.URI$Parser.parseHierarchical(URI.java:3066)
	at java.net.URI$Parser.parse(URI.java:3014)
	at java.net.URI.<init>(URI.java:807)
	at org.apache.wink.common.internal.UriBuilderImpl.schemeSpecificPart(UriBuilderImpl.java:865)
	... 48 more

This looks like it is out of the   public UriBuilder schemeSpecificPart(String ssp) throws IllegalArgumentException {...}
but as I investigated further the "ssp" String now is   "//myserver/dm/atom/library/[@Pgistest/@RMain.nsf]/feed"
which means that the brackts ("[" and "]") are not escaped any more.
The call comes from    
public UriBuilder uri(URI uri) throws IllegalArgumentException {
 ....

	if (uri.getSchemeSpecificPart() != null) {
            logger.debug("Constructing schemeSpecificPart"); 
            schemeSpecificPart(uri.getSchemeSpecificPart());
        }
 ....
}
The URI object I created at the beginning with the escape characters for the brackets now returns an unescaped URI string as result of uri.getSchemeSpecificPart().
As this is used as a direct input for constructing a new URI object within this part of the UriBuilderImpl this leads to an IllegalArgumentException.


    public UriBuilder schemeSpecificPart(String ssp) throws IllegalArgumentException {
        ...

        URI uri = null;
        try {
            // uri templates will be automatically encoded
            uri = new URI(scheme, ssp, fragment);
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("schemeSpecificPart is invalid", e);
        }
       	....
    }
 
This leads to the conclusion that URIs with special characters like brackets are currently not supported as (feed) urls.

My current workaround is to use a proxy for the UriBuilderImpl class which catches the Exception and will than encode the part of the URI again before use.

	Enhancer e = new Enhancer();
        e.setSuperclass(originalBuilder.getClass());
        e.setCallback(new MethodInterceptor() {
            public Object intercept(Object obj, java.lang.reflect.Method method, Object[] args, MethodProxy proxy) throws Throwable {

                Object result;
                if ("schemeSpecificPart".equals(method.getName())) {
                    try {
                        result = proxy.invokeSuper(obj, args);
                    } catch (IllegalArgumentException iae) {
                        String ssp = (String) args[0];
                        String encoded = UriUtils.encodeUri(ssp, "UTF-8");
                        LOG.debug("in [{}], out [{}]", new Object[]{ssp, encoded });
                        // set encoded value:
                        result = proxy.invokeSuper(obj, new Object[]{encoded });
                    }

                } else {
                    // do normal execution
                    result = proxy.invokeSuper(obj, args);
                }
                return result;
            }
        });
        
 As we are using the Spring framework I used the UriUtils from Spring to escape the URI string again.
 As this is just a workaround not a solution, I hope for a fix within Wink to handle this.
 

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


[jira] Commented: (WINK-289) URISyntaxException when using "[" brackets in query string

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

Jesse Ramos commented on WINK-289:
----------------------------------

When getting the information from the URI we're calling URI.getSchemeSpecificPart() when we should be using getRawSchemeSpecificPart().

When switching over to use the correct method call, I ran into another issue in our code where URI.getAuthority() has a value but getHost() does not.  We check to see if getHost() is null before setting the host but don't check getAuthority() resulting in part of the URI being lost.

Checking in a fix for both issues.

> URISyntaxException when using "[" brackets in query string
> ----------------------------------------------------------
>
>                 Key: WINK-289
>                 URL: https://issues.apache.org/jira/browse/WINK-289
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 1.1
>         Environment: Java 5, Spring, Rest Client to access ATOM based Rest Services
>            Reporter: Ingo Marahrens
>            Assignee: Jesse Ramos
>
> I am using Wink to query/read several backend services using the Atom Protocol.
> One of those produces farely ugly URLs with "[" and "]" within the URL strings. 
> When reading from a feed these URLs are already escaped like this          http://myserver/dm/atom/library/%5B@Pgistest/@RMain.nsf%5D/feed .
> This way I can use them directly to read the next feed:
> URI uri = URI.create(uriString);
> new RestClient().resource(uri);
> At this point everything is fine, but as it continues an exception is thrown 
> java.lang.IllegalArgumentException: schemeSpecificPart is invalid
> 	at org.apache.wink.common.internal.UriBuilderImpl.schemeSpecificPart(UriBuilderImpl.java:867)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.CGLIB$schemeSpecificPart$24(<generated>)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec$$FastClassByCGLIB$$10e694a6.invoke(<generated>)
> 	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
> 	at de.gish.lc.services.wink.RuntimeDelegateImpl$1.intercept(RuntimeDelegateImpl.java:39)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.schemeSpecificPart(<generated>)
> 	at org.apache.wink.common.internal.UriBuilderImpl.uri(UriBuilderImpl.java:961)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.CGLIB$uri$0(<generated>)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec$$FastClassByCGLIB$$10e694a6.invoke(<generated>)
> 	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
> 	at de.gish.lc.services.wink.RuntimeDelegateImpl$1.intercept(RuntimeDelegateImpl.java:39)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.uri(<generated>)
> 	at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:81)
> 	at org.apache.wink.client.internal.ResourceImpl.<init>(ResourceImpl.java:72)
> 	at org.apache.wink.client.RestClient.resource(RestClient.java:99)
> 	at de.gish.lc.rest.connection.impl.StaticUserLoginBasedConnectionFactory.getResource(StaticUserLoginBasedConnectionFactory.java:105)
> 	at de.gish.lc.services.wink.AbstractWinkService.readAtomFeed(AbstractWinkService.java:175)
> 	at de.gish.lc.services.wink.QuickrServiceWink.readFeed(QuickrServiceWink.java:47)
> 	at de.gish.lc.services.wink.QuickrServiceWink.readLibraryFeedForEntry(QuickrServiceWink.java:119)
> 	at de.gish.lc.services.QuickrServiceTest.readLibraryFeedForEntry(QuickrServiceTest.java:74)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
> 	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
> 	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
> 	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
> 	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
> 	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> 	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
> 	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> 	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: java.net.URISyntaxException: Illegal character in path at index 39: https://quickr.gish.de/dm/atom/library/[@Pgistest/@RMain.nsf]/feed
> 	at java.net.URI$Parser.fail(URI.java:2809)
> 	at java.net.URI$Parser.checkChars(URI.java:2982)
> 	at java.net.URI$Parser.parseHierarchical(URI.java:3066)
> 	at java.net.URI$Parser.parse(URI.java:3014)
> 	at java.net.URI.<init>(URI.java:807)
> 	at org.apache.wink.common.internal.UriBuilderImpl.schemeSpecificPart(UriBuilderImpl.java:865)
> 	... 48 more
> This looks like it is out of the   public UriBuilder schemeSpecificPart(String ssp) throws IllegalArgumentException {...}
> but as I investigated further the "ssp" String now is   "//myserver/dm/atom/library/[@Pgistest/@RMain.nsf]/feed"
> which means that the brackts ("[" and "]") are not escaped any more.
> The call comes from    
> public UriBuilder uri(URI uri) throws IllegalArgumentException {
>  ....
> 	if (uri.getSchemeSpecificPart() != null) {
>             logger.debug("Constructing schemeSpecificPart"); 
>             schemeSpecificPart(uri.getSchemeSpecificPart());
>         }
>  ....
> }
> The URI object I created at the beginning with the escape characters for the brackets now returns an unescaped URI string as result of uri.getSchemeSpecificPart().
> As this is used as a direct input for constructing a new URI object within this part of the UriBuilderImpl this leads to an IllegalArgumentException.
>     public UriBuilder schemeSpecificPart(String ssp) throws IllegalArgumentException {
>         ...
>         URI uri = null;
>         try {
>             // uri templates will be automatically encoded
>             uri = new URI(scheme, ssp, fragment);
>         } catch (URISyntaxException e) {
>             throw new IllegalArgumentException("schemeSpecificPart is invalid", e);
>         }
>        	....
>     }
>  
> This leads to the conclusion that URIs with special characters like brackets are currently not supported as (feed) urls.
> My current workaround is to use a proxy for the UriBuilderImpl class which catches the Exception and will than encode the part of the URI again before use.
> 	Enhancer e = new Enhancer();
>         e.setSuperclass(originalBuilder.getClass());
>         e.setCallback(new MethodInterceptor() {
>             public Object intercept(Object obj, java.lang.reflect.Method method, Object[] args, MethodProxy proxy) throws Throwable {
>                 Object result;
>                 if ("schemeSpecificPart".equals(method.getName())) {
>                     try {
>                         result = proxy.invokeSuper(obj, args);
>                     } catch (IllegalArgumentException iae) {
>                         String ssp = (String) args[0];
>                         String encoded = UriUtils.encodeUri(ssp, "UTF-8");
>                         LOG.debug("in [{}], out [{}]", new Object[]{ssp, encoded });
>                         // set encoded value:
>                         result = proxy.invokeSuper(obj, new Object[]{encoded });
>                     }
>                 } else {
>                     // do normal execution
>                     result = proxy.invokeSuper(obj, args);
>                 }
>                 return result;
>             }
>         });
>         
>  As we are using the Spring framework I used the UriUtils from Spring to escape the URI string again.
>  As this is just a workaround not a solution, I hope for a fix within Wink to handle this.
>  

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


[jira] Resolved: (WINK-289) URISyntaxException when using "[" brackets in query string

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

Bryant Luk resolved WINK-289.
-----------------------------

    Fix Version/s: 1.1.1
       Resolution: Fixed

I think this is fixed now so marking it Resolved.

> URISyntaxException when using "[" brackets in query string
> ----------------------------------------------------------
>
>                 Key: WINK-289
>                 URL: https://issues.apache.org/jira/browse/WINK-289
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 1.1
>         Environment: Java 5, Spring, Rest Client to access ATOM based Rest Services
>            Reporter: Ingo Marahrens
>            Assignee: Jesse Ramos
>             Fix For: 1.1.1
>
>
> I am using Wink to query/read several backend services using the Atom Protocol.
> One of those produces farely ugly URLs with "[" and "]" within the URL strings. 
> When reading from a feed these URLs are already escaped like this          http://myserver/dm/atom/library/%5B@Pgistest/@RMain.nsf%5D/feed .
> This way I can use them directly to read the next feed:
> URI uri = URI.create(uriString);
> new RestClient().resource(uri);
> At this point everything is fine, but as it continues an exception is thrown 
> java.lang.IllegalArgumentException: schemeSpecificPart is invalid
> 	at org.apache.wink.common.internal.UriBuilderImpl.schemeSpecificPart(UriBuilderImpl.java:867)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.CGLIB$schemeSpecificPart$24(<generated>)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec$$FastClassByCGLIB$$10e694a6.invoke(<generated>)
> 	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
> 	at de.gish.lc.services.wink.RuntimeDelegateImpl$1.intercept(RuntimeDelegateImpl.java:39)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.schemeSpecificPart(<generated>)
> 	at org.apache.wink.common.internal.UriBuilderImpl.uri(UriBuilderImpl.java:961)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.CGLIB$uri$0(<generated>)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec$$FastClassByCGLIB$$10e694a6.invoke(<generated>)
> 	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
> 	at de.gish.lc.services.wink.RuntimeDelegateImpl$1.intercept(RuntimeDelegateImpl.java:39)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.uri(<generated>)
> 	at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:81)
> 	at org.apache.wink.client.internal.ResourceImpl.<init>(ResourceImpl.java:72)
> 	at org.apache.wink.client.RestClient.resource(RestClient.java:99)
> 	at de.gish.lc.rest.connection.impl.StaticUserLoginBasedConnectionFactory.getResource(StaticUserLoginBasedConnectionFactory.java:105)
> 	at de.gish.lc.services.wink.AbstractWinkService.readAtomFeed(AbstractWinkService.java:175)
> 	at de.gish.lc.services.wink.QuickrServiceWink.readFeed(QuickrServiceWink.java:47)
> 	at de.gish.lc.services.wink.QuickrServiceWink.readLibraryFeedForEntry(QuickrServiceWink.java:119)
> 	at de.gish.lc.services.QuickrServiceTest.readLibraryFeedForEntry(QuickrServiceTest.java:74)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
> 	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
> 	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
> 	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
> 	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
> 	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> 	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
> 	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> 	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: java.net.URISyntaxException: Illegal character in path at index 39: https://quickr.gish.de/dm/atom/library/[@Pgistest/@RMain.nsf]/feed
> 	at java.net.URI$Parser.fail(URI.java:2809)
> 	at java.net.URI$Parser.checkChars(URI.java:2982)
> 	at java.net.URI$Parser.parseHierarchical(URI.java:3066)
> 	at java.net.URI$Parser.parse(URI.java:3014)
> 	at java.net.URI.<init>(URI.java:807)
> 	at org.apache.wink.common.internal.UriBuilderImpl.schemeSpecificPart(UriBuilderImpl.java:865)
> 	... 48 more
> This looks like it is out of the   public UriBuilder schemeSpecificPart(String ssp) throws IllegalArgumentException {...}
> but as I investigated further the "ssp" String now is   "//myserver/dm/atom/library/[@Pgistest/@RMain.nsf]/feed"
> which means that the brackts ("[" and "]") are not escaped any more.
> The call comes from    
> public UriBuilder uri(URI uri) throws IllegalArgumentException {
>  ....
> 	if (uri.getSchemeSpecificPart() != null) {
>             logger.debug("Constructing schemeSpecificPart"); 
>             schemeSpecificPart(uri.getSchemeSpecificPart());
>         }
>  ....
> }
> The URI object I created at the beginning with the escape characters for the brackets now returns an unescaped URI string as result of uri.getSchemeSpecificPart().
> As this is used as a direct input for constructing a new URI object within this part of the UriBuilderImpl this leads to an IllegalArgumentException.
>     public UriBuilder schemeSpecificPart(String ssp) throws IllegalArgumentException {
>         ...
>         URI uri = null;
>         try {
>             // uri templates will be automatically encoded
>             uri = new URI(scheme, ssp, fragment);
>         } catch (URISyntaxException e) {
>             throw new IllegalArgumentException("schemeSpecificPart is invalid", e);
>         }
>        	....
>     }
>  
> This leads to the conclusion that URIs with special characters like brackets are currently not supported as (feed) urls.
> My current workaround is to use a proxy for the UriBuilderImpl class which catches the Exception and will than encode the part of the URI again before use.
> 	Enhancer e = new Enhancer();
>         e.setSuperclass(originalBuilder.getClass());
>         e.setCallback(new MethodInterceptor() {
>             public Object intercept(Object obj, java.lang.reflect.Method method, Object[] args, MethodProxy proxy) throws Throwable {
>                 Object result;
>                 if ("schemeSpecificPart".equals(method.getName())) {
>                     try {
>                         result = proxy.invokeSuper(obj, args);
>                     } catch (IllegalArgumentException iae) {
>                         String ssp = (String) args[0];
>                         String encoded = UriUtils.encodeUri(ssp, "UTF-8");
>                         LOG.debug("in [{}], out [{}]", new Object[]{ssp, encoded });
>                         // set encoded value:
>                         result = proxy.invokeSuper(obj, new Object[]{encoded });
>                     }
>                 } else {
>                     // do normal execution
>                     result = proxy.invokeSuper(obj, args);
>                 }
>                 return result;
>             }
>         });
>         
>  As we are using the Spring framework I used the UriUtils from Spring to escape the URI string again.
>  As this is just a workaround not a solution, I hope for a fix within Wink to handle this.
>  

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


[jira] Assigned: (WINK-289) URISyntaxException when using "[" brackets in query string

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

Jesse Ramos reassigned WINK-289:
--------------------------------

    Assignee: Jesse Ramos

> URISyntaxException when using "[" brackets in query string
> ----------------------------------------------------------
>
>                 Key: WINK-289
>                 URL: https://issues.apache.org/jira/browse/WINK-289
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 1.1
>         Environment: Java 5, Spring, Rest Client to access ATOM based Rest Services
>            Reporter: Ingo Marahrens
>            Assignee: Jesse Ramos
>
> I am using Wink to query/read several backend services using the Atom Protocol.
> One of those produces farely ugly URLs with "[" and "]" within the URL strings. 
> When reading from a feed these URLs are already escaped like this          http://myserver/dm/atom/library/%5B@Pgistest/@RMain.nsf%5D/feed .
> This way I can use them directly to read the next feed:
> URI uri = URI.create(uriString);
> new RestClient().resource(uri);
> At this point everything is fine, but as it continues an exception is thrown 
> java.lang.IllegalArgumentException: schemeSpecificPart is invalid
> 	at org.apache.wink.common.internal.UriBuilderImpl.schemeSpecificPart(UriBuilderImpl.java:867)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.CGLIB$schemeSpecificPart$24(<generated>)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec$$FastClassByCGLIB$$10e694a6.invoke(<generated>)
> 	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
> 	at de.gish.lc.services.wink.RuntimeDelegateImpl$1.intercept(RuntimeDelegateImpl.java:39)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.schemeSpecificPart(<generated>)
> 	at org.apache.wink.common.internal.UriBuilderImpl.uri(UriBuilderImpl.java:961)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.CGLIB$uri$0(<generated>)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec$$FastClassByCGLIB$$10e694a6.invoke(<generated>)
> 	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
> 	at de.gish.lc.services.wink.RuntimeDelegateImpl$1.intercept(RuntimeDelegateImpl.java:39)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.uri(<generated>)
> 	at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:81)
> 	at org.apache.wink.client.internal.ResourceImpl.<init>(ResourceImpl.java:72)
> 	at org.apache.wink.client.RestClient.resource(RestClient.java:99)
> 	at de.gish.lc.rest.connection.impl.StaticUserLoginBasedConnectionFactory.getResource(StaticUserLoginBasedConnectionFactory.java:105)
> 	at de.gish.lc.services.wink.AbstractWinkService.readAtomFeed(AbstractWinkService.java:175)
> 	at de.gish.lc.services.wink.QuickrServiceWink.readFeed(QuickrServiceWink.java:47)
> 	at de.gish.lc.services.wink.QuickrServiceWink.readLibraryFeedForEntry(QuickrServiceWink.java:119)
> 	at de.gish.lc.services.QuickrServiceTest.readLibraryFeedForEntry(QuickrServiceTest.java:74)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
> 	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
> 	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
> 	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
> 	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
> 	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> 	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
> 	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> 	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: java.net.URISyntaxException: Illegal character in path at index 39: https://quickr.gish.de/dm/atom/library/[@Pgistest/@RMain.nsf]/feed
> 	at java.net.URI$Parser.fail(URI.java:2809)
> 	at java.net.URI$Parser.checkChars(URI.java:2982)
> 	at java.net.URI$Parser.parseHierarchical(URI.java:3066)
> 	at java.net.URI$Parser.parse(URI.java:3014)
> 	at java.net.URI.<init>(URI.java:807)
> 	at org.apache.wink.common.internal.UriBuilderImpl.schemeSpecificPart(UriBuilderImpl.java:865)
> 	... 48 more
> This looks like it is out of the   public UriBuilder schemeSpecificPart(String ssp) throws IllegalArgumentException {...}
> but as I investigated further the "ssp" String now is   "//myserver/dm/atom/library/[@Pgistest/@RMain.nsf]/feed"
> which means that the brackts ("[" and "]") are not escaped any more.
> The call comes from    
> public UriBuilder uri(URI uri) throws IllegalArgumentException {
>  ....
> 	if (uri.getSchemeSpecificPart() != null) {
>             logger.debug("Constructing schemeSpecificPart"); 
>             schemeSpecificPart(uri.getSchemeSpecificPart());
>         }
>  ....
> }
> The URI object I created at the beginning with the escape characters for the brackets now returns an unescaped URI string as result of uri.getSchemeSpecificPart().
> As this is used as a direct input for constructing a new URI object within this part of the UriBuilderImpl this leads to an IllegalArgumentException.
>     public UriBuilder schemeSpecificPart(String ssp) throws IllegalArgumentException {
>         ...
>         URI uri = null;
>         try {
>             // uri templates will be automatically encoded
>             uri = new URI(scheme, ssp, fragment);
>         } catch (URISyntaxException e) {
>             throw new IllegalArgumentException("schemeSpecificPart is invalid", e);
>         }
>        	....
>     }
>  
> This leads to the conclusion that URIs with special characters like brackets are currently not supported as (feed) urls.
> My current workaround is to use a proxy for the UriBuilderImpl class which catches the Exception and will than encode the part of the URI again before use.
> 	Enhancer e = new Enhancer();
>         e.setSuperclass(originalBuilder.getClass());
>         e.setCallback(new MethodInterceptor() {
>             public Object intercept(Object obj, java.lang.reflect.Method method, Object[] args, MethodProxy proxy) throws Throwable {
>                 Object result;
>                 if ("schemeSpecificPart".equals(method.getName())) {
>                     try {
>                         result = proxy.invokeSuper(obj, args);
>                     } catch (IllegalArgumentException iae) {
>                         String ssp = (String) args[0];
>                         String encoded = UriUtils.encodeUri(ssp, "UTF-8");
>                         LOG.debug("in [{}], out [{}]", new Object[]{ssp, encoded });
>                         // set encoded value:
>                         result = proxy.invokeSuper(obj, new Object[]{encoded });
>                     }
>                 } else {
>                     // do normal execution
>                     result = proxy.invokeSuper(obj, args);
>                 }
>                 return result;
>             }
>         });
>         
>  As we are using the Spring framework I used the UriUtils from Spring to escape the URI string again.
>  As this is just a workaround not a solution, I hope for a fix within Wink to handle this.
>  

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


[jira] Commented: (WINK-289) URISyntaxException when using "[" brackets in query string

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

Hudson commented on WINK-289:
-----------------------------

Integrated in Wink-Trunk-JDK1.5 #340 (See [http://hudson.zones.apache.org/hudson/job/Wink-Trunk-JDK1.5/340/])
    [WINK-289] Use URI.getRawSchemeSpecificPart() when getting informatin from a URI


> URISyntaxException when using "[" brackets in query string
> ----------------------------------------------------------
>
>                 Key: WINK-289
>                 URL: https://issues.apache.org/jira/browse/WINK-289
>             Project: Wink
>          Issue Type: Bug
>          Components: Common
>    Affects Versions: 1.1
>         Environment: Java 5, Spring, Rest Client to access ATOM based Rest Services
>            Reporter: Ingo Marahrens
>            Assignee: Jesse Ramos
>
> I am using Wink to query/read several backend services using the Atom Protocol.
> One of those produces farely ugly URLs with "[" and "]" within the URL strings. 
> When reading from a feed these URLs are already escaped like this          http://myserver/dm/atom/library/%5B@Pgistest/@RMain.nsf%5D/feed .
> This way I can use them directly to read the next feed:
> URI uri = URI.create(uriString);
> new RestClient().resource(uri);
> At this point everything is fine, but as it continues an exception is thrown 
> java.lang.IllegalArgumentException: schemeSpecificPart is invalid
> 	at org.apache.wink.common.internal.UriBuilderImpl.schemeSpecificPart(UriBuilderImpl.java:867)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.CGLIB$schemeSpecificPart$24(<generated>)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec$$FastClassByCGLIB$$10e694a6.invoke(<generated>)
> 	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
> 	at de.gish.lc.services.wink.RuntimeDelegateImpl$1.intercept(RuntimeDelegateImpl.java:39)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.schemeSpecificPart(<generated>)
> 	at org.apache.wink.common.internal.UriBuilderImpl.uri(UriBuilderImpl.java:961)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.CGLIB$uri$0(<generated>)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec$$FastClassByCGLIB$$10e694a6.invoke(<generated>)
> 	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
> 	at de.gish.lc.services.wink.RuntimeDelegateImpl$1.intercept(RuntimeDelegateImpl.java:39)
> 	at org.apache.wink.common.internal.UriBuilderImpl$$EnhancerByCGLIB$$927fbbec.uri(<generated>)
> 	at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:81)
> 	at org.apache.wink.client.internal.ResourceImpl.<init>(ResourceImpl.java:72)
> 	at org.apache.wink.client.RestClient.resource(RestClient.java:99)
> 	at de.gish.lc.rest.connection.impl.StaticUserLoginBasedConnectionFactory.getResource(StaticUserLoginBasedConnectionFactory.java:105)
> 	at de.gish.lc.services.wink.AbstractWinkService.readAtomFeed(AbstractWinkService.java:175)
> 	at de.gish.lc.services.wink.QuickrServiceWink.readFeed(QuickrServiceWink.java:47)
> 	at de.gish.lc.services.wink.QuickrServiceWink.readLibraryFeedForEntry(QuickrServiceWink.java:119)
> 	at de.gish.lc.services.QuickrServiceTest.readLibraryFeedForEntry(QuickrServiceTest.java:74)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
> 	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
> 	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
> 	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
> 	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
> 	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> 	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
> 	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> 	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: java.net.URISyntaxException: Illegal character in path at index 39: https://quickr.gish.de/dm/atom/library/[@Pgistest/@RMain.nsf]/feed
> 	at java.net.URI$Parser.fail(URI.java:2809)
> 	at java.net.URI$Parser.checkChars(URI.java:2982)
> 	at java.net.URI$Parser.parseHierarchical(URI.java:3066)
> 	at java.net.URI$Parser.parse(URI.java:3014)
> 	at java.net.URI.<init>(URI.java:807)
> 	at org.apache.wink.common.internal.UriBuilderImpl.schemeSpecificPart(UriBuilderImpl.java:865)
> 	... 48 more
> This looks like it is out of the   public UriBuilder schemeSpecificPart(String ssp) throws IllegalArgumentException {...}
> but as I investigated further the "ssp" String now is   "//myserver/dm/atom/library/[@Pgistest/@RMain.nsf]/feed"
> which means that the brackts ("[" and "]") are not escaped any more.
> The call comes from    
> public UriBuilder uri(URI uri) throws IllegalArgumentException {
>  ....
> 	if (uri.getSchemeSpecificPart() != null) {
>             logger.debug("Constructing schemeSpecificPart"); 
>             schemeSpecificPart(uri.getSchemeSpecificPart());
>         }
>  ....
> }
> The URI object I created at the beginning with the escape characters for the brackets now returns an unescaped URI string as result of uri.getSchemeSpecificPart().
> As this is used as a direct input for constructing a new URI object within this part of the UriBuilderImpl this leads to an IllegalArgumentException.
>     public UriBuilder schemeSpecificPart(String ssp) throws IllegalArgumentException {
>         ...
>         URI uri = null;
>         try {
>             // uri templates will be automatically encoded
>             uri = new URI(scheme, ssp, fragment);
>         } catch (URISyntaxException e) {
>             throw new IllegalArgumentException("schemeSpecificPart is invalid", e);
>         }
>        	....
>     }
>  
> This leads to the conclusion that URIs with special characters like brackets are currently not supported as (feed) urls.
> My current workaround is to use a proxy for the UriBuilderImpl class which catches the Exception and will than encode the part of the URI again before use.
> 	Enhancer e = new Enhancer();
>         e.setSuperclass(originalBuilder.getClass());
>         e.setCallback(new MethodInterceptor() {
>             public Object intercept(Object obj, java.lang.reflect.Method method, Object[] args, MethodProxy proxy) throws Throwable {
>                 Object result;
>                 if ("schemeSpecificPart".equals(method.getName())) {
>                     try {
>                         result = proxy.invokeSuper(obj, args);
>                     } catch (IllegalArgumentException iae) {
>                         String ssp = (String) args[0];
>                         String encoded = UriUtils.encodeUri(ssp, "UTF-8");
>                         LOG.debug("in [{}], out [{}]", new Object[]{ssp, encoded });
>                         // set encoded value:
>                         result = proxy.invokeSuper(obj, new Object[]{encoded });
>                     }
>                 } else {
>                     // do normal execution
>                     result = proxy.invokeSuper(obj, args);
>                 }
>                 return result;
>             }
>         });
>         
>  As we are using the Spring framework I used the UriUtils from Spring to escape the URI string again.
>  As this is just a workaround not a solution, I hope for a fix within Wink to handle this.
>  

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