You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by MitchK <mi...@web.de> on 2010/09/09 12:16:32 UTC

Invalid URL causes no Exception - instance keeps still

Hello list,

I noticed that when I do something like:


			System.out.println("execute Request "+method.getURI());
			int statuscode = this.httpClient.executeMethod(method);
			System.out.println("statuscode: "+statuscode);

The line "statuscode" is never printed, if the method was created with an
invalid URL.

In my test case, I tried something like that:

PostMethod method = new PostMethod("path");

Yes, I really mean "path" - this is my invalid url.

How should I notice that there went something wrong, when no Exception is
thrown?

Thank you!

- Mitch
-- 
View this message in context: http://old.nabble.com/Invalid-URL-causes-no-Exception---instance-keeps-still-tp29647704p29647704.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Invalid URL causes no Exception - instance keeps still

Posted by Ken Krugler <kk...@transpac.com>.
> I noticed that when I do something like:
>
>
> 			System.out.println("execute Request "+method.getURI());
> 			int statuscode = this.httpClient.executeMethod(method);
> 			System.out.println("statuscode: "+statuscode);
>
> The line "statuscode" is never printed, if the method was created  
> with an
> invalid URL.
>
> In my test case, I tried something like that:
>
> PostMethod method = new PostMethod("path");
>
> Yes, I really mean "path" - this is my invalid url.
>
> How should I notice that there went something wrong, when no  
> Exception is
> thrown?

No idea why you're seeing this behavior - in my experience, HttpClient  
either throws an exception or returns a valid status code.

Though I've never had this happen with HttpClient, some 3rd party jars  
can trigger Errors instead of Exceptions, so make sure you've got a  
catch(Throwable t) in place.

-- Ken

--------------------------
Ken Krugler
+1 530-210-6378
http://bixolabs.com
e l a s t i c   w e b   m i n i n g






---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org