[JCLOUDS-1200] Mark nonserializable fields in HttpResponseException and subtypes as transient.

This commit is contained in:
Jesse Glick 2018-05-18 18:46:24 -04:00 committed by Andrew Gaul
parent 1f6ec343c0
commit 65a5ec8164
7 changed files with 21 additions and 8 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<ErrorResponse> errors;
private transient Set<ErrorResponse> errors;
public GoGridResponseException(HttpCommand command, HttpResponse response, Set<ErrorResponse> errors) {
super(buildMessage(command, response, errors), command, response);
this.setErrors(errors);
}
@Nullable
public Set<ErrorResponse> getError() {
return errors;
}

View File

@ -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;
}