diff --git a/src/main/java/org/gaul/s3proxy/S3ErrorCode.java b/src/main/java/org/gaul/s3proxy/S3ErrorCode.java index d5639b5..1d8343e 100644 --- a/src/main/java/org/gaul/s3proxy/S3ErrorCode.java +++ b/src/main/java/org/gaul/s3proxy/S3ErrorCode.java @@ -49,6 +49,10 @@ enum S3ErrorCode { "The specified location constraint is not valid. For" + " more information about Regions, see How to Select" + " a Region for Your Buckets."), + INVALID_PART(HttpServletResponse.SC_BAD_REQUEST, + "One or more of the specified parts could not be found." + + " The part may not have been uploaded, or the specified entity" + + " tag may not match the part's entity tag."), INVALID_REQUEST(HttpServletResponse.SC_BAD_REQUEST, "Bad Request"), MALFORMED_X_M_L(HttpServletResponse.SC_BAD_REQUEST, "The XML you provided was not well-formed or did not validate" + diff --git a/src/main/java/org/gaul/s3proxy/S3ProxyHandler.java b/src/main/java/org/gaul/s3proxy/S3ProxyHandler.java index af5268e..11deb53 100644 --- a/src/main/java/org/gaul/s3proxy/S3ProxyHandler.java +++ b/src/main/java/org/gaul/s3proxy/S3ProxyHandler.java @@ -1239,7 +1239,11 @@ final class S3ProxyHandler extends AbstractHandler { parseCompleteMultipartUpload(is).entrySet().iterator(); it.hasNext();) { Map.Entry entry = it.next(); - long partSize = partsByListing.get(entry.getKey()).partSize(); + MultipartPart part = partsByListing.get(entry.getKey()); + if (part == null) { + throw new S3Exception(S3ErrorCode.INVALID_PART); + } + long partSize = part.partSize(); if (partSize < blobStore.getMinimumMultipartPartSize() && partSize != -1 && it.hasNext()) { throw new S3Exception(S3ErrorCode.ENTITY_TOO_SMALL);