diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/BooleanFeatureFlagClient.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/BooleanFeatureFlagClient.java index 42a075e694db123dc2f697c9c135ec0b3f55ef1d..b21bbb47aec44f2774bc2cec8486a9c4b77bb5cf 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/BooleanFeatureFlagClient.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/BooleanFeatureFlagClient.java @@ -55,7 +55,11 @@ public class BooleanFeatureFlagClient { PartitionInfo partitionInfo = partitionProvider.get(dataPartitionId); return partitionInfo; } catch (PartitionException e) { - logger.error(String.format("Error getting partition info for data-partition: %s. Message: %s. ResponseCode: %s.", dataPartitionId, e.getResponse().getBody(), e.getResponse().getResponseCode()), e); + if (e.getResponse() != null) { + logger.error(String.format("Error getting partition info for data-partition: %s. Message: %s. ResponseCode: %s.", dataPartitionId, e.getResponse().getBody(), e.getResponse().getResponseCode()), e); + } else { + logger.error(String.format("Error getting partition info for data-partition: %s.", dataPartitionId), e); + } throw e; } } diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/api/RecordIndexerApiTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/api/RecordIndexerApiTest.java index 0787ade6afe3c312c14a039323bf934d75849d89..fd5940d16d90b59844aea1d6d5f4ac64a23405ac 100644 --- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/api/RecordIndexerApiTest.java +++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/api/RecordIndexerApiTest.java @@ -24,6 +24,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Mockito; import org.opengroup.osdu.core.common.http.HeadersUtil; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.model.http.AppException; @@ -90,6 +91,12 @@ public class RecordIndexerApiTest { should_return400_indexerWorkerTest(messageEmpty, String.format("Required header: '%s' not found", DpsHeaders.DATA_PARTITION_ID)); } + @Test + public void should_addCorrelationIdToHeader_IfExists_indexWorkerTest() throws Exception { + this.sut.indexWorker(createRecordChangedMessage(recordMessageValid)); + Mockito.verify(this.requestInfo.getHeaders()).put("correlation-id", "b5a281bd-f59d-4db2-9939-b2d85036fc7e"); + } + @Test public void should_return400_given_incorrectJsonFormatMessage_indexWorkerTest() { should_return400_indexerWorkerTest(messageWithIncorrectJsonFormat, "Unable to parse request payload.");