From: adheli.tavares Date: Mon, 14 Apr 2025 15:31:37 +0000 (+0100) Subject: Security uplift X-Git-Tag: 3.1.2~2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=de8def4691872d18a92176eb4d321f2518f162b3;p=policy%2Fcommon.git Security uplift - fix error messages from new version of gson Issue-ID: POLICY-5302 Change-Id: Id89fdd70c495374bc0862fba1a947538826218f2 Signed-off-by: adheli.tavares --- diff --git a/gson/src/test/java/org/onap/policy/common/gson/internal/JacksonTypeAdapterTest.java b/gson/src/test/java/org/onap/policy/common/gson/internal/JacksonTypeAdapterTest.java index e2d350ec..a5ebc1ed 100644 --- a/gson/src/test/java/org/onap/policy/common/gson/internal/JacksonTypeAdapterTest.java +++ b/gson/src/test/java/org/onap/policy/common/gson/internal/JacksonTypeAdapterTest.java @@ -1,10 +1,10 @@ /* - * ============LICENSE_START======================================================= + * ============LICENSE_START============================================================== * ONAP - * ================================================================================ + * ======================================================================================= * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2024 Nordix Foundation - * ================================================================================ + * Modifications Copyright (C) 2024-2025 OpenInfra Foundation Europe. 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 @@ -16,7 +16,9 @@ * 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========================================================= + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END================================================================ */ package org.onap.policy.common.gson.internal; @@ -27,6 +29,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; @@ -45,7 +48,7 @@ class JacksonTypeAdapterTest { /** * Gson object that excludes fields, as we're going to process the fields ourselves. */ - private static Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); + private static final Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); private JacksonTypeAdapter adapter; private List sers; @@ -86,7 +89,14 @@ class JacksonTypeAdapterTest { } }); - TypeAdapter delegate = gson.getDelegateAdapter(null, TypeToken.get(Data.class)); + TypeAdapterFactory factory = new TypeAdapterFactory() { + @Override + public TypeAdapter create(Gson gson, TypeToken typeToken) { + return null; + } + }; + + TypeAdapter delegate = gson.getDelegateAdapter(factory, TypeToken.get(Data.class)); adapter = new JacksonTypeAdapter<>(gson, delegate, sers, desers); }