
org.cloudfoundry.gradle.tasks.WarningBypassingResponseErrorHandler.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cf-gradle-plugin Show documentation
Show all versions of cf-gradle-plugin Show documentation
A Gradle plugin that makes it easy to deploy Gradle-based applications to Cloud Foundry instances.
The newest version!
package org.cloudfoundry.gradle.tasks
import org.cloudfoundry.client.lib.CloudFoundryException
import org.cloudfoundry.client.lib.rest.CloudControllerResponseErrorHandler
import org.springframework.http.HttpStatus
/**
* This class is used to override the default error handling for REST responses in RestTemplate. The main
* goal is to keep RestTemplate from logging warnings for expected HTTP "errors".
*/
class WarningBypassingResponseErrorHandler extends CloudControllerResponseErrorHandler {
private List expectedStatusCodes = []
public void addExpectedStatus(HttpStatus status) {
expectedStatusCodes << status
}
public void clearExpectedStatus() {
expectedStatusCodes.clear()
}
@Override
protected boolean hasError(HttpStatus statusCode) {
if (expectedStatusCodes.contains(statusCode)) {
throw new CloudFoundryException(statusCode)
}
return super.hasError(statusCode)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy