diff --git a/native/src/main/java/io/ballerina/stdlib/nats/basic/consumer/DefaultMessageHandler.java b/native/src/main/java/io/ballerina/stdlib/nats/basic/consumer/DefaultMessageHandler.java index 31df52cc..fbf8faad 100644 --- a/native/src/main/java/io/ballerina/stdlib/nats/basic/consumer/DefaultMessageHandler.java +++ b/native/src/main/java/io/ballerina/stdlib/nats/basic/consumer/DefaultMessageHandler.java @@ -342,7 +342,7 @@ private static RecordType getRecordType(Type type) { private static Type getPayloadType(Type definedType) { if (definedType.getTag() == INTERSECTION_TAG) { - return ((IntersectionType) definedType).getConstituentTypes().get(0); + return TypeUtils.getReferredType(definedType); } return definedType; }