Commit cf119682 authored by Sanjeev-SLB's avatar Sanjeev-SLB
Browse files

Merge branch 'broken-pipe-fix' into 'master'

Broken pipe IOException handler

See merge request !125
parents 2f877c80 875b4385
Pipeline #71030 failed with stages
in 34 minutes and 24 seconds
......@@ -595,7 +595,7 @@ The following software have components provided under the terms of this license:
- Java Servlet API (from https://projects.eclipse.org/projects/ee4j.servlet)
- Java(TM) API for WebSocket (from https://repo1.maven.org/maven2/org/jboss/spec/javax/websocket/jboss-websocket-api_1.1_spec)
- Old JAXB Core (from https://eclipse-ee4j.github.io/jaxb-ri/)
- Project Lombok (from http://projectlombok.org)
- Project Lombok (from https://projectlombok.org)
========================================================================
ImageMagick
......@@ -691,7 +691,7 @@ The following software have components provided under the terms of this license:
- Netty/Codec/HTTP (from https://repo1.maven.org/maven2/io/netty/netty-codec-http)
- Netty/Common (from https://repo1.maven.org/maven2/io/netty/netty-common)
- Netty/Common (from https://repo1.maven.org/maven2/io/netty/netty-common)
- Project Lombok (from http://projectlombok.org)
- Project Lombok (from https://projectlombok.org)
- SLF4J API Module (from http://www.slf4j.org)
- Spongy Castle (from http://rtyley.github.io/spongycastle/)
- Spring Data for Azure Cosmos DB SQL API (from https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/cosmos/azure-spring-data-cosmos)
......@@ -784,7 +784,7 @@ The following software have components provided under the terms of this license:
- Microsoft Azure SDK for EventGrid Management (from https://github.com/Azure/azure-sdk-for-java)
- Microsoft Azure SDK for SQL API of Azure Cosmos DB Service (from https://github.com/Azure/azure-sdk-for-java)
- Microsoft Azure client library for Blob Storage (from https://github.com/Azure/azure-sdk-for-java)
- Project Lombok (from http://projectlombok.org)
- Project Lombok (from https://projectlombok.org)
- Spring Web (from https://github.com/spring-projects/spring-framework)
- azure-documentdb (from https://azure.microsoft.com/en-us/services/cosmos-db/)
- msal4j (from https://github.com/AzureAD/microsoft-authentication-library-for-java)
......@@ -806,3 +806,5 @@ The following software have components provided under the terms of this license:
- JUnit Platform Commons (from https://junit.org/junit5/)
- JUnit Platform Engine API (from https://junit.org/junit5/)
- Spongy Castle (from http://rtyley.github.io/spongycastle/)
......@@ -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