diff --git a/CHANGELOG.md b/CHANGELOG.md index ec956e2e24b..9fa9416a468 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ Fix #5145: [java-generator] handle `additionalProperties: true` emitting a field * Fix #4911: Config/RequestConfig.scaleTimeout has been deprecated along with Scalable.scale(count, wait) and DeployableScalableResource.deployLatest(wait). withTimeout may be called before the operation to control the timeout. * Fix #4911: Config/RequestConfig.websocketTimeout has been removed. Config/RequestConfig.requestTimeout will be used for websocket connection timeouts. * Fix #4911: HttpClient api/building changes - writeTimeout has been removed, readTimeout has moved to the HttpRequest +* Fix #4662: removed deprecated classes/methods: ReflectUtils, ReplaceValueStream, ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable, ResourceCompare, and Serialization methods taking parameters +* Fix #4662: deprecated serialization static logic: several IOHelpers methods, Serialization methods, such as access to the static jsonMapper. Please use KubernetesSerialization methods instead. +* Fix #4662: deprecated Helper.getAnnotationValue, use HasMetadata methods instead. ### 6.6.2 (2023-05-15) diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Cache.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Cache.java index 401ab702e09..8b091142947 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Cache.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/informers/cache/Cache.java @@ -17,11 +17,11 @@ import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.ObjectMeta; -import io.fabric8.kubernetes.client.utils.ReflectUtils; import io.fabric8.kubernetes.client.utils.Utils; import java.util.Collections; import java.util.List; +import java.util.Optional; /** * It basically saves and indexes all the entries. @@ -41,27 +41,16 @@ public interface Cache extends Indexer { * @param obj specific object * @return the key */ - public static String metaNamespaceKeyFunc(Object obj) { - try { - if (obj == null) { - return ""; - } - ObjectMeta metadata; - if (obj instanceof String) { - return (String) obj; - } else if (obj instanceof ObjectMeta) { - metadata = (ObjectMeta) obj; - } else { - metadata = ReflectUtils.objectMetadata(obj); - if (metadata == null) { - throw new RuntimeException("Object is bad :" + obj); - } - } - - return namespaceKeyFunc(metadata.getNamespace(), metadata.getName()); - } catch (ReflectiveOperationException e) { - throw new RuntimeException(e); + public static String metaNamespaceKeyFunc(HasMetadata obj) { + if (obj == null) { + return ""; + } + ObjectMeta metadata = obj.getMetadata(); + if (metadata == null) { + throw new RuntimeException("Object is bad :" + obj); } + + return namespaceKeyFunc(metadata.getNamespace(), metadata.getName()); } public static String metaUidKeyFunc(HasMetadata obj) { @@ -90,12 +79,8 @@ public static String namespaceKeyFunc(String objectNamespace, String objectName) * @param obj the specific object * @return the indexed value */ - public static List metaNamespaceIndexFunc(Object obj) { - try { - ObjectMeta metadata = ReflectUtils.objectMetadata(obj); - return metadata == null ? Collections.emptyList() : Collections.singletonList(metadata.getNamespace()); - } catch (ReflectiveOperationException e) { - throw new RuntimeException(e); - } + public static List metaNamespaceIndexFunc(HasMetadata obj) { + return Optional.ofNullable(obj).map(HasMetadata::getMetadata) + .map(metadata -> Collections.singletonList(metadata.getNamespace())).orElse(Collections.emptyList()); } } diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ReflectUtils.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ReflectUtils.java index 90df0e01ba8..d514b05e610 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ReflectUtils.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ReflectUtils.java @@ -24,6 +24,10 @@ import java.lang.reflect.Method; import java.util.List; +/** + * @deprecated use {@link HasMetadata} methods instead + */ +@Deprecated public class ReflectUtils { private ReflectUtils() { throw new IllegalStateException("Utility class"); diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ReplaceValueStream.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ReplaceValueStream.java index 3e5163c0604..4be65d2cb6d 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ReplaceValueStream.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/ReplaceValueStream.java @@ -26,7 +26,10 @@ /** * Replaces template parameter values in the stream to avoid * parsing issues of templates with numeric expressions + * + * @deprecated to be removed in future versions */ +@Deprecated public class ReplaceValueStream { private final Map valuesMap;