summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2020-01-23 15:22:08 +0000
committerGerrit Code Review <gerrit@onap.org>2020-01-23 15:22:08 +0000
commit3ed40f1a7fe37e61e92ee9d47c157805ce3ea7a5 (patch)
tree3a752f89503f4df1180f2e8076fd612fdef913b4
parentcf4b410cfd7a561649e105d62d1bad6d05dc2acd (diff)
parent29a97a7fe7fa9c3c50fba299a7b1cf121be05b07 (diff)
Merge "Revert "Promise Request-id header: Check MDC value if no header""
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseRequestIdFilter.java13
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/filter/PromiseRequestIdFilterTest.java27
2 files changed, 2 insertions, 38 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseRequestIdFilter.java b/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseRequestIdFilter.java
index 1c96819c8..faaf55ae7 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseRequestIdFilter.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseRequestIdFilter.java
@@ -41,10 +41,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
-import org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs;
import org.onap.vid.logging.Headers;
import org.onap.vid.logging.RequestIdHeader;
-import org.slf4j.MDC;
import org.springframework.web.filter.GenericFilterBean;
@WebFilter(urlPatterns = "/*")
@@ -84,17 +82,12 @@ public class PromiseRequestIdFilter extends GenericFilterBean {
if (isWrapNeeded(highestPriorityHeader, originalRequestId)) {
// Copy originalRequestId to the promised header value
- request = new PromiseRequestIdRequestWrapper(httpRequest,
- firstValidUuidOrElse(originalRequestId, requestIdFromMDC(), UUID::randomUUID));
+ request = new PromiseRequestIdRequestWrapper(httpRequest, toUuidOrElse(originalRequestId, UUID::randomUUID));
}
return request;
}
- private String requestIdFromMDC() {
- return MDC.get(MDCs.REQUEST_ID);
- }
-
private boolean verifyAndValidateUuid(String value) {
return isNotEmpty(value) && uuidRegex.matcher(value).matches();
}
@@ -106,10 +99,6 @@ public class PromiseRequestIdFilter extends GenericFilterBean {
return !headerExistsAndValid;
}
- UUID firstValidUuidOrElse(String uuid1, String uuid2, Supplier<UUID> uuidSupplier) {
- return toUuidOrElse(uuid1, () -> toUuidOrElse(uuid2, uuidSupplier));
- }
-
UUID toUuidOrElse(String uuid, Supplier<UUID> uuidSupplier) {
if (verifyAndValidateUuid(uuid)) {
try {
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/filter/PromiseRequestIdFilterTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/filter/PromiseRequestIdFilterTest.java
index f415bfbcb..d67bd618c 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/filter/PromiseRequestIdFilterTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/filter/PromiseRequestIdFilterTest.java
@@ -51,12 +51,9 @@ import javax.servlet.http.HttpServletResponse;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer;
-import org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs;
import org.onap.portalsdk.core.web.support.UserUtils;
import org.onap.vid.logging.RequestIdHeader;
-import org.slf4j.MDC;
import org.springframework.mock.web.MockHttpServletResponse;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -73,18 +70,10 @@ public class PromiseRequestIdFilterTest {
private final PromiseRequestIdFilter promiseRequestIdFilter = new PromiseRequestIdFilter();
- @AfterMethod
- public void tearDown() {
- MDC.remove(MDCs.REQUEST_ID);
- }
-
@Test
- public void givenMdcValueAndRequestIdHeader_headerValueNotChanged() throws IOException, ServletException {
+ public void givenRequestIdHeader_headerValueNotChanged() throws IOException, ServletException {
final String someTxId = "863850e2-8545-4efd-94b8-afba5f52b3d5";
- final String mdcTxId = "ed752ff1-3970-4f18-8219-2d821fa4eaea";
-
- MDC.put(MDCs.REQUEST_ID, mdcTxId);
final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of(
anotherHeader, anotherValue,
@@ -133,20 +122,6 @@ public class PromiseRequestIdFilterTest {
}
@Test
- public void givenMdcValueAndNoRequestIdHeader_headerValueWasFromMDC() throws IOException, ServletException {
-
- final String mdcTxId = "ed752ff1-3970-4f18-8219-2d821fa4eaea";
-
- MDC.put(MDCs.REQUEST_ID, mdcTxId);
-
- final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of(
- anotherHeader, anotherValue
- );
-
- buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, specificTxId(mdcTxId));
- }
-
- @Test
public void givenTwoRequestIdHeader_onapHeaderValueIsUsed() throws IOException, ServletException {
final String onapTxId = "863850e2-8545-4efd-94b8-AFBA5F52B3D5"; // note mixed case