Skip to content

Commit

Permalink
fix(resilience4j): Circuit breaker ignores 404s from Jenkins (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
robzienert authored Jun 10, 2020
1 parent e82e97b commit a92fc6b
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import com.netflix.spinnaker.kork.exceptions.SpinnakerException;
import com.netflix.spinnaker.kork.web.exceptions.NotFoundException;
import io.github.resilience4j.circuitbreaker.CircuitBreaker;
import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig;
import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry;
import java.io.InputStream;
import java.time.Duration;
Expand Down Expand Up @@ -83,7 +84,20 @@ public JenkinsService(
this.jenkinsClient = jenkinsClient;
this.csrf = csrf;
this.permissions = permissions;
this.circuitBreaker = circuitBreakerRegistry.circuitBreaker("jenkins-" + jenkinsHostId);
this.circuitBreaker =
circuitBreakerRegistry.circuitBreaker(
"jenkins-" + jenkinsHostId,
CircuitBreakerConfig.custom()
.ignoreException(
(e) -> {
if (e instanceof RetrofitError) {
RetrofitError re = (RetrofitError) e;
return re.getKind() == RetrofitError.Kind.HTTP
&& re.getResponse().getStatus() == 404;
}
return false;
})
.build());
}

@Override
Expand Down

0 comments on commit a92fc6b

Please sign in to comment.