From 0dba887a2cfbd19ba72e933e0839d6c43941867b Mon Sep 17 00:00:00 2001 From: coderzc Date: Fri, 5 Aug 2022 16:54:52 +0800 Subject: [PATCH] fix test --- .../pulsar/handlers/amqp/utils/ExchangeUtil.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/amqp-impl/src/main/java/io/streamnative/pulsar/handlers/amqp/utils/ExchangeUtil.java b/amqp-impl/src/main/java/io/streamnative/pulsar/handlers/amqp/utils/ExchangeUtil.java index 3079445e9..8d204ef36 100644 --- a/amqp-impl/src/main/java/io/streamnative/pulsar/handlers/amqp/utils/ExchangeUtil.java +++ b/amqp-impl/src/main/java/io/streamnative/pulsar/handlers/amqp/utils/ExchangeUtil.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.extern.slf4j.Slf4j; import org.apache.qpid.server.exchange.ExchangeDefaults; @@ -76,16 +77,24 @@ public static String covertObjectValueAsString(Object obj) { } return JSON_MAPPER.writeValueAsString(obj); } catch (Exception e) { + log.error("Failed to covert object: {}", e.getMessage()); throw new RuntimeException(e); } } public static T covertStringValueAsObject(String value, Class clazz) { - return JSON_MAPPER.convertValue(value, clazz); + try { + if (List.class.isAssignableFrom(clazz)) { + return JSON_MAPPER.readValue(value, clazz); + } + return JSON_MAPPER.convertValue(value, clazz); + } catch (Exception e) { + log.error("Failed to covert string: {}", e.getMessage()); + throw new RuntimeException(e); + } } public static Object covertStringValueAsObject(String value) { return covertStringValueAsObject(value, Object.class); } - }