null pointer exception
chenbihuan opened this issue · comments
Bihuan Chen commented
Hi,
The following two methods may receive a uri
with undefined scheme. Thus getScheme()
may return null
, which causes a null pointer exception. The similar problem may arise in hprose.client.HproseTcpClient
. Although it is clearly stated in the wiki that only http and tcp are supported, it is better to add such null checks.
public static HproseClient hprose.client.HproseHttpClient.create(String uri, HproseMode mode) throws IOException, URISyntaxException {
String scheme = (new URI(uri)).getScheme().toLowerCase();
if (!scheme.equals("http") && !scheme.equals("https")) {
throw new HproseException("This client doesn't support " + scheme + " scheme.");
}
return new HproseHttpClient(uri, mode);
}
public static HproseClient hprose.client.HproseHttpClient.create(String[] uris, HproseMode mode) throws IOException, URISyntaxException {
for (int i = 0, n = uris.length; i < n; ++i) {
String scheme = (new URI(uris[i])).getScheme().toLowerCase();
if (!scheme.equals("http") && !scheme.equals("https")) {
throw new HproseException("This client doesn't support " + scheme + " scheme.");
}
}
return new HproseHttpClient(uris, mode);
}
不帅任你踹 commented
Thank you.