Skip to content

Commit

Permalink
fix(exceptionhandler): Remove exception handler from the controller s…
Browse files Browse the repository at this point in the history
…ince we have a generic handler in Kork (#1018)
  • Loading branch information
srekapalli authored and mergify[bot] committed Jan 27, 2020
1 parent 5bd7ac7 commit beae312
Showing 1 changed file with 0 additions and 25 deletions.
@@ -1,6 +1,5 @@
package com.netflix.spinnaker.gate.controllers;

import static org.springframework.http.HttpHeaders.CONTENT_TYPE;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

import com.netflix.spinnaker.gate.model.manageddelivery.ConstraintState;
Expand All @@ -15,8 +14,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -26,16 +23,13 @@
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import retrofit.RetrofitError;
import retrofit.client.Header;

@RequestMapping("/managed")
@RestController
Expand Down Expand Up @@ -177,23 +171,4 @@ void pauseApplication(@PathVariable("application") String application) {
void resumeApplication(@PathVariable("application") String application) {
keelService.resumeApplication(application);
}

@ExceptionHandler
void passthroughRetrofitErrors(RetrofitError e, HttpServletResponse response) {
try {
response.setStatus(e.getResponse().getStatus());
response.setHeader(
CONTENT_TYPE,
e.getResponse().getHeaders().stream()
.filter(it -> it.getName().equals(CONTENT_TYPE))
.map(Header::getValue)
.findFirst()
.orElse("text/plain"));
IOUtils.copy(e.getResponse().getBody().in(), response.getOutputStream());
} catch (Exception ex) {
log.error(
"Error reading response body when translating exception from downstream keelService: ",
ex);
}
}
}

0 comments on commit beae312

Please sign in to comment.