diff --git a/README.md b/README.md index a3f2fa32..2637122c 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ This repository only contains the source code for the package. ### Set up the prerequisites -1. Download and install Java SE Development Kit (JDK) version 17 (from one of the following locations). +1. Download and install Java SE Development Kit (JDK) version 21 (from one of the following locations). * [Oracle](https://www.oracle.com/java/technologies/downloads/) * [OpenJDK](https://adoptium.net/) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 7488a053..2bfffe79 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -7,12 +7,12 @@ keywords = ["websub", "hub", "publisher", "service", "listener", "client"] repository = "https://github.com/ballerina-platform/module-ballerina-websubhub" icon = "icon.png" license = ["Apache-2.0"] -distribution = "2201.11.0" +distribution = "2201.10.0-20241019-091600-89e54c08" -[platform.java17] +[platform.java21] graalvmCompatible = true -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "websubhub-native" version = "1.13.0" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index c32b2be4..5b1dc3bb 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.11.0-20241008-112400-81975006" +distribution-version = "2201.11.0-20241112-214900-6b80ab87" [[package]] org = "ballerina" name = "auth" -version = "2.12.0" +version = "2.12.1" dependencies = [ {org = "ballerina", name = "crypto"}, {org = "ballerina", name = "jballerina.java"}, @@ -22,7 +22,7 @@ dependencies = [ [[package]] org = "ballerina" name = "cache" -version = "3.8.0" +version = "3.8.1" dependencies = [ {org = "ballerina", name = "constraint"}, {org = "ballerina", name = "jballerina.java"}, @@ -33,7 +33,7 @@ dependencies = [ [[package]] org = "ballerina" name = "constraint" -version = "1.5.0" +version = "1.6.0" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -41,7 +41,7 @@ dependencies = [ [[package]] org = "ballerina" name = "crypto" -version = "2.7.2" +version = "2.7.3" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "time"} @@ -62,7 +62,7 @@ dependencies = [ [[package]] org = "ballerina" name = "file" -version = "1.10.0" +version = "1.10.1" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, @@ -106,7 +106,7 @@ modules = [ [[package]] org = "ballerina" name = "io" -version = "1.6.1" +version = "1.6.2" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "lang.value"} @@ -126,7 +126,7 @@ modules = [ [[package]] org = "ballerina" name = "jwt" -version = "2.13.0" +version = "2.13.1" dependencies = [ {org = "ballerina", name = "cache"}, {org = "ballerina", name = "crypto"}, @@ -233,7 +233,7 @@ dependencies = [ [[package]] org = "ballerina" name = "log" -version = "2.10.0" +version = "2.10.1" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, @@ -247,7 +247,7 @@ modules = [ [[package]] org = "ballerina" name = "mime" -version = "2.10.1" +version = "2.10.2" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, @@ -261,7 +261,7 @@ modules = [ [[package]] org = "ballerina" name = "oauth2" -version = "2.12.0" +version = "2.12.1" dependencies = [ {org = "ballerina", name = "cache"}, {org = "ballerina", name = "crypto"}, @@ -274,7 +274,7 @@ dependencies = [ [[package]] org = "ballerina" name = "observe" -version = "1.3.0" +version = "1.4.0" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -282,7 +282,7 @@ dependencies = [ [[package]] org = "ballerina" name = "os" -version = "1.8.0" +version = "1.8.1" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"} @@ -291,7 +291,7 @@ dependencies = [ [[package]] org = "ballerina" name = "task" -version = "2.5.0" +version = "2.5.1" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "time"} @@ -314,7 +314,7 @@ modules = [ [[package]] org = "ballerina" name = "time" -version = "2.5.0" +version = "2.6.0" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -322,7 +322,7 @@ dependencies = [ [[package]] org = "ballerina" name = "url" -version = "2.4.0" +version = "2.4.1" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -333,7 +333,7 @@ modules = [ [[package]] org = "ballerina" name = "uuid" -version = "1.8.0" +version = "1.8.1" dependencies = [ {org = "ballerina", name = "crypto"}, {org = "ballerina", name = "jballerina.java"}, diff --git a/build-config/resources/Ballerina.toml b/build-config/resources/Ballerina.toml index 2d8de29e..a1a85401 100644 --- a/build-config/resources/Ballerina.toml +++ b/build-config/resources/Ballerina.toml @@ -7,12 +7,12 @@ keywords = ["websub", "hub", "publisher", "service", "listener", "client"] repository = "https://github.com/ballerina-platform/module-ballerina-websubhub" icon = "icon.png" license = ["Apache-2.0"] -distribution = "2201.11.0" +distribution = "2201.10.0-20241019-091600-89e54c08" -[platform.java17] +[platform.java21] graalvmCompatible = true -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "websubhub-native" version = "@toml.version@" diff --git a/build.gradle b/build.gradle index f868e81b..c3531ca4 100644 --- a/build.gradle +++ b/build.gradle @@ -16,10 +16,10 @@ */ plugins { - id "com.github.spotbugs" version "5.0.14" - id "com.github.johnrengelman.shadow" version "8.1.1" - id "de.undercouch.download" version "5.4.0" - id "net.researchgate.release" version "2.8.0" + id "com.github.spotbugs" version "${spotbugsPluginVersion}" + id "com.github.johnrengelman.shadow" version "${shadowJarPluginVersion}" + id "de.undercouch.download" version "${downloadPluginVersion}" + id "net.researchgate.release" version "${releasePluginVersion}" } ext.ballerinaLangVersion = project.ballerinaLangVersion diff --git a/compiler-plugin-tests/build.gradle b/compiler-plugin-tests/build.gradle index a011c759..8159ecd7 100644 --- a/compiler-plugin-tests/build.gradle +++ b/compiler-plugin-tests/build.gradle @@ -48,8 +48,11 @@ checkstyle { checkstyleTest.dependsOn(":checkstyle:downloadCheckstyleRuleFiles") spotbugsTest { - effort "max" - reportLevel "low" + def classLoader = plugins["com.github.spotbugs"].class.classLoader + def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence") + def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort") + effort = SpotBugsEffort.MAX + reportLevel = SpotBugsConfidence.LOW reportsDir = file("$project.buildDir/reports/spotbugs") reports { html.enabled true diff --git a/compiler-plugin/build.gradle b/compiler-plugin/build.gradle index adbe3f12..f5a671b0 100644 --- a/compiler-plugin/build.gradle +++ b/compiler-plugin/build.gradle @@ -40,8 +40,11 @@ checkstyle { checkstyleMain.dependsOn(":checkstyle:downloadCheckstyleRuleFiles") spotbugsMain { - effort "max" - reportLevel "low" + def classLoader = plugins["com.github.spotbugs"].class.classLoader + def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence") + def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort") + effort = SpotBugsEffort.MAX + reportLevel = SpotBugsConfidence.LOW reportsDir = file("$project.buildDir/reports/spotbugs") reports { html.enabled true diff --git a/compiler-plugin/src/main/java/io/ballerina/stdlib/websubhub/task/validator/ServiceDeclarationValidator.java b/compiler-plugin/src/main/java/io/ballerina/stdlib/websubhub/task/validator/ServiceDeclarationValidator.java index 0b2e7efe..5d98533b 100644 --- a/compiler-plugin/src/main/java/io/ballerina/stdlib/websubhub/task/validator/ServiceDeclarationValidator.java +++ b/compiler-plugin/src/main/java/io/ballerina/stdlib/websubhub/task/validator/ServiceDeclarationValidator.java @@ -41,6 +41,10 @@ public class ServiceDeclarationValidator { private static final Map> allowedReturnTypes; private static final List methodsWithOptionalReturnTypes; + private ServiceDeclarationValidator() { + //private constructor + } + static { allowedMethods = List.of( Constants.ON_REGISTER_TOPIC, Constants.ON_DEREGISTER_TOPIC, Constants.ON_UPDATE_MESSAGE, diff --git a/gradle.properties b/gradle.properties index 098dc1f1..2a875b6c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,42 +1,48 @@ org.gradle.caching=true group=io.ballerina.stdlib version=1.13.0-SNAPSHOT -ballerinaLangVersion=2201.11.0-20241008-112400-81975006 +ballerinaLangVersion=2201.11.0-20241112-214900-6b80ab87 + puppycrawlCheckstyleVersion=10.12.0 testngVersion=7.6.1 ballerinaGradlePluginVersion=2.0.1 gsonVersion=2.8.8 +spotbugsPluginVersion=6.0.18 +shadowJarPluginVersion=8.1.1 +downloadPluginVersion=5.4.0 +releasePluginVersion=2.8.0 + # Direct Dependencies -stdlibIoVersion=1.6.1 -stdlibRandomVersion=1.5.0 -stdlibTimeVersion=2.4.0 -stdlibUrlVersion=2.4.0 -stdlibCryptoVersion=2.7.2 -stdlibLogVersion=2.10.0 -stdlibMimeVersion=2.10.0 -stdlibUuidVersion=1.8.0 -stdlibHttpVersion=2.13.0-20241106-120000-d375c3b +stdlibIoVersion=1.6.2-20241112-233100-995cf5f +stdlibRandomVersion=1.5.1-20241113-122300-1bc770e +stdlibTimeVersion=2.6.0-20241113-073800-201b904 +stdlibUrlVersion=2.4.1-20241113-073900-335ff51 +stdlibCryptoVersion=2.7.3-20241113-081400-d015a39 +stdlibLogVersion=2.10.1-20241113-120000-4577868 +stdlibMimeVersion=2.10.2-20241113-154200-d953747 +stdlibUuidVersion=1.8.1-20241113-154400-443c67b +stdlibHttpVersion=2.13.0-20241114-182900-7e9f66a # Transitive Dependencies # Level 01 -stdlibConstraintVersion=1.5.0 +stdlibConstraintVersion=1.6.0-20241113-090900-d276ad5 # Level 02 -stdlibOsVersion=1.8.0 -stdlibTaskVersion=2.5.0 +stdlibOsVersion=1.8.1-20241113-122000-cca973b +stdlibTaskVersion=2.5.1-20241113-123500-f905281 # Level 03 -stdlibCacheVersion=3.8.0 -stdlibFileVersion=1.10.0 +stdlibCacheVersion=3.8.1-20241113-125700-b75a1bf +stdlibFileVersion=1.10.1-20241113-151700-e1a2e38 # Level 04 -stdlibAuthVersion=2.12.0 -stdlibDataJsonDataVersion=0.3.0-20241105-101100-661d11f -stdlibJwtVersion=2.13.0 -stdlibOAuth2Version=2.12.0 +stdlibAuthVersion=2.12.1-20241113-162300-ded40eb +stdlibDataJsonDataVersion=0.3.0-20241114-143900-285d739 +stdlibJwtVersion=2.13.1-20241113-162400-b59ccfa +stdlibOAuth2Version=2.12.1-20241113-162400-4c6ddfe # Ballerinax Observe -observeVersion=1.3.0 -observeInternalVersion=1.3.0 +observeVersion=1.4.0-20241113-092000-b83ae74 +observeInternalVersion=1.3.1-20241113-101700-265054d diff --git a/native/build.gradle b/native/build.gradle index 6f5eb8b6..caad4a16 100644 --- a/native/build.gradle +++ b/native/build.gradle @@ -42,8 +42,11 @@ checkstyle { checkstyleMain.dependsOn(":checkstyle:downloadCheckstyleRuleFiles") spotbugsMain { - effort "max" - reportLevel "low" + def classLoader = plugins["com.github.spotbugs"].class.classLoader + def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence") + def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort") + effort = SpotBugsEffort.MAX + reportLevel = SpotBugsConfidence.LOW reportsDir = file("$project.buildDir/reports/spotbugs") reports { html.enabled true diff --git a/native/src/main/java/io/ballerina/stdlib/websubhub/HubCallback.java b/native/src/main/java/io/ballerina/stdlib/websubhub/HubCallback.java deleted file mode 100644 index 7debf2f7..00000000 --- a/native/src/main/java/io/ballerina/stdlib/websubhub/HubCallback.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.stdlib.websubhub; - -import io.ballerina.runtime.api.Future; -import io.ballerina.runtime.api.Module; -import io.ballerina.runtime.api.async.Callback; -import io.ballerina.runtime.api.types.Type; -import io.ballerina.runtime.api.values.BError; - -/** - * {@code HubCallback} used to handle the websubhub remote method invocation results. - */ -public class HubCallback implements Callback { - private final Future future; - private final Module module; - - public HubCallback(Future future, Module module) { - this.future = future; - this.module = module; - } - - @Override - public void notifySuccess(Object result) { - if (result instanceof BError) { - BError error = (BError) result; - if (!isModuleDefinedError(error)) { - error.printStackTrace(); - } - } - - future.complete(result); - } - - @Override - public void notifyFailure(BError bError) { - bError.printStackTrace(); - // Service level `panic` is captured in this method. - // Since, `panic` is due to a critical application bug or resource exhaustion we need to exit the application. - // Please refer: https://github.com/ballerina-platform/ballerina-standard-library/issues/2714 - System.exit(1); - } - - private boolean isModuleDefinedError(BError error) { - Type errorType = error.getType(); - Module packageDetails = errorType.getPackage(); - String orgName = packageDetails.getOrg(); - String packageName = packageDetails.getName(); - return Constants.PACKAGE_ORG.equals(orgName) && Constants.PACKAGE_NAME.equals(packageName); - } -} diff --git a/native/src/main/java/io/ballerina/stdlib/websubhub/ModuleUtils.java b/native/src/main/java/io/ballerina/stdlib/websubhub/ModuleUtils.java index 4e95f1ed..f94df090 100644 --- a/native/src/main/java/io/ballerina/stdlib/websubhub/ModuleUtils.java +++ b/native/src/main/java/io/ballerina/stdlib/websubhub/ModuleUtils.java @@ -20,6 +20,11 @@ import io.ballerina.runtime.api.Environment; import io.ballerina.runtime.api.Module; +import io.ballerina.runtime.api.creators.ErrorCreator; +import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.values.BError; + +import java.util.concurrent.CompletableFuture; /** * {@code ModuleUtils} contains the utility methods for the module. @@ -37,4 +42,43 @@ public static void setModule(Environment environment) { public static Module getModule() { return module; } + + public static void notifySuccess(CompletableFuture future, Object result) { + if (result instanceof BError) { + BError error = (BError) result; + if (!isModuleDefinedError(error)) { + error.printStackTrace(); + } + } + future.complete(result); + } + + public static void notifyFailure(BError bError) { + bError.printStackTrace(); + // Service level `panic` is captured in this method. + // Since, `panic` is due to a critical application bug or resource exhaustion we need to exit the application. + // Please refer: https://github.com/ballerina-platform/ballerina-standard-library/issues/2714 + System.exit(1); + } + + private static boolean isModuleDefinedError(BError error) { + Type errorType = error.getType(); + Module packageDetails = errorType.getPackage(); + String orgName = packageDetails.getOrg(); + String packageName = packageDetails.getName(); + return Constants.PACKAGE_ORG.equals(orgName) && Constants.PACKAGE_NAME.equals(packageName); + } + + public static Object getResult(CompletableFuture balFuture) { + try { + return balFuture.get(); + } catch (BError error) { + throw error; + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw ErrorCreator.createError(e); + } catch (Throwable throwable) { + throw ErrorCreator.createError(throwable); + } + } } diff --git a/native/src/main/java/io/ballerina/stdlib/websubhub/NativeHttpToWebsubhubAdaptor.java b/native/src/main/java/io/ballerina/stdlib/websubhub/NativeHttpToWebsubhubAdaptor.java index d61825ed..747e514c 100644 --- a/native/src/main/java/io/ballerina/stdlib/websubhub/NativeHttpToWebsubhubAdaptor.java +++ b/native/src/main/java/io/ballerina/stdlib/websubhub/NativeHttpToWebsubhubAdaptor.java @@ -19,26 +19,25 @@ package io.ballerina.stdlib.websubhub; import io.ballerina.runtime.api.Environment; -import io.ballerina.runtime.api.Future; import io.ballerina.runtime.api.Module; -import io.ballerina.runtime.api.PredefinedTypes; -import io.ballerina.runtime.api.TypeTags; -import io.ballerina.runtime.api.async.StrandMetadata; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.IntersectionType; import io.ballerina.runtime.api.types.MethodType; import io.ballerina.runtime.api.types.ObjectType; import io.ballerina.runtime.api.types.Parameter; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; +import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BString; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CompletableFuture; import static io.ballerina.stdlib.websubhub.Constants.ON_DEREGISTER_TOPIC; import static io.ballerina.stdlib.websubhub.Constants.ON_REGISTER_TOPIC; @@ -78,7 +77,7 @@ public static Object callRegisterMethod(Environment env, BObject adaptor, if (isReadOnly) { message.freezeDirect(); } - Object[] args = new Object[]{message, true, bHttpHeaders, true}; + Object[] args = new Object[]{message, bHttpHeaders}; return invokeRemoteFunction(env, bHubService, args, "callRegisterMethod", ON_REGISTER_TOPIC); } @@ -90,7 +89,7 @@ public static Object callDeregisterMethod(Environment env, BObject adaptor, if (isReadOnly) { message.freezeDirect(); } - Object[] args = new Object[]{message, true, bHttpHeaders, true}; + Object[] args = new Object[]{message, bHttpHeaders}; return invokeRemoteFunction(env, bHubService, args, "callDeregisterMethod", ON_DEREGISTER_TOPIC); } @@ -102,7 +101,7 @@ public static Object callOnUpdateMethod(Environment env, BObject adaptor, if (isReadOnly) { message.freezeDirect(); } - Object[] args = new Object[]{message, true, bHttpHeaders, true}; + Object[] args = new Object[]{message, bHttpHeaders}; return invokeRemoteFunction(env, bHubService, args, "callOnUpdateMethod", ON_UPDATE_MESSAGE); } @@ -114,7 +113,7 @@ public static Object callOnSubscriptionMethod(Environment env, BObject adaptor, if (isReadOnly) { message.freezeDirect(); } - Object[] args = new Object[]{message, true, bHttpHeaders, true}; + Object[] args = new Object[]{message, bHttpHeaders}; return invokeRemoteFunction(env, bHubService, args, "callOnSubscriptionMethod", ON_SUBSCRIPTION); } @@ -126,7 +125,7 @@ public static Object callOnSubscriptionValidationMethod(Environment env, BObject if (isReadOnly) { message.freezeDirect(); } - Object[] args = new Object[]{message, true, bHttpHeaders, true}; + Object[] args = new Object[]{message, bHttpHeaders}; return invokeRemoteFunction(env, bHubService, args, "callOnSubscriptionValidationMethod", ON_SUBSCRIPTION_VALIDATION); } @@ -138,7 +137,7 @@ public static Object callOnSubscriptionIntentVerifiedMethod(Environment env, BOb if (isReadOnly) { message.freezeDirect(); } - Object[] args = new Object[]{message, true, bHttpHeaders, true}; + Object[] args = new Object[]{message, bHttpHeaders}; return invokeRemoteFunction(env, bHubService, args, "callOnSubscriptionIntentVerifiedMethod", ON_SUBSCRIPTION_INTENT_VERIFIED); @@ -151,7 +150,7 @@ public static Object callOnUnsubscriptionMethod(Environment env, BObject adaptor if (isReadOnly) { message.freezeDirect(); } - Object[] args = new Object[]{message, true, bHttpHeaders, true}; + Object[] args = new Object[]{message, bHttpHeaders}; return invokeRemoteFunction(env, bHubService, args, "callOnUnsubscriptionMethod", ON_UNSUBSCRIPTION); } @@ -163,7 +162,7 @@ public static Object callOnUnsubscriptionValidationMethod(Environment env, BObje if (isReadOnly) { message.freezeDirect(); } - Object[] args = new Object[]{message, true, bHttpHeaders, true}; + Object[] args = new Object[]{message, bHttpHeaders}; return invokeRemoteFunction(env, bHubService, args, "callOnUnsubscriptionValidationMethod", ON_UNSUBSCRIPTION_VALIDATION); } @@ -175,7 +174,7 @@ public static Object callOnUnsubscriptionIntentVerifiedMethod(Environment env, B if (isReadOnly) { message.freezeDirect(); } - Object[] args = new Object[]{message, true, bHttpHeaders, true}; + Object[] args = new Object[]{message, bHttpHeaders}; return invokeRemoteFunction(env, bHubService, args, "callOnUnsubscriptionIntentVerifiedMethod", ON_UNSUBSCRIPTION_INTENT_VERIFIED); } @@ -200,20 +199,18 @@ private static boolean isReadOnlyParam(BObject serviceObj, String remoteMethod) private static Object invokeRemoteFunction(Environment env, BObject bHubService, Object[] args, String parentFunctionName, String remoteFunctionName) { - Future balFuture = env.markAsync(); - Module module = ModuleUtils.getModule(); - StrandMetadata metadata = new StrandMetadata(module.getOrg(), module.getName(), module.getVersion(), - parentFunctionName); - ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(bHubService)); - if (serviceType.isIsolated() && serviceType.isIsolated(remoteFunctionName)) { - env.getRuntime().invokeMethodAsyncConcurrently( - bHubService, remoteFunctionName, null, metadata, - new HubCallback(balFuture, module), null, PredefinedTypes.TYPE_NULL, args); - } else { - env.getRuntime().invokeMethodAsyncSequentially( - bHubService, remoteFunctionName, null, metadata, - new HubCallback(balFuture, module), null, PredefinedTypes.TYPE_NULL, args);; - } - return null; + return env.yieldAndRun(() -> { + CompletableFuture balFuture = new CompletableFuture<>(); + Module module = ModuleUtils.getModule(); + ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(bHubService)); + try { + Object result = env.getRuntime().callMethod(bHubService, remoteFunctionName, null, args); + ModuleUtils.notifySuccess(balFuture, result); + return ModuleUtils.getResult(balFuture); + } catch (BError bError) { + ModuleUtils.notifyFailure(bError); + } + return null; + }); } }