I have next code
URL targetUrl = ...
HttpClient client = new HttpClient(connectionManager);
GetMethod getMethod = new GetMethod();
getMethod.setPath(targetUrl.getPath());
HostConfiguration hostConfiguration = getConfiguration(targetUrl) //unknown lib code
client.executeMethod(hostConfiguration, getMethod);
In some cases(on some hosts) I get
java.lang.IllegalArgumentException: host parameter is null"
on client.executeMethod call.
Why may this happen?
The error message is misleading...
You must add the protocol in front of the host, something like HTTP://
or whatever you want to use.
There may be other circumstances in which this happens, according to this blog article, but setHostConfiguration
has been deprecated so this only applies to legacy code.
The client code should catch it earlier instead of failing so deep in the system, how can incorrect data go that far?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With