Throw consistent exception on invalid range read

Previously S3, Swift, and local blobstores threw a generic
IllegalArgumentException for this uncommon error.  Instead
consistently throw HttpResponseException.
This commit is contained in:
Andrew Gaul 2017-11-10 21:37:25 -08:00
parent c468c60d51
commit 8b94febfeb
3 changed files with 2 additions and 10 deletions

View File

@ -77,9 +77,6 @@ public class CloudFilesErrorHandler implements HttpErrorHandler {
case 413:
exception = new InsufficientResourcesException(exception.getMessage(), exception);
break;
case 416:
exception = new IllegalArgumentException(exception.getMessage(), exception);
break;
}
command.setException(exception);
}

View File

@ -133,11 +133,6 @@ public class ParseAWSErrorFromXmlContent implements HttpErrorHandler {
exception = new IllegalStateException(message, exception);
}
break;
case 416:
if ("InvalidRange".equals(errorCode)) {
exception = new IllegalArgumentException(message, exception);
}
break;
}
return exception;
}

View File

@ -704,11 +704,11 @@ public final class LocalBlobStore implements BlobStore {
offset = Long.parseLong(firstLast[0]);
last = Long.parseLong(firstLast[1]);
} else {
throw new IllegalArgumentException("illegal range: " + s);
throw new HttpResponseException("illegal range: " + s, null, null);
}
if (offset >= blob.getPayload().getContentMetadata().getContentLength()) {
throw new IllegalArgumentException("illegal range: " + s);
throw new HttpResponseException("illegal range: " + s, null, null);
}
if (last + 1 > blob.getPayload().getContentMetadata().getContentLength()) {
last = blob.getPayload().getContentMetadata().getContentLength() - 1;