diff options
author | Rob Daugherty <rd472p@att.com> | 2018-10-17 13:11:41 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-10-17 13:11:41 +0000 |
commit | 15af810c48631a9dfe24ec6b39186e3797c0143b (patch) | |
tree | 4e67c7c655ced32faf293a616db86529cf0b8aa7 /common/src/main | |
parent | 6ad847887d9fafce3305cd7b709154b6618ff6a7 (diff) | |
parent | 2ff435b28384a066017b690cf8a876a2cdd52d29 (diff) |
Merge "Bug fixes for casablanca"
Diffstat (limited to 'common/src/main')
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(); } |