diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index b037a16c8f273..4f6f4a182902e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -179,7 +179,7 @@ private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { private GetBlobPropertiesResult getBlobPropertiesResultFromResponse(ClientResponse response) { // Properties BlobProperties properties = new BlobProperties(); - properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); properties.setBlobType(response.getHeaders().getFirst("x-ms-blob-type")); properties.setLeaseStatus(response.getHeaders().getFirst("x-ms-lease-status")); @@ -323,7 +323,7 @@ private GetContainerPropertiesResult getContainerPropertiesImpl(String container GetContainerPropertiesResult properties = new GetContainerPropertiesResult(); properties.setEtag(response.getHeaders().getFirst("ETag")); - properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); properties.setMetadata(getMetadataFromHeaders(response)); return properties; @@ -347,7 +347,7 @@ public GetContainerACLResult getContainerACL(String container, BlobServiceOption acl.setSignedIdentifiers(si.getSignedIdentifiers()); acl.setPublicAccess(response.getHeaders().getFirst("x-ms-blob-public-access")); acl.setEtag(response.getHeaders().getFirst("ETag")); - acl.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + acl.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); GetContainerACLResult result = new GetContainerACLResult(); result.setValue(acl); @@ -493,7 +493,7 @@ public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetB GetBlobMetadataResult properties = new GetBlobMetadataResult(); properties.setEtag(response.getHeaders().getFirst("ETag")); - properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); properties.setMetadata(getMetadataFromHeaders(response)); return properties; @@ -525,7 +525,7 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesResult result = new SetBlobPropertiesResult(); result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); if (response.getHeaders().getFirst("x-ms-blob-sequence-number") != null) { result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); } @@ -552,7 +552,7 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash SetBlobMetadataResult result = new SetBlobMetadataResult(); result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); return result; } @@ -616,7 +616,7 @@ public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob CreateBlobSnapshotResult blobSnapshot = new CreateBlobSnapshotResult(); blobSnapshot.setEtag(response.getHeaders().getFirst("ETag")); blobSnapshot.setSnapshot(response.getHeaders().getFirst("x-ms-snapshot")); - blobSnapshot.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + blobSnapshot.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); return blobSnapshot; } @@ -733,7 +733,7 @@ private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String cont CreateBlobPagesResult result = new CreateBlobPagesResult(); result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); result.setContentMD5(response.getHeaders().getFirst("Content-MD5")); result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); @@ -759,7 +759,7 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob, List ListBlobRegionsResult result = response.getEntity(ListBlobRegionsResult.class); result.setEtag(response.getHeaders().getFirst("ETag")); result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); return result; } @@ -822,7 +822,7 @@ public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBl result.setEtag(response.getHeaders().getFirst("ETag")); result.setContentType(response.getHeaders().getFirst("Content-Type")); result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); return result; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateConverter.java index 48545adfcb5bc..f8dc6fc29c31c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateConverter.java @@ -17,16 +17,13 @@ public String format(Date date) { return getFormat().format(date); } - public Date parse(String date) throws ParseException { - return getFormat().parse(date); - } - - public Date parseNoThrow(String date) { + public Date parse(String date) { try { - return parse(date); + return getFormat().parse(date); } catch (ParseException e) { - return null; + String msg = String.format("The value \"%s\" is not a valid RFC 1123 date.", date); + throw new IllegalArgumentException(msg, e); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index 168f6944cfbbc..76c004da179d7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java @@ -249,7 +249,7 @@ public UpdateMessageResult updateMessage(String queue, String messageId, String UpdateMessageResult result = new UpdateMessageResult(); result.setPopReceipt(response.getHeaders().getFirst("x-ms-popreceipt")); - result.setTimeNextVisible(dateMapper.parseNoThrow(response.getHeaders().getFirst("x-ms-time-next-visible"))); + result.setTimeNextVisible(dateMapper.parse(response.getHeaders().getFirst("x-ms-time-next-visible"))); return result; }