Provide error message when request path is null

This commit is contained in:
Yuhao Bi 2016-11-02 00:25:20 +08:00 committed by Luca Cavanna
parent 9303165615
commit 79090431af
2 changed files with 12 additions and 0 deletions

View File

@ -510,6 +510,7 @@ public class RestClient implements Closeable {
private static URI buildUri(String pathPrefix, String path, Map<String, String> params) {
Objects.requireNonNull(params, "params must not be null");
Objects.requireNonNull(path, "path must not be null");
try {
String fullPath;
if (pathPrefix != null) {

View File

@ -229,6 +229,17 @@ public class RestClientIntegTests extends RestClientTestCase {
}
}
public void testPath() throws IOException {
for (String method : getHttpMethods()) {
try {
restClient.performRequest(method, null);
fail("path set to null should fail!");
} catch (NullPointerException e) {
assertEquals("path must not be null", e.getMessage());
}
}
}
private void bodyTest(String method) throws IOException {
String requestBody = "{ \"field\": \"value\" }";
StringEntity entity = new StringEntity(requestBody);