[OLINGO-1117] Sending skip and take requests without a value returns String index out of range Exception
This commit is contained in:
parent
8f1a079faf
commit
891421d7fc
|
@ -181,5 +181,29 @@ public class BasicHttpITCase extends AbstractBaseTestITCase {
|
|||
protected ODataClient getClient() {
|
||||
return null;
|
||||
}
|
||||
@Test
|
||||
public void testInvalidTopUrl() throws Exception {
|
||||
URL url = new URL(SERVICE_URI + "?$top");
|
||||
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod(HttpMethod.GET.name());
|
||||
connection.connect();
|
||||
|
||||
assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), connection.getResponseCode());
|
||||
assertTrue(IOUtils.toString(connection.getErrorStream()).
|
||||
contains("The system query option '$top' has the not-allowed value ''."));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidSkipUrl() throws Exception {
|
||||
URL url = new URL(SERVICE_URI + "?$skip=");
|
||||
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod(HttpMethod.GET.name());
|
||||
connection.connect();
|
||||
|
||||
assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), connection.getResponseCode());
|
||||
assertTrue(IOUtils.toString(connection.getErrorStream()).
|
||||
contains("The system query option '$skip' has the not-allowed value ''."));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -211,7 +211,10 @@ public class ODataHandlerImpl implements ODataHandler {
|
|||
if(endIndex == -1) {
|
||||
endIndex = query.length();
|
||||
}
|
||||
final String format = query.substring(index + formatOption.length(), endIndex);
|
||||
String format = "";
|
||||
if (index + formatOption.length() < endIndex) {
|
||||
format = query.substring(index + formatOption.length(), endIndex);
|
||||
}
|
||||
return new FormatOptionImpl().setFormat(format);
|
||||
}
|
||||
return uriInfo.getFormatOption();
|
||||
|
|
Loading…
Reference in New Issue