diff --git a/NOTICE b/NOTICE index c2e473d34d7a456f5ef30ff9d33121ee61c1e503..88fa3e78c613902d7f6f45c11f83be5b17a7ae86 100644 --- a/NOTICE +++ b/NOTICE @@ -290,7 +290,7 @@ The following software have components provided under the terms of this license: - Adapter: RxJava (from https://repo1.maven.org/maven2/com/squareup/retrofit2/adapter-rxjava) - Apache Ant + JUnit (from http://ant.apache.org/) - Apache Ant Core (from http://ant.apache.org/) -- Apache Ant Launcher (from https://ant.apache.org/) +- Apache Ant Launcher (from http://ant.apache.org/) - Apache Commons BeanUtils (from http://commons.apache.org/proper/commons-beanutils/) - Apache Commons CLI (from http://commons.apache.org/proper/commons-cli/) - Apache Commons Codec (from https://commons.apache.org/proper/commons-codec/) @@ -378,8 +378,8 @@ The following software have components provided under the terms of this license: - Gson (from https://repo1.maven.org/maven2/com/google/code/gson/gson) - Gson (from https://repo1.maven.org/maven2/com/google/code/gson/gson) - Guava InternalFutureFailureAccess and InternalFutures (from https://repo1.maven.org/maven2/com/google/guava/failureaccess) -- Guava: Google Core Libraries for Java (from https://github.com/google/guava) -- Guava: Google Core Libraries for Java (from https://github.com/google/guava) +- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) +- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) - HPPC Collections (from https://repo1.maven.org/maven2/com/carrotsearch/hppc) - HTTP functionality for the Reactor Netty library (from https://github.com/reactor/reactor-netty) - Hibernate Validator Engine (from https://repo1.maven.org/maven2/org/hibernate/validator/hibernate-validator) @@ -390,7 +390,7 @@ The following software have components provided under the terms of this license: - IBM COS Java SDK for COS KMS (from https://github.com/ibm/ibm-cos-sdk-java) - IBM COS SDK For Java (from https://github.com/ibm/ibm-cos-sdk-java) - IBM COS SDK for Java - Core (from https://github.com/ibm/ibm-cos-sdk-java) -- Identity and Access Management (IAM) API v1-rev284-1.25.0 (from https://repo1.maven.org/maven2/com/google/apis/google-api-services-iam) +- Identity and Access Management (IAM) API v1-rev20191010-1.30.3 (from https://repo1.maven.org/maven2/com/google/apis/google-api-services-iam) - J2ObjC Annotations (from https://github.com/google/j2objc/) - J2ObjC Annotations (from https://github.com/google/j2objc/) - JBoss Logging 3 (from http://www.jboss.org) @@ -402,7 +402,7 @@ The following software have components provided under the terms of this license: - JSON Web Token support for the JVM (from https://repo1.maven.org/maven2/io/jsonwebtoken/jjwt) - JSON library from Android SDK (from http://developer.android.com/sdk) - JSON.simple (from http://code.google.com/p/json-simple/) -- JSONassert (from https://github.com/skyscreamer/JSONassert) +- JSONassert (from http://github.com/skyscreamer/yoga) - JSR107 API and SPI (from https://github.com/jsr107/jsr107spec) - Jackson (from http://jackson.codehaus.org) - Jackson (from http://jackson.codehaus.org) @@ -418,8 +418,8 @@ The following software have components provided under the terms of this license: - Jackson datatype: jdk8 (from https://repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jdk8) - Jackson extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-jackson) - Jackson module: Afterburner (from https://github.com/FasterXML/jackson-modules-base) -- Jackson module: Old JAXB Annotations (javax.xml.bind) (from https://github.com/FasterXML/jackson-modules-base) -- Jackson module: Old JAXB Annotations (javax.xml.bind) (from https://github.com/FasterXML/jackson-modules-base) +- Jackson module: JAXB Annotations (from https://github.com/FasterXML/jackson-modules-base) +- Jackson module: JAXB Annotations (from https://github.com/FasterXML/jackson-modules-base) - Jackson-annotations (from http://github.com/FasterXML/jackson) - Jackson-annotations (from http://github.com/FasterXML/jackson) - Jackson-core (from https://github.com/FasterXML/jackson-core) @@ -454,8 +454,8 @@ The following software have components provided under the terms of this license: - Lucene Grouping (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-grouping) - Lucene Highlighter (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-highlighter) - Lucene Join (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-join) -- Lucene Memory (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-memory) - Lucene Memory (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-backward-codecs) +- Lucene Memory (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-memory) - Lucene Miscellaneous (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-misc) - Lucene Queries (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-queries) - Lucene QueryParsers (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-queryparser) @@ -468,7 +468,6 @@ The following software have components provided under the terms of this license: - Maven Artifact Manager (from https://repo1.maven.org/maven2/org/apache/maven/maven-artifact-manager) - Maven Core (from https://repo1.maven.org/maven2/org/apache/maven/maven-core) - Maven Error Diagnostics (from https://repo1.maven.org/maven2/org/apache/maven/maven-error-diagnostics) -- Maven Local Settings Model (from https://repo1.maven.org/maven2/org/apache/maven/maven-settings) - Maven Model (from https://repo1.maven.org/maven2/org/apache/maven/maven-model) - Maven Monitor (from https://repo1.maven.org/maven2/org/apache/maven/maven-monitor) - Maven Plugin API (from https://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api) @@ -479,6 +478,7 @@ The following software have components provided under the terms of this license: - Maven Project Builder (from https://repo1.maven.org/maven2/org/apache/maven/maven-project) - Maven Reporting API (from https://repo1.maven.org/maven2/org/apache/maven/reporting/maven-reporting-api) - Maven Repository Metadata Model (from https://repo1.maven.org/maven2/org/apache/maven/maven-repository-metadata) +- Maven Settings (from https://repo1.maven.org/maven2/org/apache/maven/maven-settings) - Maven Wagon API (from https://repo1.maven.org/maven2/org/apache/maven/wagon/wagon-provider-api) - Maven Wagon File Provider (from https://repo1.maven.org/maven2/org/apache/maven/wagon/wagon-file) - Maven Wagon HTTP Shared Library (from https://repo1.maven.org/maven2/org/apache/maven/wagon/wagon-http-shared) @@ -494,9 +494,6 @@ The following software have components provided under the terms of this license: - Microsoft Azure Netty HTTP Client Library (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) - Mockito (from http://www.mockito.org) -- Mockito (from http://www.mockito.org) -- Mockito (from http://www.mockito.org) -- Mockito (from http://www.mockito.org) - Mojo's Maven plugin for Cobertura (from http://mojo.codehaus.org/cobertura-maven-plugin/) - MongoDB Java Driver (from http://www.mongodb.org) - MongoDB Java Driver Core (from http://www.mongodb.org) @@ -538,8 +535,8 @@ The following software have components provided under the terms of this license: - OAuth2 for Spring Security (from https://repo1.maven.org/maven2/org/springframework/security/oauth/spring-security-oauth2) - OAuth2 for Spring Security (from https://repo1.maven.org/maven2/org/springframework/security/oauth/spring-security-oauth2) - Objenesis (from http://objenesis.org) -- OkHttp URLConnection (from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp-urlconnection) -- OkHttp URLConnection (from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp-urlconnection) +- Okio (from https://github.com/square/okio/) +- Okio (from https://github.com/square/okio/) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) @@ -567,16 +564,9 @@ The following software have components provided under the terms of this license: - Servlet Specification 2.5 API (from http://jetty.mortbay.org) - SnakeYAML (from http://www.snakeyaml.org) - Spatial4J (from http://www.locationtech.org/projects/locationtech.spatial4j) -- Spring AMQP Core (from https://github.com/spring-projects/spring-amqp) +- Spring AMQP Core (from https://projects.spring.io/spring-amqp) - Spring AOP (from https://github.com/spring-projects/spring-framework) - Spring Beans (from https://github.com/spring-projects/spring-framework) -- Spring Boot Dependencies (from https://projects.spring.io/spring-boot/#) -- Spring Boot Logging Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-logging) -- Spring Boot Reactor Netty Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-reactor-netty) -- Spring Boot Security Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-security) -- Spring Boot Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter) -- Spring Boot Web Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-web) -- Spring Boot WebFlux Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-webflux) - Spring Commons Logging Bridge (from https://github.com/spring-projects/spring-framework) - Spring Context (from https://github.com/spring-projects/spring-framework) - Spring Core (from https://github.com/spring-projects/spring-framework) @@ -588,7 +578,7 @@ The following software have components provided under the terms of this license: - Spring Messaging (from https://github.com/spring-projects/spring-framework) - Spring Plugin - Metadata Extension (from https://repo1.maven.org/maven2/org/springframework/plugin/spring-plugin-metadata) - Spring Plugin Core (from https://repo1.maven.org/maven2/org/springframework/plugin/spring-plugin-core) -- Spring RabbitMQ Support (from https://github.com/spring-projects/spring-amqp) +- Spring RabbitMQ Support (from https://projects.spring.io/spring-amqp) - Spring Retry (from https://www.springsource.org) - Spring Security JWT Library (from https://github.com/spring-projects/spring-security-oauth) - Spring Security JWT Library (from https://github.com/spring-projects/spring-security-oauth) @@ -674,13 +664,16 @@ The following software have components provided under the terms of this license: - mapper-extras (from https://github.com/elastic/elasticsearch) - micrometer-core (from https://github.com/micrometer-metrics/micrometer) - micrometer-registry-azure-monitor (from https://github.com/micrometer-metrics/micrometer) +- mockito-core (from http://mockito.org) +- mockito-core (from http://mockito.org) +- mockito-core (from http://mockito.org) - nio-multipart-parser (from ) - nio-stream-storage (from https://github.com/synchronoss/nio-stream-storage) -- okhttp (from https://square.github.io/okhttp/) -- okhttp (from https://square.github.io/okhttp/) +- okhttp (from https://github.com/square/okhttp) +- okhttp (from https://github.com/square/okhttp) - okhttp-logging-interceptor (from https://square.github.io/okhttp/) -- okio (from https://github.com/square/okio/) -- okio (from https://github.com/square/okio/) +- okhttp-urlconnection (from https://github.com/square/okhttp) +- okhttp-urlconnection (from https://github.com/square/okhttp) - org.conscrypt:conscrypt-openjdk-uber (from https://conscrypt.org/) - org.xmlunit:xmlunit-core (from http://www.xmlunit.org/) - parent-join (from https://github.com/elastic/elasticsearch) @@ -701,13 +694,13 @@ The following software have components provided under the terms of this license: - proto-google-iam-v1 (from https://github.com/googleapis/java-iam/proto-google-iam-v1) - rank-eval (from https://github.com/elastic/elasticsearch) - resilience4j (from https://resilience4j.readme.io) -- resilience4j (from https://github.com/resilience4j/resilience4j) -- resilience4j (from https://resilience4j.readme.io) -- resilience4j (from https://github.com/resilience4j/resilience4j) - resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://resilience4j.readme.io) +- resilience4j (from https://github.com/resilience4j/resilience4j) - resilience4j (from https://resilience4j.readme.io) +- resilience4j (from https://github.com/resilience4j/resilience4j) - resilience4j (from https://resilience4j.readme.io) +- resilience4j (from https://github.com/resilience4j/resilience4j) - rest (from https://github.com/elastic/elasticsearch) - rest-high-level (from https://github.com/elastic/elasticsearch) - rxjava (from https://github.com/ReactiveX/RxJava) @@ -717,6 +710,8 @@ The following software have components provided under the terms of this license: - spring-boot-actuator-autoconfigure (from https://spring.io/projects/spring-boot) - spring-boot-autoconfigure (from https://spring.io/projects/spring-boot) - spring-boot-configuration-processor (from https://spring.io/projects/spring-boot) +- spring-boot-dependencies (from https://spring.io/projects/spring-boot) +- spring-boot-starter (from https://spring.io/projects/spring-boot) - spring-boot-starter-actuator (from https://spring.io/projects/spring-boot) - spring-boot-starter-amqp (from https://spring.io/projects/spring-boot) - spring-boot-starter-aop (from https://spring.io/projects/spring-boot) @@ -724,20 +719,25 @@ The following software have components provided under the terms of this license: - spring-boot-starter-jersey (from https://spring.io/projects/spring-boot) - spring-boot-starter-json (from https://spring.io/projects/spring-boot) - spring-boot-starter-log4j2 (from https://spring.io/projects/spring-boot) +- spring-boot-starter-logging (from https://spring.io/projects/spring-boot) +- spring-boot-starter-reactor-netty (from https://spring.io/projects/spring-boot) +- spring-boot-starter-security (from https://spring.io/projects/spring-boot) - spring-boot-starter-test (from https://spring.io/projects/spring-boot) - spring-boot-starter-tomcat (from https://spring.io/projects/spring-boot) - spring-boot-starter-validation (from https://spring.io/projects/spring-boot) +- spring-boot-starter-web (from https://spring.io/projects/spring-boot) +- spring-boot-starter-webflux (from https://spring.io/projects/spring-boot) - spring-boot-test (from https://spring.io/projects/spring-boot) - spring-boot-test-autoconfigure (from https://spring.io/projects/spring-boot) -- spring-security-config (from https://spring.io/projects/spring-security) -- spring-security-core (from http://spring.io/spring-security) -- spring-security-oauth2-client (from http://spring.io/spring-security) -- spring-security-oauth2-core (from http://spring.io/spring-security) -- spring-security-oauth2-jose (from http://spring.io/spring-security) -- spring-security-oauth2-jose (from http://spring.io/spring-security) -- spring-security-oauth2-resource-server (from http://spring.io/spring-security) -- spring-security-test (from http://spring.io/spring-security) -- spring-security-web (from http://spring.io/spring-security) +- spring-security-config (from https://spring.io/spring-security) +- spring-security-core (from https://spring.io/spring-security) +- spring-security-oauth2-client (from https://spring.io/spring-security) +- spring-security-oauth2-core (from https://spring.io/spring-security) +- spring-security-oauth2-jose (from https://spring.io/spring-security) +- spring-security-oauth2-jose (from https://spring.io/spring-security) +- spring-security-oauth2-resource-server (from https://spring.io/spring-security) +- spring-security-test (from https://spring.io/spring-security) +- spring-security-web (from https://spring.io/spring-security) - springfox-core (from https://github.com/springfox/springfox) - springfox-schema (from https://github.com/springfox/springfox) - springfox-spi (from https://github.com/springfox/springfox) @@ -748,7 +748,7 @@ The following software have components provided under the terms of this license: - swagger-annotations (from https://repo1.maven.org/maven2/io/swagger/swagger-annotations) - swagger-jaxrs (from https://repo1.maven.org/maven2/io/swagger/swagger-jaxrs) - swagger-models (from https://repo1.maven.org/maven2/io/swagger/swagger-models) -- tomcat-annotations-api (from https://tomcat.apache.org/) +- tomcat-annotations-api (from http://tomcat.apache.org/) - tomcat-embed-core (from http://tomcat.apache.org/) - tomcat-embed-el (from https://tomcat.apache.org/) - tomcat-embed-websocket (from https://tomcat.apache.org/) @@ -771,7 +771,7 @@ The following software have components provided under the terms of this license: - Lucene Core (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-core) - Plexus Common Utilities (from https://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils) - Reflections (from http://github.com/ronmamo/reflections) -- Stax2 API (from http://woodstox.codehaus.org/StAX2) +- Stax2 API (from http://github.com/FasterXML/stax2-api) - ThreeTen backport (from https://www.threeten.org/threetenbp) - ThreeTen backport (from https://www.threeten.org/threetenbp) - jersey-ext-bean-validation (from https://repo1.maven.org/maven2/org/glassfish/jersey/ext/jersey-bean-validation) @@ -932,11 +932,11 @@ EPL-1.0 The following software have components provided under the terms of this license: - AspectJ weaver (from http://www.aspectj.org) -- Logback Classic Module (from http://logback.qos.ch) +- Logback Classic Module (from https://repo1.maven.org/maven2/ch/qos/logback/logback-classic) - Logback Contrib :: JSON :: Classic (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-json-classic) - Logback Contrib :: JSON :: Core (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-json-core) - Logback Contrib :: Jackson (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-jackson) -- Logback Core Module (from http://logback.qos.ch) +- Logback Core Module (from https://repo1.maven.org/maven2/ch/qos/logback/logback-core) - Microsoft Application Insights Java SDK Spring Boot starter (from https://github.com/Microsoft/ApplicationInsights-Java) - Microsoft Application Insights Java SDK Web Module (from https://github.com/Microsoft/ApplicationInsights-Java) - Microsoft Application Insights Log4j 2 Appender (from https://github.com/Microsoft/ApplicationInsights-Java) @@ -1036,7 +1036,7 @@ ImageMagick ======================================================================== The following software have components provided under the terms of this license: -- Stax2 API (from http://woodstox.codehaus.org/StAX2) +- Stax2 API (from http://github.com/FasterXML/stax2-api) - Woodstox (from https://github.com/FasterXML/woodstox) ======================================================================== @@ -1065,11 +1065,11 @@ The following software have components provided under the terms of this license: - Java Native Access Platform (from https://github.com/java-native-access/jna) - Javassist (from http://www.javassist.org/) - Javassist (from http://www.javassist.org/) -- Logback Classic Module (from http://logback.qos.ch) +- Logback Classic Module (from https://repo1.maven.org/maven2/ch/qos/logback/logback-classic) - Logback Contrib :: JSON :: Classic (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-json-classic) - Logback Contrib :: JSON :: Core (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-json-core) - Logback Contrib :: Jackson (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-jackson) -- Logback Core Module (from http://logback.qos.ch) +- Logback Core Module (from https://repo1.maven.org/maven2/ch/qos/logback/logback-core) - Microsoft Application Insights Java SDK Spring Boot starter (from https://github.com/Microsoft/ApplicationInsights-Java) - Microsoft Application Insights Java SDK Web Module (from https://github.com/Microsoft/ApplicationInsights-Java) - Microsoft Application Insights Log4j 2 Appender (from https://github.com/Microsoft/ApplicationInsights-Java) @@ -1135,9 +1135,6 @@ The following software have components provided under the terms of this license: - Microsoft Azure common module for Storage (from https://github.com/Azure/azure-sdk-for-java) - Microsoft Azure internal Avro module for Storage (from https://github.com/Azure/azure-sdk-for-java) - Mockito (from http://www.mockito.org) -- Mockito (from http://www.mockito.org) -- Mockito (from http://www.mockito.org) -- Mockito (from http://www.mockito.org) - Netty/Codec/HTTP (from https://repo1.maven.org/maven2/io/netty/netty-codec-http) - 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) @@ -1152,9 +1149,12 @@ The following software have components provided under the terms of this license: - documentdb-bulkexecutor (from http://azure.microsoft.com/en-us/services/documentdb/) - java jwt (from https://github.com/auth0/java-jwt) - micrometer-core (from https://github.com/micrometer-metrics/micrometer) +- mockito-core (from http://mockito.org) +- mockito-core (from http://mockito.org) +- mockito-core (from http://mockito.org) - msal4j (from https://github.com/AzureAD/microsoft-authentication-library-for-java) - msal4j-persistence-extension (from https://github.com/AzureAD/microsoft-authentication-extensions-for-java) -- spring-security-core (from http://spring.io/spring-security) +- spring-security-core (from https://spring.io/spring-security) ======================================================================== MPL-1.1 @@ -1174,7 +1174,7 @@ The following software have components provided under the terms of this license: - Javassist (from http://www.javassist.org/) - Javassist (from http://www.javassist.org/) - RabbitMQ Java Client (from http://www.rabbitmq.com) -- okhttp (from https://square.github.io/okhttp/) +- okhttp (from https://github.com/square/okhttp) ======================================================================== MS-RL @@ -1268,8 +1268,8 @@ The following software have components provided under the terms of this license: - Bouncy Castle PKIX, CMS, EAC, TSP, PKCS, OCSP, CMP, and CRMF APIs (from http://www.bouncycastle.org/java.html) - Bouncy Castle Provider (from http://www.bouncycastle.org/java.html) - Bouncy Castle Provider (from http://www.bouncycastle.org/java.html) -- Guava: Google Core Libraries for Java (from https://github.com/google/guava) -- Guava: Google Core Libraries for Java (from https://github.com/google/guava) +- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) +- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) - HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) - JTidy (from http://jtidy.sourceforge.net) - Joda-Time (from https://www.joda.org/joda-time/) diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/error/GlobalExceptionMapperCore.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/error/GlobalExceptionMapperCore.java index b6323ac4554024cfc82171b8ea74924812498d3d..c34001666b0c993dae73df6d792caa8d93e6067a 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/error/GlobalExceptionMapperCore.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/error/GlobalExceptionMapperCore.java @@ -17,6 +17,8 @@ package org.opengroup.osdu.indexer.error; import javax.validation.ValidationException; import javassist.NotFoundException; +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; @@ -29,6 +31,8 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; import org.opengroup.osdu.core.common.model.http.AppException; +import java.io.IOException; + @Order(Ordered.HIGHEST_PRECEDENCE - 1) @ControllerAdvice public class GlobalExceptionMapperCore extends ResponseEntityExceptionHandler { @@ -59,6 +63,17 @@ public class GlobalExceptionMapperCore extends ResponseEntityExceptionHandler { new AppException(HttpStatus.FORBIDDEN.value(), "Access denied", e.getMessage(), e)); } + @ExceptionHandler(IOException.class) + public ResponseEntity<Object> handleIOException(IOException e) { + if (StringUtils.containsIgnoreCase(ExceptionUtils.getRootCauseMessage(e), "Broken pipe")) { + this.logger.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)); + } + } + @ExceptionHandler(Exception.class) protected ResponseEntity<Object> handleGeneralException(Exception e) { return this.getErrorResponse( diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/error/GlobalExceptionMapperCoreTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/error/GlobalExceptionMapperCoreTest.java index aa53ea967f6a2ddfcc7324d46caabdffd82edf5f..992c0a01fea9b1892e20eaaa31b5674028741a85 100644 --- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/error/GlobalExceptionMapperCoreTest.java +++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/error/GlobalExceptionMapperCoreTest.java @@ -29,8 +29,9 @@ import org.springframework.security.access.AccessDeniedException; import javax.validation.ValidationException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import java.io.IOException; + +import static org.junit.Assert.*; @RunWith(PowerMockRunner.class) public class GlobalExceptionMapperCoreTest { @@ -90,4 +91,20 @@ public class GlobalExceptionMapperCoreTest { ResponseEntity<Object> response = sut.handleAppException(exception); assertEquals(RequestStatus.INVALID_RECORD, response.getStatusCodeValue()); } + + @Test + public void should_returnNullResponse_when_BrokenPipeIOExceptionIsCaptured() { + IOException ioException = new IOException("Broken pipe"); + + ResponseEntity response = this.sut.handleIOException(ioException); + assertNull(response); + } + + @Test + public void should_returnServiceUnavailable_when_IOExceptionIsCaptured() { + IOException ioException = new IOException("Not broken yet"); + + ResponseEntity response = this.sut.handleIOException(ioException); + assertEquals(HttpStatus.SC_SERVICE_UNAVAILABLE, response.getStatusCodeValue()); + } } \ No newline at end of file