Browse files

fix the failed java unit test related to getBlob.

  • Loading branch information...
1 parent fab505c commit 564d8aa92e6835c633dd26d3c459ebbc23f87060 unknown committed Apr 5, 2012
View
22 .../src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java
@@ -2,15 +2,15 @@
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.microsoft.windowsazure.services.blob.implementation;
@@ -122,6 +122,10 @@ private void ThrowIfError(ClientResponse r) {
PipelineHelpers.ThrowIfError(r);
}
+ private void ThrowIfNotSuccess(ClientResponse clientResponse) {
+ PipelineHelpers.ThrowIfNotSuccess(clientResponse);
+ }
+
private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) {
return PipelineHelpers.addOptionalQueryParam(webResource, key, value);
}
@@ -630,7 +634,7 @@ public GetBlobResult getBlob(String container, String blob, GetBlobOptions optio
builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition());
ClientResponse response = builder.get(ClientResponse.class);
- ThrowIfError(response);
+ ThrowIfNotSuccess(response);
GetBlobPropertiesResult properties = getBlobPropertiesResultFromResponse(response);
GetBlobResult blobResult = new GetBlobResult();
View
14 ...rc/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java
@@ -27,9 +27,17 @@
import com.sun.jersey.api.client.WebResource.Builder;
public class PipelineHelpers {
- public static void ThrowIfError(ClientResponse r) {
- if (r.getStatus() >= 400) {
- throw new UniformInterfaceException(r);
+ public static void ThrowIfNotSuccess(ClientResponse clientResponse) {
+ int statusCode = clientResponse.getStatus();
+
+ if ((statusCode < 200) || (statusCode >= 300)) {
+ throw new UniformInterfaceException(clientResponse);
+ }
+ }
+
+ public static void ThrowIfError(ClientResponse clientResponse) {
+ if (clientResponse.getStatus() >= 400) {
+ throw new UniformInterfaceException(clientResponse);
}
}

0 comments on commit 564d8aa

Please sign in to comment.