From c34285e35a263a95611ea4403e2245bbd02e3f8f Mon Sep 17 00:00:00 2001 From: hindujaB Date: Thu, 27 Apr 2023 18:43:11 +0530 Subject: [PATCH] Fix BObject getType API --- native/src/main/java/io/ballerina/stdlib/stan/Utils.java | 2 +- .../main/java/io/ballerina/stdlib/stan/consumer/Attach.java | 4 ++-- .../io/ballerina/stdlib/stan/consumer/StreamingListener.java | 2 +- .../java/io/ballerina/stdlib/stan/consumer/Subscribe.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/native/src/main/java/io/ballerina/stdlib/stan/Utils.java b/native/src/main/java/io/ballerina/stdlib/stan/Utils.java index 843eff2..0d063fc 100644 --- a/native/src/main/java/io/ballerina/stdlib/stan/Utils.java +++ b/native/src/main/java/io/ballerina/stdlib/stan/Utils.java @@ -60,7 +60,7 @@ public static byte[] convertDataIntoByteArray(Object data) { public static MethodType getAttachedFunctionType(BObject serviceObject, String functionName) { MethodType function = null; - ObjectType objectType = (ObjectType) TypeUtils.getReferredType(serviceObject.getType()); + ObjectType objectType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(serviceObject)); MethodType[] resourceFunctions = objectType.getMethods(); for (MethodType resourceFunction : resourceFunctions) { if (functionName.equals(resourceFunction.getName())) { diff --git a/native/src/main/java/io/ballerina/stdlib/stan/consumer/Attach.java b/native/src/main/java/io/ballerina/stdlib/stan/consumer/Attach.java index a61ba76..05de394 100644 --- a/native/src/main/java/io/ballerina/stdlib/stan/consumer/Attach.java +++ b/native/src/main/java/io/ballerina/stdlib/stan/consumer/Attach.java @@ -47,7 +47,7 @@ public static Object attach(Environment environment, BObject streamingListener, Object serviceName) { String subject; Object streamingConnectionUrl = streamingListener.getNativeData(Constants.URL.getValue()); - ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(service.getType()); + ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(service)); @SuppressWarnings("unchecked") BMap annotation = (BMap) serviceType .getAnnotation(StringUtils.fromString(Utils.getModule().getOrg() + ORG_NAME_SEPARATOR + @@ -73,7 +73,7 @@ public static Object attach(Environment environment, BObject streamingListener, } private static boolean getAckMode(BObject service) { - ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(service.getType()); + ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(service)); @SuppressWarnings("unchecked") BMap serviceConfig = (BMap) serviceType .getAnnotation(StringUtils.fromString(Utils.getModule().getOrg() + ORG_NAME_SEPARATOR + diff --git a/native/src/main/java/io/ballerina/stdlib/stan/consumer/StreamingListener.java b/native/src/main/java/io/ballerina/stdlib/stan/consumer/StreamingListener.java index a01a5ad..7a5a1b3 100644 --- a/native/src/main/java/io/ballerina/stdlib/stan/consumer/StreamingListener.java +++ b/native/src/main/java/io/ballerina/stdlib/stan/consumer/StreamingListener.java @@ -127,7 +127,7 @@ private void executeResource(String subject, Object[] args, Type returnType) { CountDownLatch countDownLatch = new CountDownLatch(1); StrandMetadata metadata = new StrandMetadata(Utils.getModule().getOrg(), Utils.getModule().getName(), Utils.getModule().getVersion(), Constants.ON_MESSAGE_RESOURCE); - ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(service.getType()); + ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(service)); if (ObserveUtils.isTracingEnabled()) { Map properties = new HashMap<>(); NatsObserverContext observerContext = new NatsObserverContext(NatsObservabilityConstants.CONTEXT_CONSUMER, diff --git a/native/src/main/java/io/ballerina/stdlib/stan/consumer/Subscribe.java b/native/src/main/java/io/ballerina/stdlib/stan/consumer/Subscribe.java index ea1bfd0..1e15e8f 100644 --- a/native/src/main/java/io/ballerina/stdlib/stan/consumer/Subscribe.java +++ b/native/src/main/java/io/ballerina/stdlib/stan/consumer/Subscribe.java @@ -87,7 +87,7 @@ public static void streamingSubscribe(BObject streamingListener) { private static Subscription createSubscription(BObject service, StreamingListener messageHandler, io.nats.streaming.StreamingConnection streamingConnection, NatsMetricsReporter natsMetricsReporter) { - ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(service.getType()); + ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(service)); BMap annotation = (BMap) serviceType .getAnnotation(StringUtils.fromString(Utils.getModule().getOrg() + ORG_NAME_SEPARATOR + Utils.getModule().getName() + VERSION_SEPARATOR +