How should I resolve java.lang.IllegalArgumentException: protocol = https host = null Exception?
URLs use forward slashes (/), not backward ones (as windows). Try:
serverURLS = "https://abc.my.domain.com:55555/update";
The reason why you get the error is that the URL class can't parse the host part of the string and therefore, host
is null
.
This code seems completely unnecessary:
String serverURLS = getRecipientURL(message);
serverURLS = "https:\\\\abc.my.domain.com:55555\\update";
if (serverURLS != null){
serverURL = new URL(serverURLS);
}
serverURLS
is assigned the result ofgetRecipientURL(message)
- Then immediately you overwrite the value of
serverURLS
, making the previous statement a dead store - Then, because
if (serverURLS != null)
evaluates totrue
, since you just assigned the variable a value in the preceding statement, you assign a value toserverURL
. It is impossible forif (serverURLS != null)
to evaluate tofalse
! - You never actually use the variable
serverURLS
beyond the previous line of code.
You could replace all of this with just:
serverURL = new URL("https:\\\\abc.my.domain.com:55555\\update");