Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,20 @@ protected Consumer<CloudAsyncJob> getOnCompleteHandler(ProcessContext context) {
@Override
protected Consumer<CloudAsyncJob> getOnErrorHandler(ProcessContext context) {
CloudApplication app = context.getVariable(Variables.APP_TO_PROCESS);
String serviceInstanceName = context.getVariable(Variables.SERVICE_TO_UNBIND_BIND);

CloudControllerClient client = context.getControllerClient();
CloudServiceInstance serviceInstance = client.getServiceInstance(serviceInstanceName, false);
String serviceInstanceName = resolveServiceInstanceName(context);
CloudServiceInstance serviceInstance = serviceInstanceName != null ? client.getServiceInstance(serviceInstanceName, false) : null;

return serviceBindingJob -> context.getStepLogger()
.error(buildErrorMessage(app, serviceInstance, serviceInstanceName, serviceBindingJob));
}

private String resolveServiceInstanceName(ProcessContext context) {
String serviceInstanceName = context.getVariable(Variables.SERVICE_TO_UNBIND_BIND);
if (serviceInstanceName == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract into a new method whole logic related with getting service instance name and avoid setting finalServiceInstanceName because it is little bit confusing to have 2 variables for the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! Done!

return context.getVariable(Variables.SERVICE_TO_DELETE);
}
return serviceInstanceName;
}

private String buildErrorMessage(CloudApplication app, CloudServiceInstance serviceInstance, String serviceInstanceName,
Expand Down
Loading