Skip to content

Commit

Permalink
Upgrade to Spring Boot 3.1.3
Browse files Browse the repository at this point in the history
transient fields annotated with @JsonIgnore were breaking with Jackson 2.15.
Moving these annotations to the accessors resolves this. For consistency,
all Jackson annotations on the model objects were moved to the accessors.

The Spring Security example still needs to be updated, it now uses
deprecated method calls.
  • Loading branch information
royclarkson committed Sep 18, 2023
1 parent 9e9228f commit 39c34bc
Show file tree
Hide file tree
Showing 27 changed files with 76 additions and 62 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
buildscript {
ext {
// Spring Dependencies
springBootVersion = "3.0.10"
springBootVersion = "3.1.3"

// External Dependencies
beanUtilsVersion = "1.9.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public abstract class AsyncServiceBrokerRequest extends ServiceBrokerRequest {
*/
public final static String ASYNC_REQUEST_PARAMETER = "accepts_incomplete";

@JsonIgnore //accepts_incomplete Osb field passed as query param in most subclasses
protected transient boolean asyncAccepted;

/**
Expand Down Expand Up @@ -70,6 +69,7 @@ protected AsyncServiceBrokerRequest(boolean asyncAccepted, String platformInstan
*
* @return the boolean value
*/
@JsonIgnore //accepts_incomplete Osb field passed as query param in most subclasses
public boolean isAsyncAccepted() {
return this.asyncAccepted;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ public class AsyncServiceBrokerResponse {

private static final int MAX_OPERATION_LENGTH = 10_000;

@JsonIgnore //not sent on the wire as json payload, but as http status instead
protected final boolean async;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
protected final String operation;

/**
Expand All @@ -59,6 +57,7 @@ protected AsyncServiceBrokerResponse(boolean async, String operation) {
*
* @return the boolean value
*/
@JsonIgnore //not sent on the wire as json payload, but as http status instead
public boolean isAsync() {
return this.async;
}
Expand All @@ -68,6 +67,7 @@ public boolean isAsync() {
*
* @return the operation description
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public String getOperation() {
return this.operation;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public class Context {

protected final String platform;

@JsonAnySetter
protected final Map<String, Object> properties = new HashMap<>();

/**
Expand Down Expand Up @@ -93,6 +92,17 @@ public Map<String, Object> getProperties() {
return this.properties;
}

/**
* Set a property in the context.
*
* @param key the key of the property
* @param value the value of the property
*/
@JsonAnySetter
public void setProperties(String key, Object value) {
this.properties.put(key, value);
}

/**
* Get the value of a property in the context with the given key.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,12 @@ public class ServiceBrokerRequest {
*/
public static final String PLATFORM_INSTANCE_ID_VARIABLE = "platformInstanceId";

@JsonIgnore //relative path to Osb query path, not to include in Json body
protected transient String platformInstanceId;

@JsonIgnore //mapped as X-Api-Info-Location Header
protected transient String apiInfoLocation;

@JsonIgnore //mapped as X-Broker-API-Originating-Identity Header
protected transient Context originatingIdentity;

@JsonIgnore //mapped as X-Broker-API-Request-Identity Header
protected transient String requestIdentity;

/**
Expand Down Expand Up @@ -116,6 +112,7 @@ protected ServiceBrokerRequest(String platformInstanceId, String apiInfoLocation
*
* @return the platform instance ID, or {@literal null} if not provided
*/
@JsonIgnore //relative path to Osb query path, not to include in Json body
public String getPlatformInstanceId() {
return this.platformInstanceId;
}
Expand All @@ -140,6 +137,7 @@ public void setPlatformInstanceId(String platformInstanceId) {
*
* @return the API info endpoint location, or {@literal null} if not provided
*/
@JsonIgnore //mapped as X-Api-Info-Location Header
public String getApiInfoLocation() {
return this.apiInfoLocation;
}
Expand All @@ -161,6 +159,7 @@ public void setApiInfoLocation(String apiInfoLocation) {
*
* @return the user identity, or {@literal null} if not provided
*/
@JsonIgnore //mapped as X-Broker-API-Originating-Identity Header
public Context getOriginatingIdentity() {
return this.originatingIdentity;
}
Expand All @@ -182,6 +181,7 @@ public void setOriginatingIdentity(Context originatingIdentity) {
*
* @return the request identity, or {@literal null} if not provided
*/
@JsonIgnore //mapped as X-Broker-API-Request-Identity Header
public String getRequestIdentity() {
return this.requestIdentity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
*/
public class BindingMetadata {

@JsonProperty("expires_at")
private final String expiresAt;

/**
Expand All @@ -55,6 +54,7 @@ public BindingMetadata(String expiresAt) {
*
* @return the date and time in ISO 8601 format
*/
@JsonProperty("expires_at")
public String getExpiresAt() {
return expiresAt;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,11 @@
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CreateServiceInstanceBindingRequest extends AsyncParameterizedServiceInstanceRequest {

@JsonIgnore //OSB field passed as path param
private transient String serviceInstanceId;

@JsonIgnore //OSB field passed as path param
private transient String bindingId;

@NotEmpty
@JsonProperty("service_id")
private final String serviceDefinitionId;

@NotEmpty
Expand All @@ -66,10 +63,8 @@ public class CreateServiceInstanceBindingRequest extends AsyncParameterizedServi

private final BindResource bindResource;

@JsonIgnore //internal field
private transient ServiceDefinition serviceDefinition;

@JsonIgnore //internal field
private transient Plan plan;

/**
Expand Down Expand Up @@ -126,6 +121,7 @@ public CreateServiceInstanceBindingRequest(String serviceInstanceId, String serv
*
* @return the service instance ID
*/
@JsonIgnore //OSB field passed as path param
public String getServiceInstanceId() {
return this.serviceInstanceId;
}
Expand All @@ -149,6 +145,7 @@ public void setServiceInstanceId(final String serviceInstanceId) {
*
* @return the service instance ID
*/
@JsonIgnore //OSB field passed as path param
public String getBindingId() {
return this.bindingId;
}
Expand All @@ -172,6 +169,7 @@ public void setBindingId(final String bindingId) {
*
* @return the service definition ID
*/
@JsonProperty("service_id")
public String getServiceDefinitionId() {
return this.serviceDefinitionId;
}
Expand Down Expand Up @@ -226,6 +224,7 @@ public BindResource getBindResource() {
*
* @return the service definition
*/
@JsonIgnore //internal field
public ServiceDefinition getServiceDefinition() {
return this.serviceDefinition;
}
Expand All @@ -249,6 +248,7 @@ public void setServiceDefinition(final ServiceDefinition serviceDefinition) {
*
* @return the plan
*/
@JsonIgnore //internal field
public Plan getPlan() {
return this.plan;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class CreateServiceInstanceBindingResponse extends AsyncServiceBrokerResponse {

@JsonIgnore
protected final boolean bindingExisted;

@JsonInclude(JsonInclude.Include.NON_NULL)
private final BindingMetadata metadata;

/**
Expand All @@ -67,6 +65,7 @@ protected CreateServiceInstanceBindingResponse(boolean async, String operation,
*
* @return the boolean value
*/
@JsonIgnore
public boolean isBindingExisted() {
return this.bindingExisted;
}
Expand All @@ -76,6 +75,7 @@ public boolean isBindingExisted() {
*
* @return the metadata
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public BindingMetadata getMetadata() {
return this.metadata;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,16 @@
*/
public class DeleteServiceInstanceBindingRequest extends AsyncServiceBrokerRequest {

@JsonIgnore // mapped as path param
private transient final String serviceInstanceId;

@JsonIgnore // mapped as path param
private transient final String bindingId;

@JsonProperty("service_id")
private transient final String serviceDefinitionId;

@JsonProperty("plan_id")
private transient final String planId;

@JsonIgnore /*internal field*/
private transient final ServiceDefinition serviceDefinition;

@JsonIgnore /*internal field*/
private transient final Plan plan;

/**
Expand Down Expand Up @@ -87,6 +81,7 @@ public DeleteServiceInstanceBindingRequest(String serviceInstanceId, String serv
}

@JsonProperty(ASYNC_REQUEST_PARAMETER)
@JsonIgnore(false)
//in base class field is excluded, as other requests are passing this as query params
@Override
public boolean isAsyncAccepted() {
Expand All @@ -101,6 +96,7 @@ public boolean isAsyncAccepted() {
*
* @return the service instance ID
*/
@JsonIgnore // mapped as path param
public String getServiceInstanceId() {
return this.serviceInstanceId;
}
Expand All @@ -113,6 +109,7 @@ public String getServiceInstanceId() {
*
* @return the service instance ID
*/
@JsonIgnore // mapped as path param
public String getBindingId() {
return this.bindingId;
}
Expand All @@ -126,6 +123,7 @@ public String getBindingId() {
*
* @return the service definition ID
*/
@JsonProperty("service_id")
public String getServiceDefinitionId() {
return this.serviceDefinitionId;
}
Expand All @@ -140,6 +138,7 @@ public String getServiceDefinitionId() {
*
* @return the plan ID
*/
@JsonProperty("plan_id")
public String getPlanId() {
return this.planId;
}
Expand All @@ -153,6 +152,7 @@ public String getPlanId() {
*
* @return the service definition
*/
@JsonIgnore /*internal field*/
public ServiceDefinition getServiceDefinition() {
return this.serviceDefinition;
}
Expand All @@ -166,6 +166,7 @@ public ServiceDefinition getServiceDefinition() {
*
* @return the plan
*/
@JsonIgnore /*internal field*/
public Plan getPlan() {
return this.plan;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class GetLastServiceBindingOperationResponse {

private final String description;

@JsonIgnore
private final boolean deleteOperation;

/**
Expand Down Expand Up @@ -90,6 +89,7 @@ public String getDescription() {
*
* @return the boolean value
*/
@JsonIgnore
public boolean isDeleteOperation() {
return this.deleteOperation;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class GetServiceInstanceBindingResponse {

private final Map<String, Object> parameters;

@JsonInclude(JsonInclude.Include.NON_NULL)
private final BindingMetadata metadata;

/**
Expand All @@ -64,6 +63,7 @@ public Map<String, Object> getParameters() {
*
* @return the metadata
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public BindingMetadata getMetadata() {
return this.metadata;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,10 @@ public String toString() {

private final String containerDir;

@JsonSerialize(using = ToStringSerializer.class)
@JsonDeserialize(using = ModeDeserializer.class)
private final Mode mode;

@JsonSerialize(using = ToStringSerializer.class)
@JsonDeserialize(using = DeviceTypeDeserializer.class)
private final DeviceType deviceType;

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "device_type")
@JsonSubTypes({@JsonSubTypes.Type(value = SharedVolumeDevice.class, name = "shared")})
private final VolumeDevice device;

/**
Expand Down Expand Up @@ -156,6 +150,8 @@ public String getContainerDir() {
*
* @return the volume read/write mode
*/
@JsonSerialize(using = ToStringSerializer.class)
@JsonDeserialize(using = ModeDeserializer.class)
public Mode getMode() {
return this.mode;
}
Expand All @@ -165,6 +161,8 @@ public Mode getMode() {
*
* @return the volume device type
*/
@JsonSerialize(using = ToStringSerializer.class)
@JsonDeserialize(using = DeviceTypeDeserializer.class)
public DeviceType getDeviceType() {
return this.deviceType;
}
Expand All @@ -174,6 +172,8 @@ public DeviceType getDeviceType() {
*
* @return the volume device details
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "device_type")
@JsonSubTypes({@JsonSubTypes.Type(value = SharedVolumeDevice.class, name = "shared")})
public VolumeDevice getDevice() {
return this.device;
}
Expand Down
Loading

0 comments on commit 39c34bc

Please sign in to comment.