Commit 1e68c930 authored by Sanjeev-SLB's avatar Sanjeev-SLB
Browse files

Broken pipe IOException handler

parent a7d0430d
Pipeline #70112 failed with stages
in 36 minutes and 9 seconds
......@@ -18,6 +18,8 @@ package org.opengroup.osdu.notification.errors;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
......@@ -32,6 +34,7 @@ import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import org.opengroup.osdu.core.common.model.http.AppException;
import javax.validation.ValidationException;
import java.io.IOException;
import java.nio.file.AccessDeniedException;
import java.util.List;
import java.util.stream.Collectors;
......@@ -78,6 +81,17 @@ public class SpringExceptionMapper extends ResponseEntityExceptionHandler {
"An unknown error has occurred.", e));
}
@ExceptionHandler(IOException.class)
public ResponseEntity<Object> handleIOException(IOException e) {
if (StringUtils.containsIgnoreCase(ExceptionUtils.getRootCauseMessage(e), "Broken pipe")) {
this.log.warning("Client closed the connection while request still being processed");
return null;
} else {
return this.getErrorResponse(
new AppException(HttpStatus.SERVICE_UNAVAILABLE.value(), "Unknown error", e.getMessage(), e));
}
}
private ResponseEntity<Object> getErrorResponse(AppException e) {
if(e.getOriginalException()!= null) {
this.log.error(e.getOriginalException().getMessage(), e.getOriginalException());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment