summaryrefslogtreecommitdiffstats
path: root/common/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/main')
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java12
-rw-r--r--common/src/main/java/org/onap/so/constants/Defaults.java20
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java6
3 files changed, 32 insertions, 6 deletions
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
index 7e4397ec29..e91dc43af9 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
@@ -245,18 +245,22 @@ public class AAIResourcesClient extends AAIClient {
String json;
try {
json = this.createClient(uri).get(String.class)
- .orElseThrow(() -> createException(c, uri.build() + " not found in A&AI"));
+ .orElseThrow(() -> createException(c, uri.build() + " not found in A&AI", Optional.empty()));
} catch (NotFoundException e) {
- throw createException(c, "could not construct uri for use with A&AI");
+ throw createException(c, "could not construct uri for use with A&AI", Optional.of(e));
}
return new AAIResultWrapper(json);
}
- private RuntimeException createException(Class<? extends RuntimeException> c, String message) {
+ private RuntimeException createException(Class<? extends RuntimeException> c, String message, Optional<Throwable> t) {
RuntimeException e;
try {
- e = c.getConstructor(String.class).newInstance(message);
+ if (t.isPresent()) {
+ e = c.getConstructor(String.class, Throwable.class).newInstance(message, t.get());
+ } else {
+ e = c.getConstructor(String.class).newInstance(message);
+ }
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e1) {
throw new IllegalArgumentException("could not create instance for " + c.getName());
diff --git a/common/src/main/java/org/onap/so/constants/Defaults.java b/common/src/main/java/org/onap/so/constants/Defaults.java
index abbd522b4e..06c6fae467 100644
--- a/common/src/main/java/org/onap/so/constants/Defaults.java
+++ b/common/src/main/java/org/onap/so/constants/Defaults.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
package org.onap.so.constants;
public enum Defaults {
diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java
index cc2ccb5c2e..9624dcd578 100644
--- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java
+++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java
@@ -32,8 +32,10 @@ public class MDCTaskDecorator implements TaskDecorator {
Map<String, String> contextMap = MDC.getCopyOfContextMap();
return () -> {
try {
- MDC.setContextMap(contextMap);
- runnable.run();
+ if(contextMap!=null){
+ MDC.setContextMap(contextMap);
+ runnable.run();
+ }
} finally {
MDC.clear();
}