From 0fa88a118076f51d9b693cd5ad740898a8081bea Mon Sep 17 00:00:00 2001 From: Sean Yang Date: Mon, 26 Feb 2024 16:39:14 +0800 Subject: [PATCH] Fix compilation error of YamlCodec in jdk1.8 (#13791) --- .../dubbo/remoting/http12/message/codec/YamlCodec.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/message/codec/YamlCodec.java b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/message/codec/YamlCodec.java index 2b3aacfb5c..30380eb159 100644 --- a/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/message/codec/YamlCodec.java +++ b/dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/message/codec/YamlCodec.java @@ -36,12 +36,13 @@ import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.Constructor; import org.yaml.snakeyaml.representer.Representer; +@SuppressWarnings({"unchecked", "rawtypes"}) public class YamlCodec implements HttpMessageCodec { @Override public Object decode(InputStream is, Class targetType, Charset charset) throws DecodeException { try (InputStreamReader reader = new InputStreamReader(is, charset)) { - return createYaml().loadAs(reader, targetType); + return createYaml().loadAs(reader, (Class) targetType); } catch (Throwable t) { throw new DecodeException("Error decoding yaml", t); } @@ -57,7 +58,7 @@ public class YamlCodec implements HttpMessageCodec { for (int i = 0; i < len; i++) { if (iterator.hasNext()) { Object result = iterator.next(); - Class targetType = targetTypes[i]; + Class targetType = targetTypes[i]; if (targetType.isInstance(result)) { results[i] = result; } else {