[ 
https://issues.apache.org/jira/browse/CAMEL-11506?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16073274#comment-16073274
 ] 

Claus Ibsen commented on CAMEL-11506:
-------------------------------------

Ah Apache Ivy allows to use the older http client 3.1 instead of the JDK, so we 
can try to add it to the classpath
{code}
    /**
     * This method is used to get appropriate http downloader dependening on 
Jakarta Commons
     * HttpClient availability in classpath, or simply use jdk url handling in 
other cases.
     * 
     * @return most accurate http downloader
     */
    public static URLHandler getHttp() {
        try {
            Class.forName("org.apache.commons.httpclient.HttpClient");

            // temporary fix for IVY-880: only use HttpClientHandler when
            // http-client-3.x is available
            
Class.forName("org.apache.commons.httpclient.params.HttpClientParams");

            Class handler = 
Class.forName("org.apache.ivy.util.url.HttpClientHandler");
            Message.verbose("jakarta commons httpclient detected: using it for 
http downloading");
            return (URLHandler) handler.newInstance();
        } catch (ClassNotFoundException e) {
            Message.verbose("jakarta commons httpclient not found: using jdk 
url handling");
            return new BasicURLHandler();
        } catch (NoClassDefFoundError e) {
            Message.verbose("error occurred while loading jakarta commons 
httpclient: "
                    + e.getMessage());
            Message.verbose("Using jdk url handling instead.");
            return new BasicURLHandler();
        } catch (InstantiationException e) {
            Message.verbose("couldn't instantiate HttpClientHandler: using jdk 
url handling");
            return new BasicURLHandler();
        } catch (IllegalAccessException e) {
            Message.verbose("couldn't instantiate HttpClientHandler: using jdk 
url handling");
            return new BasicURLHandler();
        }
    }
{code}

> MavenVersionManager blocks on unavailable URL
> ---------------------------------------------
>
>                 Key: CAMEL-11506
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11506
>             Project: Camel
>          Issue Type: Improvement
>          Components: tooling
>    Affects Versions: 2.19.0
>            Reporter: Lars Heinemann
>
> If I try to load the catalog of a not existing Camel version using the 
> MavenVersionManager then the call to load does not return.
> Below is the appropriate stack of the thread which is never returning. 
> {noformat}
> "main" #1 prio=6 os_prio=0 tid=0x00007f6ea800b000 nid=0x12da runnable 
> [0x00007f6eb2013000]
>    java.lang.Thread.State: RUNNABLE
>       at java.net.SocketInputStream.socketRead0(Native Method)
>       at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
>       at java.net.SocketInputStream.read(SocketInputStream.java:171)
>       at java.net.SocketInputStream.read(SocketInputStream.java:141)
>       at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
>       at sun.security.ssl.InputRecord.read(InputRecord.java:503)
>       at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
>       - locked <0x00000007b0be7870> (a java.lang.Object)
>       at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:940)
>       at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
>       - locked <0x00000007b0be8668> (a sun.security.ssl.AppInputStream)
>       at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
>       at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
>       at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
>       - locked <0x0000000773a4de60> (a java.io.BufferedInputStream)
>       at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:735)
>       at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678)
>       at 
> sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1569)
>       - locked <0x0000000773a4baa0> (a 
> sun.net.www.protocol.https.DelegateHttpsURLConnection)
>       at 
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
>       - locked <0x0000000773a4baa0> (a 
> sun.net.www.protocol.https.DelegateHttpsURLConnection)
>       at 
> java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
>       at 
> sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
>       at 
> org.apache.ivy.util.url.BasicURLHandler.checkStatusCode(BasicURLHandler.java:131)
>       at 
> org.apache.ivy.util.url.BasicURLHandler.getURLInfo(BasicURLHandler.java:73)
>       at 
> org.apache.ivy.util.url.BasicURLHandler.getURLInfo(BasicURLHandler.java:54)
>       at 
> org.apache.ivy.plugins.repository.url.URLResource.init(URLResource.java:68)
>       at 
> org.apache.ivy.plugins.repository.url.URLResource.exists(URLResource.java:84)
>       at 
> org.apache.ivy.plugins.resolver.RepositoryResolver.findResourceUsingPattern(RepositoryResolver.java:97)
>       at 
> org.apache.ivy.plugins.resolver.AbstractPatternsBasedResolver.findResourceUsingPatterns(AbstractPatternsBasedResolver.java:97)
>       at 
> org.apache.ivy.plugins.resolver.IBiblioResolver.findArtifactRef(IBiblioResolver.java:125)
>       at 
> org.apache.ivy.plugins.resolver.BasicResolver.getArtifactRef(BasicResolver.java:1034)
>       at 
> org.apache.ivy.plugins.resolver.BasicResolver.findFirstArtifactRef(BasicResolver.java:971)
>       at 
> org.apache.ivy.plugins.resolver.BasicResolver.getDependency(BasicResolver.java:243)
>       at 
> org.apache.ivy.plugins.resolver.IBiblioResolver.getDependency(IBiblioResolver.java:506)
>       at 
> org.apache.ivy.plugins.resolver.ChainResolver.getDependency(ChainResolver.java:104)
>       at org.apache.ivy.core.resolve.IvyNode.loadData(IvyNode.java:170)
>       at org.apache.ivy.core.resolve.VisitNode.loadData(VisitNode.java:292)
>       at 
> org.apache.ivy.core.resolve.ResolveEngine.fetchDependencies(ResolveEngine.java:718)
>       at 
> org.apache.ivy.core.resolve.ResolveEngine.doFetchDependencies(ResolveEngine.java:803)
>       at 
> org.apache.ivy.core.resolve.ResolveEngine.fetchDependencies(ResolveEngine.java:726)
>       at 
> org.apache.ivy.core.resolve.ResolveEngine.getDependencies(ResolveEngine.java:599)
>       at 
> org.apache.ivy.core.resolve.ResolveEngine.resolve(ResolveEngine.java:236)
>       at org.apache.ivy.Ivy.resolve(Ivy.java:523)
>       at org.apache.ivy.Ivy$resolve$0.call(Unknown Source)
>       at groovy.grape.GrapeIvy.getDependencies(GrapeIvy.groovy:410)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:498)
>       at 
> org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:169)
>       at 
> org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
>       at groovy.grape.GrapeIvy.resolve(GrapeIvy.groovy:571)
>       at groovy.grape.GrapeIvy$resolve$1.callCurrent(Unknown Source)
>       at groovy.grape.GrapeIvy.resolve(GrapeIvy.groovy:538)
>       at groovy.grape.GrapeIvy$resolve$0.callCurrent(Unknown Source)
>       at groovy.grape.GrapeIvy.grab(GrapeIvy.groovy:256)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:498)
>       at 
> org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:169)
>       at 
> org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174)
>       at groovy.grape.GrapeIvy.grab(GrapeIvy.groovy:237)
>       at groovy.grape.Grape.grab(Grape.java:152)
>       at 
> org.apache.camel.catalog.maven.MavenVersionManager.loadVersion(MavenVersionManager.java:91)
> {noformat}
> It would be really helpful if we'd had a method to specify a timeout or at 
> least that a good timeout value is preset as default. (like 1 minute for 
> instance)
> Tbh I am rather unsure if that can be fixed in Camel directly or if Ivy 
> should be fixed. IMO before accessing a URI Ivy's BasicURLHandler should use 
> the isReachable(url, timeout) to test if it makes sense at all to connect 
> instead of using getURLInfo right away?



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to