From 65a5ec8164f5a75f63b1d853a742f358e0ae040b Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Fri, 18 May 2018 18:46:24 -0400 Subject: [PATCH] [JCLOUDS-1200] Mark nonserializable fields in HttpResponseException and subtypes as transient. --- .../main/java/org/jclouds/atmos/AtmosResponseException.java | 4 +++- .../src/main/java/org/jclouds/aws/AWSResponseException.java | 4 +++- .../main/java/org/jclouds/http/HttpResponseException.java | 5 +++-- .../jclouds/azure/storage/AzureStorageResponseException.java | 4 +++- .../b2/src/main/java/org/jclouds/b2/B2ResponseException.java | 4 +++- .../java/org/jclouds/gogrid/GoGridResponseException.java | 4 +++- .../org/jclouds/ultradns/ws/UltraDNSWSResponseException.java | 4 +++- 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosResponseException.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosResponseException.java index 10cc99abdd..10f3705013 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosResponseException.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosResponseException.java @@ -20,6 +20,7 @@ import org.jclouds.atmos.domain.AtmosError; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponseException; +import org.jclouds.javax.annotation.Nullable; /** * Encapsulates an Error from Atmos Storage Services. @@ -29,7 +30,7 @@ import org.jclouds.http.HttpResponseException; */ public class AtmosResponseException extends HttpResponseException { - private AtmosError error; + private transient AtmosError error; public AtmosResponseException(HttpCommand command, HttpResponse response, AtmosError error) { @@ -65,6 +66,7 @@ public class AtmosResponseException extends HttpResponseException { this.error = error; } + @Nullable public AtmosError getError() { return error; } diff --git a/apis/sts/src/main/java/org/jclouds/aws/AWSResponseException.java b/apis/sts/src/main/java/org/jclouds/aws/AWSResponseException.java index b8cfafb377..5d180be67d 100644 --- a/apis/sts/src/main/java/org/jclouds/aws/AWSResponseException.java +++ b/apis/sts/src/main/java/org/jclouds/aws/AWSResponseException.java @@ -20,6 +20,7 @@ import org.jclouds.aws.domain.AWSError; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponseException; +import org.jclouds.javax.annotation.Nullable; /** * Encapsulates an AWS Error from Amazon. @@ -30,7 +31,7 @@ import org.jclouds.http.HttpResponseException; */ public class AWSResponseException extends HttpResponseException { - private AWSError error = new AWSError(); + private transient AWSError error = new AWSError(); public AWSResponseException(HttpCommand command, HttpResponse response, AWSError error) { super(String.format("request %s failed with code %s, error: %s", command.getCurrentRequest().getRequestLine(), response @@ -65,6 +66,7 @@ public class AWSResponseException extends HttpResponseException { this.error = error; } + @Nullable public AWSError getError() { return error; } diff --git a/core/src/main/java/org/jclouds/http/HttpResponseException.java b/core/src/main/java/org/jclouds/http/HttpResponseException.java index 2da5c913bd..5ea4500cc0 100644 --- a/core/src/main/java/org/jclouds/http/HttpResponseException.java +++ b/core/src/main/java/org/jclouds/http/HttpResponseException.java @@ -31,8 +31,8 @@ public class HttpResponseException extends RuntimeException { private static final long serialVersionUID = 1L; - protected final HttpCommand command; - protected final HttpResponse response; + protected final transient HttpCommand command; + protected final transient HttpResponse response; private String content; public HttpResponseException(String message, HttpCommand command, @Nullable HttpResponse response, Throwable cause) { @@ -112,6 +112,7 @@ public class HttpResponseException extends RuntimeException { .getRequestLine(), response.getStatusLine(), content), command, response, content); } + @Nullable public HttpCommand getCommand() { return command; } diff --git a/providers/azureblob/src/main/java/org/jclouds/azure/storage/AzureStorageResponseException.java b/providers/azureblob/src/main/java/org/jclouds/azure/storage/AzureStorageResponseException.java index 744de08f45..36e2057b5b 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azure/storage/AzureStorageResponseException.java +++ b/providers/azureblob/src/main/java/org/jclouds/azure/storage/AzureStorageResponseException.java @@ -20,6 +20,7 @@ import org.jclouds.azure.storage.domain.AzureStorageError; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponseException; +import org.jclouds.javax.annotation.Nullable; /** * Encapsulates an Error from Azure Storage Services. @@ -30,7 +31,7 @@ import org.jclouds.http.HttpResponseException; */ public class AzureStorageResponseException extends HttpResponseException { - private AzureStorageError error = new AzureStorageError(); + private transient AzureStorageError error = new AzureStorageError(); public AzureStorageResponseException(HttpCommand command, HttpResponse response, AzureStorageError error) { super(String.format("command %s failed with code %s, error: %s", command.toString(), response @@ -65,6 +66,7 @@ public class AzureStorageResponseException extends HttpResponseException { this.error = error; } + @Nullable public AzureStorageError getError() { return error; } diff --git a/providers/b2/src/main/java/org/jclouds/b2/B2ResponseException.java b/providers/b2/src/main/java/org/jclouds/b2/B2ResponseException.java index 3e89359854..7cca74c8a6 100644 --- a/providers/b2/src/main/java/org/jclouds/b2/B2ResponseException.java +++ b/providers/b2/src/main/java/org/jclouds/b2/B2ResponseException.java @@ -22,9 +22,10 @@ import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponseException; import com.google.common.base.Preconditions; +import org.jclouds.javax.annotation.Nullable; public final class B2ResponseException extends HttpResponseException { - private final B2Error error; + private final transient B2Error error; public B2ResponseException(HttpCommand command, HttpResponse response, B2Error error) { super("request " + command.getCurrentRequest().getRequestLine() + " failed with code " + response.getStatusCode() @@ -32,6 +33,7 @@ public final class B2ResponseException extends HttpResponseException { this.error = error; } + @Nullable public B2Error getError() { return error; } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridResponseException.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridResponseException.java index f5b260274f..36c619ecae 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridResponseException.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridResponseException.java @@ -24,16 +24,18 @@ import org.jclouds.gogrid.domain.internal.ErrorResponse; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponseException; +import org.jclouds.javax.annotation.Nullable; public class GoGridResponseException extends HttpResponseException { - private Set errors; + private transient Set errors; public GoGridResponseException(HttpCommand command, HttpResponse response, Set errors) { super(buildMessage(command, response, errors), command, response); this.setErrors(errors); } + @Nullable public Set getError() { return errors; } diff --git a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/UltraDNSWSResponseException.java b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/UltraDNSWSResponseException.java index f1fa46911c..9b1608c536 100644 --- a/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/UltraDNSWSResponseException.java +++ b/providers/ultradns-ws/src/main/java/org/jclouds/ultradns/ws/UltraDNSWSResponseException.java @@ -19,6 +19,7 @@ package org.jclouds.ultradns.ws; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponseException; +import org.jclouds.javax.annotation.Nullable; /** * @see UltraDNSWSError @@ -27,13 +28,14 @@ public class UltraDNSWSResponseException extends HttpResponseException { private static final long serialVersionUID = 5493782874839736777L; - private final UltraDNSWSError error; + private final transient UltraDNSWSError error; public UltraDNSWSResponseException(HttpCommand command, HttpResponse response, UltraDNSWSError error) { super(error.toString(), command, response); this.error = error; } + @Nullable public UltraDNSWSError getError() { return error; }