diff --git a/README.md b/README.md index 1328b832d..cdd7d4394 100644 --- a/README.md +++ b/README.md @@ -345,7 +345,7 @@ This repository only contains the source code for the module. ### Set Up the prerequisites -* Download and install Java SE Development Kit (JDK) version 17 (from one of the following locations). +* Download and install Java SE Development Kit (JDK) version 21 (from one of the following locations). * [Oracle](https://www.oracle.com/java/technologies/downloads/) diff --git a/ballerina-tests/Ballerina.toml b/ballerina-tests/Ballerina.toml index df96c227a..2e96e14c3 100644 --- a/ballerina-tests/Ballerina.toml +++ b/ballerina-tests/Ballerina.toml @@ -3,33 +3,33 @@ org = "ballerina" name = "grpc_tests" version = "@toml.version@" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "grpc-native" version = "@project.version@" path = "../native/build/libs/grpc-native-@project.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "../test-utils/build/libs/grpc-test-utils-@project.version@.jar" scope = "testOnly" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "./lib/ballerina-cli-@ballerinalang.version@.jar" scope = "testOnly" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "com.google.protobuf" artifactId = "protobuf-java" version = "@protobuf.java.version@" path = "./lib/protobuf-java-@protobuf.java.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "com.google.api.grpc" artifactId = "proto-google-common-protos" version = "@proto.google.commons.version@" path = "./lib/proto-google-common-protos-@proto.google.commons.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "org.ballerinalang" artifactId = "formatter-core" version = "@ballerinalang.version@" diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 2880a96b1..b9ad90d89 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -10,164 +10,164 @@ icon = "icon.png" license = ["Apache-2.0"] export = ["grpc", "grpc.types.duration", "grpc.types.struct", "grpc.types.timestamp", "grpc.types.wrappers", "grpc.types.any"] -[platform.java17] +[platform.java21] graalvmCompatible = true -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "grpc-native" version = "1.13.0" path = "../native/build/libs/grpc-native-1.13.0-SNAPSHOT.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "../test-utils/build/libs/grpc-test-utils-1.13.0-SNAPSHOT.jar" scope = "testOnly" -[[platform.java17.dependency]] -path = "./lib/ballerina-cli-2201.11.0-20241008-112400-81975006.jar" +[[platform.java21.dependency]] +path = "./lib/ballerina-cli-2201.10.0-20241025-103700-5c9e6a27.jar" scope = "testOnly" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "./lib/antlr4-runtime-4.5.1.wso2v1.jar" scope = "testOnly" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "http-native" version = "2.13.0" -path = "./lib/http-native-2.13.0-20241113-151000-3feb04b.jar" +path = "./lib/http-native-2.13.0-20241029-110700-30ed05b.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-common" version = "4.1.115.Final" path = "./lib/netty-common-4.1.115.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-buffer" version = "4.1.115.Final" path = "./lib/netty-buffer-4.1.115.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-transport" version = "4.1.115.Final" path = "./lib/netty-transport-4.1.115.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-resolver" version = "4.1.115.Final" path = "./lib/netty-resolver-4.1.115.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-handler" version = "4.1.115.Final" path = "./lib/netty-handler-4.1.115.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-codec-http" version = "4.1.115.Final" path = "./lib/netty-codec-http-4.1.115.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-codec" version = "4.1.115.Final" path = "./lib/netty-codec-4.1.115.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-handler-proxy" version = "4.1.115.Final" path = "./lib/netty-handler-proxy-4.1.115.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-codec-http2" version = "4.1.115.Final" path = "./lib/netty-codec-http2-4.1.115.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-transport-native-unix-common" version = "4.1.115.Final" path = "./lib/netty-transport-native-unix-common-4.1.115.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "commons.pool.wso2" artifactId = "commons-pool" version = "1.5.6.wso2v1" path = "./lib/commons-pool-1.5.6.wso2v1.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "org.bouncycastle" artifactId = "bcprov-jdk18on" version = "1.78" path = "./lib/bcprov-jdk18on-1.78.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "org.bouncycastle" artifactId = "bcpkix-jdk18on" version = "1.78" path = "./lib/bcpkix-jdk18on-1.78.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "org.bouncycastle" artifactId = "bcutil-jdk18on" version = "1.78" path = "./lib/bcutil-jdk18on-1.78.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-tcnative-classes" version = "2.0.65.Final" path = "./lib/netty-tcnative-classes-2.0.65.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-tcnative-boringssl-static" version = "2.0.65.Final" path = "./lib/netty-tcnative-boringssl-static-2.0.65.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "./lib/netty-tcnative-boringssl-static-2.0.65.Final-windows-x86_64.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "./lib/netty-tcnative-boringssl-static-2.0.65.Final-linux-aarch_64.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "./lib/netty-tcnative-boringssl-static-2.0.65.Final-linux-x86_64.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "./lib/netty-tcnative-boringssl-static-2.0.65.Final-osx-aarch_64.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "./lib/netty-tcnative-boringssl-static-2.0.65.Final-osx-x86_64.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "com.google.protobuf" artifactId = "protobuf-java" version = "3.25.5" path = "./lib/protobuf-java-3.25.5.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "com.google.api.grpc" artifactId = "proto-google-common-protos" version = "1.17.0" path = "./lib/proto-google-common-protos-1.17.0.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "org.ballerinalang" artifactId = "formatter-core" version = "2201.11.0-20241008-112400-81975006" path = "./lib/formatter-core-2201.11.0-20241008-112400-81975006.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "org.ballerinalang" artifactId = "ballerina-parser" -version = "2201.11.0-20241008-112400-81975006" -path = "./lib/ballerina-parser-2201.11.0-20241008-112400-81975006.jar" +version = "2201.10.0-20241025-103700-5c9e6a27" +path = "./lib/ballerina-parser-2201.10.0-20241025-103700-5c9e6a27.jar" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index c37fdd60a..c8d9bbcc6 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.10.0-20241025-103700-5c9e6a27" [[package]] org = "ballerina" name = "auth" -version = "2.12.0" +version = "2.12.1" dependencies = [ {org = "ballerina", name = "crypto"}, {org = "ballerina", name = "jballerina.java"}, @@ -25,18 +25,17 @@ modules = [ [[package]] org = "ballerina" name = "cache" -version = "3.8.0" +version = "3.8.1" dependencies = [ {org = "ballerina", name = "constraint"}, {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "task"}, - {org = "ballerina", name = "time"} + {org = "ballerina", name = "task"} ] [[package]] org = "ballerina" name = "constraint" -version = "1.5.0" +version = "1.5.1" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -44,7 +43,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"} @@ -66,7 +65,7 @@ dependencies = [ [[package]] org = "ballerina" name = "file" -version = "1.10.0" +version = "1.10.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, @@ -138,7 +137,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"} @@ -155,7 +154,7 @@ modules = [ [[package]] org = "ballerina" name = "jwt" -version = "2.13.0" +version = "2.13.1" dependencies = [ {org = "ballerina", name = "cache"}, {org = "ballerina", name = "crypto"}, @@ -163,8 +162,7 @@ dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "lang.int"}, {org = "ballerina", name = "lang.string"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "time"} + {org = "ballerina", name = "log"} ] modules = [ {org = "ballerina", packageName = "jwt", moduleName = "jwt"} @@ -260,7 +258,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"}, @@ -286,13 +284,12 @@ dependencies = [ [[package]] org = "ballerina" name = "oauth2" -version = "2.12.0" +version = "2.12.1" dependencies = [ {org = "ballerina", name = "cache"}, {org = "ballerina", name = "crypto"}, {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "log"}, - {org = "ballerina", name = "time"}, {org = "ballerina", name = "url"} ] modules = [ @@ -302,7 +299,7 @@ modules = [ [[package]] org = "ballerina" name = "observe" -version = "1.3.0" +version = "1.3.1" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -310,7 +307,7 @@ dependencies = [ [[package]] org = "ballerina" name = "os" -version = "1.8.0" +version = "1.8.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, @@ -320,7 +317,7 @@ dependencies = [ [[package]] org = "ballerina" name = "protobuf" -version = "1.6.1" +version = "1.6.2" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "time"} @@ -338,7 +335,7 @@ modules = [ [[package]] org = "ballerina" name = "task" -version = "2.5.0" +version = "2.5.1" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "time"} @@ -361,7 +358,7 @@ modules = [ [[package]] org = "ballerina" name = "time" -version = "2.5.0" +version = "2.5.1" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -372,7 +369,7 @@ modules = [ [[package]] org = "ballerina" name = "url" -version = "2.4.0" +version = "2.4.1" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] diff --git a/build-config/resources/Ballerina.toml b/build-config/resources/Ballerina.toml index 26392e274..7528176f4 100644 --- a/build-config/resources/Ballerina.toml +++ b/build-config/resources/Ballerina.toml @@ -10,163 +10,163 @@ icon = "icon.png" license = ["Apache-2.0"] export = ["grpc", "grpc.types.duration", "grpc.types.struct", "grpc.types.timestamp", "grpc.types.wrappers", "grpc.types.any"] -[platform.java17] +[platform.java21] graalvmCompatible = true -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "grpc-native" version = "@toml.version@" path = "../native/build/libs/grpc-native-@project.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "../test-utils/build/libs/grpc-test-utils-@project.version@.jar" scope = "testOnly" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "./lib/ballerina-cli-@ballerinalang.version@.jar" scope = "testOnly" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "./lib/antlr4-runtime-@antlr.version@.jar" scope = "testOnly" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "http-native" version = "@http.version@" path = "./lib/http-native-@http.native.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-common" version = "@netty.version@" path = "./lib/netty-common-@netty.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-buffer" version = "@netty.version@" path = "./lib/netty-buffer-@netty.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-transport" version = "@netty.version@" path = "./lib/netty-transport-@netty.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-resolver" version = "@netty.version@" path = "./lib/netty-resolver-@netty.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-handler" version = "@netty.version@" path = "./lib/netty-handler-@netty.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-codec-http" version = "@netty.version@" path = "./lib/netty-codec-http-@netty.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-codec" version = "@netty.version@" path = "./lib/netty-codec-@netty.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-handler-proxy" version = "@netty.version@" path = "./lib/netty-handler-proxy-@netty.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-codec-http2" version = "@netty.version@" path = "./lib/netty-codec-http2-@netty.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-transport-native-unix-common" version = "@netty.version@" path = "./lib/netty-transport-native-unix-common-@netty.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "commons.pool.wso2" artifactId = "commons-pool" version = "@commons.pool.version@" path = "./lib/commons-pool-@commons.pool.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "org.bouncycastle" artifactId = "bcprov-jdk18on" version = "@bouncy.castle.version@" path = "./lib/bcprov-jdk18on-@bouncy.castle.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "org.bouncycastle" artifactId = "bcpkix-jdk18on" version = "@bouncy.castle.version@" path = "./lib/bcpkix-jdk18on-@bouncy.castle.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "org.bouncycastle" artifactId = "bcutil-jdk18on" version = "@bouncy.castle.version@" path = "./lib/bcutil-jdk18on-@bouncy.castle.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-tcnative-classes" version = "@nettytcnative.version@" path = "./lib/netty-tcnative-classes-@nettytcnative.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-tcnative-boringssl-static" version = "@nettytcnative.version@" path = "./lib/netty-tcnative-boringssl-static-@nettytcnative.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "./lib/netty-tcnative-boringssl-static-@nettytcnative.version@-windows-x86_64.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "./lib/netty-tcnative-boringssl-static-@nettytcnative.version@-linux-aarch_64.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "./lib/netty-tcnative-boringssl-static-@nettytcnative.version@-linux-x86_64.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "./lib/netty-tcnative-boringssl-static-@nettytcnative.version@-osx-aarch_64.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "./lib/netty-tcnative-boringssl-static-@nettytcnative.version@-osx-x86_64.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "com.google.protobuf" artifactId = "protobuf-java" version = "@protobuf.java.version@" path = "./lib/protobuf-java-@protobuf.java.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "com.google.api.grpc" artifactId = "proto-google-common-protos" version = "@proto.google.commons.version@" path = "./lib/proto-google-common-protos-@proto.google.commons.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "org.ballerinalang" artifactId = "formatter-core" version = "@ballerinalang.version@" path = "./lib/formatter-core-@ballerinalang.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "org.ballerinalang" artifactId = "ballerina-parser" version = "@ballerinalang.version@" diff --git a/compiler-plugin-tests/build.gradle b/compiler-plugin-tests/build.gradle index 9da57aafc..5fefec7fc 100644 --- a/compiler-plugin-tests/build.gradle +++ b/compiler-plugin-tests/build.gradle @@ -50,8 +50,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 d1b08e742..e405e2cd1 100644 --- a/compiler-plugin/build.gradle +++ b/compiler-plugin/build.gradle @@ -48,8 +48,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/gradle.properties b/gradle.properties index 5541c8949..2564c3b8e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.caching=true group=io.ballerina.stdlib version=1.13.0-SNAPSHOT #dependency versions -ballerinaLangVersion=2201.11.0-20241008-112400-81975006 +ballerinaLangVersion=2201.11.0-20241117-133400-a3054b77 ballerinaTomlParserVersion=1.2.2 checkstylePluginVersion=10.12.0 commonsLang3Version=3.8.1 @@ -13,7 +13,7 @@ jknackHandlebarsVersion=4.0.6 nettyVersion=4.1.115.Final nettyTcnativeVersion=2.0.65.Final picocliVersion=4.0.1 -githubSpotbugsVersion=5.0.14 +githubSpotbugsVersion=6.0.18 githubJohnrengelmanShadowVersion=8.1.1 underCouchDownloadVersion=5.4.0 researchgateReleaseVersion=2.8.0 @@ -26,30 +26,30 @@ bouncycastleVersion=1.78 wso2CommonsPoolVersion=1.5.6.wso2v1 #stdlib dependencies -stdlibIoVersion=1.6.1 -stdlibTimeVersion=2.4.0 -stdlibUrlVersion=2.4.0 +stdlibIoVersion=1.6.2-20241112-233100-995cf5f +stdlibTimeVersion=2.6.0-20241113-073800-201b904 +stdlibUrlVersion=2.4.1-20241113-073900-335ff51 -stdlibConstraintVersion=1.5.0 -stdlibCryptoVersion=2.7.2 -stdlibLogVersion=2.10.0 -stdlibOsVersion=1.8.0 -stdlibProtobufVersion=1.6.1 -stdlibRandomVersion=1.5.0 -stdlibTaskVersion=2.5.0 +stdlibConstraintVersion=1.6.0-20241113-090900-d276ad5 +stdlibCryptoVersion=2.7.3-20241113-081400-d015a39 +stdlibLogVersion=2.10.1-20241113-120000-4577868 +stdlibOsVersion=1.8.1-20241113-122000-cca973b +stdlibProtobufVersion=1.6.2-20241113-122200-13cac06 +stdlibRandomVersion=1.5.1-20241113-122300-1bc770e +stdlibTaskVersion=2.5.1-20241113-123500-f905281 -stdlibCacheVersion=3.8.0 -stdlibFileVersion=1.10.0 -stdlibMimeVersion=2.10.0 -stdlibUuidVersion=1.8.0 +stdlibCacheVersion=3.8.1-20241113-125700-b75a1bf +stdlibFileVersion=1.10.1-20241113-151700-e1a2e38 +stdlibMimeVersion=2.10.2-20241113-154200-d953747 +stdlibUuidVersion=1.8.1-20241113-154400-443c67b -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 -stdlibHttpVersion=2.13.0-20241113-151000-3feb04b +stdlibHttpVersion=2.13.0-20241114-182900-7e9f66a # Ballerinax Observer -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/src/main/java/io/ballerina/stdlib/grpc/DataContext.java b/native/src/main/java/io/ballerina/stdlib/grpc/DataContext.java index 65247b4f8..48dcb9d3b 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/DataContext.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/DataContext.java @@ -19,16 +19,17 @@ package io.ballerina.stdlib.grpc; import io.ballerina.runtime.api.Environment; -import io.ballerina.runtime.api.Future; + +import java.util.concurrent.CompletableFuture; /** * {@code DataContext} is the wrapper to hold {@code Strand} and {@code Future}. */ public class DataContext { - private Environment environment; - private Future future; + private final Environment environment; + private final CompletableFuture future; - public DataContext(Environment env, Future future) { + public DataContext(Environment env, CompletableFuture future) { this.environment = env; this.future = future; } @@ -37,7 +38,7 @@ public Environment getEnvironment() { return environment; } - public Future getFuture() { + public CompletableFuture getFuture() { return future; } } diff --git a/native/src/main/java/io/ballerina/stdlib/grpc/GrpcConstants.java b/native/src/main/java/io/ballerina/stdlib/grpc/GrpcConstants.java index abf8f2858..f7f113261 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/GrpcConstants.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/GrpcConstants.java @@ -16,7 +16,6 @@ package io.ballerina.stdlib.grpc; import com.google.protobuf.DescriptorProtos; -import io.ballerina.runtime.api.async.StrandMetadata; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.values.BString; @@ -25,7 +24,6 @@ import java.util.Map; import java.util.Objects; -import static io.ballerina.runtime.api.constants.RuntimeConstants.BALLERINA_BUILTIN_PKG_PREFIX; import static io.ballerina.runtime.api.constants.RuntimeConstants.ORG_NAME_SEPARATOR; import static io.ballerina.stdlib.grpc.nativeimpl.ModuleUtils.getModule; @@ -37,7 +35,7 @@ public class GrpcConstants { //gRPC package name. public static final String PROTOCOL_PACKAGE_GRPC = "grpc"; - public static final String PROTOCOL_PACKAGE_VERSION_GRPC = getModule().getVersion(); + public static final String PROTOCOL_PACKAGE_VERSION_GRPC = getModule().getMajorVersion(); public static final String ORG_NAME = "ballerina"; public static final String PROTOCOL_STRUCT_PACKAGE_GRPC = ORG_NAME + ORG_NAME_SEPARATOR + "grpc:" + PROTOCOL_PACKAGE_VERSION_GRPC; @@ -240,11 +238,6 @@ public static T getKeyByValue(Map map, E value) { //Observability tag keys public static final String TAG_KEY_GRPC_ERROR_MESSAGE = "grpc.error_message"; - // Strand meta data - public static final StrandMetadata ON_MESSAGE_METADATA = - new StrandMetadata(BALLERINA_BUILTIN_PKG_PREFIX, PROTOCOL_PACKAGE_GRPC, PROTOCOL_PACKAGE_VERSION_GRPC, - ON_MESSAGE_RESOURCE); - public static final BString ENDPOINT_CONFIG_SECURESOCKET = StringUtils.fromString("secureSocket"); public static final BString SECURESOCKET_CONFIG_DISABLE_SSL = StringUtils.fromString("enable"); public static final BString SECURESOCKET_CONFIG_CERT = StringUtils.fromString("cert"); diff --git a/native/src/main/java/io/ballerina/stdlib/grpc/GrpcUtil.java b/native/src/main/java/io/ballerina/stdlib/grpc/GrpcUtil.java index 2452c0ac2..e51e311e0 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/GrpcUtil.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/GrpcUtil.java @@ -18,10 +18,12 @@ package io.ballerina.stdlib.grpc; -import io.ballerina.runtime.api.TypeTags; +import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BDecimal; +import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BString; import io.ballerina.stdlib.grpc.exception.StatusRuntimeException; @@ -40,6 +42,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; import static io.ballerina.runtime.api.constants.RuntimeConstants.BALLERINA_VERSION; @@ -473,4 +476,17 @@ public static String getTypeName(Type type) { } return type.getName(); } + + 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/grpc/Message.java b/native/src/main/java/io/ballerina/stdlib/grpc/Message.java index 5ad937b10..8b8e84190 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/Message.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/Message.java @@ -28,16 +28,16 @@ import com.google.protobuf.TimestampProto; import com.google.protobuf.WireFormat; import com.google.protobuf.WrappersProto; -import io.ballerina.runtime.api.PredefinedTypes; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.AnydataType; import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.MapType; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.types.RecordType; import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.types.UnionType; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.utils.TypeUtils; diff --git a/native/src/main/java/io/ballerina/stdlib/grpc/MessageUtils.java b/native/src/main/java/io/ballerina/stdlib/grpc/MessageUtils.java index b6f1042ff..77583f135 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/MessageUtils.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/MessageUtils.java @@ -17,15 +17,15 @@ import com.google.protobuf.DescriptorProtos; import com.google.protobuf.Descriptors; -import io.ballerina.runtime.api.PredefinedTypes; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.MethodType; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.types.RecordType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BMap; diff --git a/native/src/main/java/io/ballerina/stdlib/grpc/ServiceDefinition.java b/native/src/main/java/io/ballerina/stdlib/grpc/ServiceDefinition.java index 6d5da9e67..4fc452398 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/ServiceDefinition.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/ServiceDefinition.java @@ -21,15 +21,15 @@ import com.google.protobuf.DescriptorProtos; import com.google.protobuf.Descriptors; import com.google.protobuf.InvalidProtocolBufferException; -import io.ballerina.runtime.api.PredefinedTypes; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.types.ErrorType; import io.ballerina.runtime.api.types.MethodType; import io.ballerina.runtime.api.types.NullType; import io.ballerina.runtime.api.types.ObjectType; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.types.RecordType; import io.ballerina.runtime.api.types.StreamType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.types.UnionType; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.values.BMap; diff --git a/native/src/main/java/io/ballerina/stdlib/grpc/ServicesBuilderUtils.java b/native/src/main/java/io/ballerina/stdlib/grpc/ServicesBuilderUtils.java index bfa14ad86..e5887a3b5 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/ServicesBuilderUtils.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/ServicesBuilderUtils.java @@ -22,7 +22,6 @@ import com.google.protobuf.Descriptors; import com.google.protobuf.InvalidProtocolBufferException; import io.ballerina.runtime.api.Module; -import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.Runtime; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; @@ -30,6 +29,7 @@ import io.ballerina.runtime.api.types.NullType; import io.ballerina.runtime.api.types.ObjectType; import io.ballerina.runtime.api.types.Parameter; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.types.RecordType; import io.ballerina.runtime.api.types.StreamType; import io.ballerina.runtime.api.types.Type; @@ -239,7 +239,7 @@ private static com.google.protobuf.Descriptors.FileDescriptor getDescriptor(Obje if (descriptorData == null) { descriptorData = annotationMap.getStringValue(StringUtils.fromString("descriptor")); } - BMap descMap = (BMap) annotationMap.getMapValue( + BMap descMap = (BMap) annotationMap.getMapValue( StringUtils.fromString("descMap")); return getFileDescriptor(descriptorData, descMap); } catch (IOException | Descriptors.DescriptorValidationException e) { @@ -258,9 +258,9 @@ private static com.google.protobuf.Descriptors.FileDescriptor getDescriptorFromS } else if (type.getFields().containsKey("value")) { descriptorData = service.getStringValue(StringUtils.fromString("value")); } - BMap descMap = null; + BMap descMap = null; if (type.getFields().containsKey("descMap")) { - descMap = (BMap) service.getMapValue(StringUtils.fromString("descMap")); + descMap = service.getMapValue(StringUtils.fromString("descMap")); } if (descriptorData == null || descMap == null) { return null; @@ -273,8 +273,7 @@ private static com.google.protobuf.Descriptors.FileDescriptor getDescriptorFromS } - private static Descriptors.FileDescriptor getFileDescriptor( - BString descriptorData, BMap descMap) + private static Descriptors.FileDescriptor getFileDescriptor(BString descriptorData, BMap descMap) throws InvalidProtocolBufferException, Descriptors.DescriptorValidationException, GrpcServerException { byte[] descriptor = hexStringToByteArray(descriptorData.getValue()); @@ -291,14 +290,15 @@ private static Descriptors.FileDescriptor getFileDescriptor( List fileDescriptors = new ArrayList<>(); for (ByteString dependency : descriptorProto.getDependencyList().asByteStringList()) { String dependencyKey = dependency.toStringUtf8(); - if (descMap == null || descMap.size() == 0) { + if (descMap == null || descMap.isEmpty()) { Descriptors.FileDescriptor dependentDescriptor = StandardDescriptorBuilder.getFileDescriptor (dependencyKey); if (dependentDescriptor != null) { fileDescriptors.add(dependentDescriptor); } } else if (descMap.containsKey(StringUtils.fromString(dependencyKey))) { - fileDescriptors.add(getFileDescriptor(descMap.get(StringUtils.fromString(dependencyKey)), descMap)); + fileDescriptors.add(getFileDescriptor((BString) descMap.get(StringUtils.fromString(dependencyKey)), + descMap)); } } return Descriptors.FileDescriptor.buildFrom(descriptorProto, diff --git a/native/src/main/java/io/ballerina/stdlib/grpc/callback/AbstractCallableUnitCallBack.java b/native/src/main/java/io/ballerina/stdlib/grpc/callback/AbstractCallableUnitCallBack.java index 22c920304..f38e7330a 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/callback/AbstractCallableUnitCallBack.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/callback/AbstractCallableUnitCallBack.java @@ -18,7 +18,6 @@ package io.ballerina.stdlib.grpc.callback; -import io.ballerina.runtime.api.async.Callback; import io.ballerina.runtime.api.values.BError; import io.ballerina.stdlib.grpc.GrpcConstants; import io.ballerina.stdlib.grpc.Message; @@ -26,26 +25,12 @@ import io.ballerina.stdlib.grpc.StreamObserver; import io.ballerina.stdlib.grpc.exception.StatusRuntimeException; -import java.util.concurrent.Semaphore; - /** * Abstract call back class registered for gRPC service in B7a executor. * * @since 0.995.0 */ -public class AbstractCallableUnitCallBack implements Callback { - - public final Semaphore available = new Semaphore(1, true); - - @Override - public void notifySuccess(Object o) { - available.release(); - } - - @Override - public void notifyFailure(io.ballerina.runtime.api.values.BError error) { - available.release(); - } +public class AbstractCallableUnitCallBack { /** * Handles failures in GRPC callable unit callback. diff --git a/native/src/main/java/io/ballerina/stdlib/grpc/callback/StreamingCallableUnitCallBack.java b/native/src/main/java/io/ballerina/stdlib/grpc/callback/StreamingCallableUnitCallBack.java index 7099f1283..43c9bc02e 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/callback/StreamingCallableUnitCallBack.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/callback/StreamingCallableUnitCallBack.java @@ -18,8 +18,8 @@ package io.ballerina.stdlib.grpc.callback; import com.google.protobuf.Descriptors; -import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.Runtime; +import io.ballerina.runtime.api.concurrent.StrandMetadata; import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.types.ObjectType; import io.ballerina.runtime.api.utils.StringUtils; @@ -56,15 +56,14 @@ public class StreamingCallableUnitCallBack extends AbstractCallableUnitCallBack private static final Logger LOG = LoggerFactory.getLogger(StreamingCallableUnitCallBack.class); - private Runtime runtime; - private StreamObserver responseSender; - private boolean emptyResponse; - private Descriptors.Descriptor outputType; - private ObserverContext observerContext; + private final Runtime runtime; + private final StreamObserver responseSender; + private final boolean emptyResponse; + private final Descriptors.Descriptor outputType; + private final ObserverContext observerContext; public StreamingCallableUnitCallBack(Runtime runtime, StreamObserver responseSender, boolean isEmptyResponse, Descriptors.Descriptor outputType, ObserverContext context) { - available.acquireUninterruptibly(); this.runtime = runtime; this.responseSender = responseSender; this.emptyResponse = isEmptyResponse; @@ -72,9 +71,7 @@ public StreamingCallableUnitCallBack(Runtime runtime, StreamObserver responseSen this.outputType = outputType; } - @Override public void notifySuccess(Object response) { - super.notifySuccess(response); // check whether connection is closed. if (responseSender instanceof ServerCallHandler.ServerCallStreamObserver) { ServerCallHandler.ServerCallStreamObserver serverCallStreamObserver = (ServerCallHandler @@ -112,17 +109,21 @@ public void notifySuccess(Object response) { ReturnStreamUnitCallBack returnStreamUnitCallBack = new ReturnStreamUnitCallBack( runtime, responseSender, outputType, bObject, headers); ObjectType serviceObjectType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(bObject)); - if (serviceObjectType.isIsolated() && serviceObjectType.isIsolated(STREAMING_NEXT_FUNCTION)) { - runtime.invokeMethodAsyncConcurrently(bObject, STREAMING_NEXT_FUNCTION, null, null, - returnStreamUnitCallBack, null, PredefinedTypes.TYPE_NULL); - } else { - runtime.invokeMethodAsyncSequentially(bObject, STREAMING_NEXT_FUNCTION, null, null, - returnStreamUnitCallBack, null, PredefinedTypes.TYPE_NULL); - } + Thread.startVirtualThread(() -> { + try { + boolean isConcurrentSafe = serviceObjectType.isIsolated() && + serviceObjectType.isIsolated(STREAMING_NEXT_FUNCTION); + StrandMetadata metadata = new StrandMetadata(isConcurrentSafe, null); + Object result = runtime.callMethod(bObject, STREAMING_NEXT_FUNCTION, metadata); + returnStreamUnitCallBack.notifySuccess(result); + } catch (BError error) { + returnStreamUnitCallBack.notifyFailure(error); + } + }); } else { // If content is null and remote function doesn't return empty response means. response is already sent // to client via caller object, but connection is not closed already by calling complete function. - // Hence closing the connection. + // Hence, closing the connection. if (content == null) { if (this.emptyResponse) { Message responseMessage = new Message(GrpcConstants.EMPTY_DATATYPE_NAME, null); @@ -138,7 +139,6 @@ public void notifySuccess(Object response) { } } - @Override public void notifyFailure(io.ballerina.runtime.api.values.BError error) { if (responseSender instanceof ServerCallHandler.ServerCallStreamObserver) { ServerCallHandler.ServerCallStreamObserver serverCallStreamObserver = (ServerCallHandler @@ -165,7 +165,6 @@ public void notifyFailure(io.ballerina.runtime.api.values.BError error) { if (observerContext != null) { observerContext.addProperty(PROPERTY_KEY_HTTP_STATUS_CODE, HttpResponseStatus.INTERNAL_SERVER_ERROR.code()); } - super.notifyFailure(error); if (isPanic) { System.exit(1); } @@ -175,11 +174,11 @@ public void notifyFailure(io.ballerina.runtime.api.values.BError error) { * Call back class registered to send returned stream from a remote function. * */ - public class ReturnStreamUnitCallBack extends AbstractCallableUnitCallBack { - private StreamObserver requestSender; - private Descriptors.Descriptor outputType; - private Runtime runtime; - private BObject bObject; + public static class ReturnStreamUnitCallBack extends AbstractCallableUnitCallBack { + private final StreamObserver requestSender; + private final Descriptors.Descriptor outputType; + private final Runtime runtime; + private final BObject bObject; private HttpHeaders headers; public ReturnStreamUnitCallBack(Runtime runtime, StreamObserver requestSender, @@ -191,7 +190,6 @@ public ReturnStreamUnitCallBack(Runtime runtime, StreamObserver requestSender, this.headers = headers; } - @Override public void notifySuccess(Object response) { if (response != null) { Message msg; @@ -207,22 +205,24 @@ public void notifySuccess(Object response) { } requestSender.onNext(msg); ObjectType serviceObjectType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(bObject)); - if (serviceObjectType.isIsolated() && serviceObjectType.isIsolated(STREAMING_NEXT_FUNCTION)) { - runtime.invokeMethodAsyncConcurrently(bObject, STREAMING_NEXT_FUNCTION, null, - null, this, null, PredefinedTypes.TYPE_NULL); - } else { - runtime.invokeMethodAsyncSequentially(bObject, STREAMING_NEXT_FUNCTION, null, - null, this, null, PredefinedTypes.TYPE_NULL); - } + Thread.startVirtualThread(() -> { + try { + boolean isConcurrentSafe = serviceObjectType.isIsolated() && + serviceObjectType.isIsolated(STREAMING_NEXT_FUNCTION); + StrandMetadata metadata = new StrandMetadata(isConcurrentSafe, null); + Object result = runtime.callMethod(bObject, STREAMING_NEXT_FUNCTION, metadata); + this.notifySuccess(result); + } catch (BError error) { + this.notifyFailure(error); + } + }); } else { requestSender.onCompleted(); } - } - @Override public void notifyFailure(BError error) { - super.notifyFailure(error); + } } } diff --git a/native/src/main/java/io/ballerina/stdlib/grpc/callback/UnaryCallableUnitCallBack.java b/native/src/main/java/io/ballerina/stdlib/grpc/callback/UnaryCallableUnitCallBack.java index 403288795..aba640409 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/callback/UnaryCallableUnitCallBack.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/callback/UnaryCallableUnitCallBack.java @@ -18,8 +18,8 @@ package io.ballerina.stdlib.grpc.callback; import com.google.protobuf.Descriptors; -import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.Runtime; +import io.ballerina.runtime.api.concurrent.StrandMetadata; import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.types.ObjectType; import io.ballerina.runtime.api.utils.StringUtils; @@ -56,11 +56,11 @@ public class UnaryCallableUnitCallBack extends AbstractCallableUnitCallBack { private static final Logger LOG = LoggerFactory.getLogger(UnaryCallableUnitCallBack.class); - private Runtime runtime; - private StreamObserver requestSender; - private boolean emptyResponse; - private Descriptors.Descriptor outputType; - private ObserverContext observerContext; + private final Runtime runtime; + private final StreamObserver requestSender; + private final boolean emptyResponse; + private final Descriptors.Descriptor outputType; + private final ObserverContext observerContext; public UnaryCallableUnitCallBack(Runtime runtime, StreamObserver requestSender, boolean isEmptyResponse, @@ -72,9 +72,7 @@ public UnaryCallableUnitCallBack(Runtime runtime, StreamObserver requestSender, this.observerContext = context; } - @Override public void notifySuccess(Object response) { - super.notifySuccess(response); // check whether connection is closed. if (requestSender instanceof ServerCallHandler.ServerCallStreamObserver) { ServerCallHandler.ServerCallStreamObserver serverCallStreamObserver = (ServerCallHandler @@ -120,17 +118,21 @@ public void notifySuccess(Object response) { ReturnStreamUnitCallBack returnStreamUnitCallBack = new ReturnStreamUnitCallBack( runtime, requestSender, outputType, bObject, headers); ObjectType serviceObjectType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(bObject)); - if (serviceObjectType.isIsolated() && serviceObjectType.isIsolated(STREAMING_NEXT_FUNCTION)) { - runtime.invokeMethodAsyncConcurrently(bObject, STREAMING_NEXT_FUNCTION, null, null, - returnStreamUnitCallBack, null, PredefinedTypes.TYPE_NULL); - } else { - runtime.invokeMethodAsyncSequentially(bObject, STREAMING_NEXT_FUNCTION, null, null, - returnStreamUnitCallBack, null, PredefinedTypes.TYPE_NULL); - } + Thread.startVirtualThread(() -> { + try { + boolean isConcurrentSafe = serviceObjectType.isIsolated() && + serviceObjectType.isIsolated(STREAMING_NEXT_FUNCTION); + StrandMetadata metadata = new StrandMetadata(isConcurrentSafe, null); + Object result = runtime.callMethod(bObject, STREAMING_NEXT_FUNCTION, metadata); + returnStreamUnitCallBack.notifySuccess(result); + } catch (BError error) { + returnStreamUnitCallBack.notifyFailure(error); + } + }); } else { // If content is null and remote function doesn't return empty response means. response is already sent // to client via caller object, but connection is not closed already by calling complete function. - // Hence closing the connection. + // Hence, closing the connection. if (content == null) { requestSender.onCompleted(); } else { @@ -151,7 +153,6 @@ public void notifySuccess(Object response) { } } - @Override public void notifyFailure(BError error) { if (requestSender instanceof ServerCallHandler.ServerCallStreamObserver) { ServerCallHandler.ServerCallStreamObserver serverCallStreamObserver = (ServerCallHandler @@ -176,7 +177,6 @@ public void notifyFailure(BError error) { if (observerContext != null) { observerContext.addProperty(PROPERTY_KEY_HTTP_STATUS_CODE, HttpResponseStatus.INTERNAL_SERVER_ERROR.code()); } - super.notifyFailure(error); if (isPanic) { System.exit(1); } @@ -187,10 +187,10 @@ public void notifyFailure(BError error) { * */ public class ReturnStreamUnitCallBack extends AbstractCallableUnitCallBack { - private StreamObserver requestSender; - private Descriptors.Descriptor outputType; - private Runtime runtime; - private BObject bObject; + private final StreamObserver requestSender; + private final Descriptors.Descriptor outputType; + private final Runtime runtime; + private final BObject bObject; private HttpHeaders headers; public ReturnStreamUnitCallBack(Runtime runtime, StreamObserver requestSender, @@ -202,7 +202,6 @@ public ReturnStreamUnitCallBack(Runtime runtime, StreamObserver requestSender, this.headers = headers; } - @Override public void notifySuccess(Object response) { if (response != null) { Message msg; @@ -218,22 +217,23 @@ public void notifySuccess(Object response) { } requestSender.onNext(msg); ObjectType serviceObjectType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(bObject)); - if (serviceObjectType.isIsolated() && serviceObjectType.isIsolated(STREAMING_NEXT_FUNCTION)) { - runtime.invokeMethodAsyncConcurrently(bObject, STREAMING_NEXT_FUNCTION, null, null, - this, null, PredefinedTypes.TYPE_NULL); - } else { - runtime.invokeMethodAsyncSequentially(bObject, STREAMING_NEXT_FUNCTION, null, null, - this, null, PredefinedTypes.TYPE_NULL); - } + Thread.startVirtualThread(() -> { + try { + boolean isConcurrentSafe = serviceObjectType.isIsolated() && + serviceObjectType.isIsolated(STREAMING_NEXT_FUNCTION); + StrandMetadata metadata = new StrandMetadata(isConcurrentSafe, null); + Object result = runtime.callMethod(bObject, STREAMING_NEXT_FUNCTION, metadata); + this.notifySuccess(result); + } catch (BError error) { + this.notifyFailure(error); + } + }); } else { requestSender.onCompleted(); } - } - @Override public void notifyFailure(BError error) { - super.notifyFailure(error); } } } diff --git a/native/src/main/java/io/ballerina/stdlib/grpc/listener/ServerCallHandler.java b/native/src/main/java/io/ballerina/stdlib/grpc/listener/ServerCallHandler.java index 857639558..41f059e56 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/listener/ServerCallHandler.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/listener/ServerCallHandler.java @@ -18,14 +18,15 @@ package io.ballerina.stdlib.grpc.listener; import com.google.protobuf.Descriptors; -import io.ballerina.runtime.api.PredefinedTypes; -import io.ballerina.runtime.api.TypeTags; -import io.ballerina.runtime.api.async.Callback; +import io.ballerina.runtime.api.concurrent.StrandMetadata; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.ObjectType; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.utils.TypeUtils; +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.observability.ObservabilityConstants; @@ -173,8 +174,9 @@ private boolean isEmptyResponse() { void onMessageInvoke(ServiceResource resource, Message request, StreamObserver responseObserver, ObserverContext context) { - Callback callback = new UnaryCallableUnitCallBack(resource.getRuntime(), responseObserver, isEmptyResponse(), - this.methodDescriptor.getOutputType(), context); + UnaryCallableUnitCallBack callback = + new UnaryCallableUnitCallBack(resource.getRuntime(), responseObserver, isEmptyResponse(), + this.methodDescriptor.getOutputType(), context); Object requestParam = request != null ? request.getbMessage() : null; HttpHeaders headers = request != null ? request.getHeaders() : null; Object[] requestParams = computeResourceParams(resource, requestParam, headers, responseObserver); @@ -186,29 +188,23 @@ void onMessageInvoke(ServiceResource resource, Message request, StreamObserver r String functionName = resource.getFunctionName(); ObjectType serviceObjectType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(resource.getService())); - - boolean isEmpty = isEmpty(requestParams); - if (isEmpty) { - if (serviceObjectType.isIsolated() && serviceObjectType.isIsolated(functionName)) { - resource.getRuntime().invokeMethodAsyncConcurrently(resource.getService(), functionName, null, - GrpcConstants.ON_MESSAGE_METADATA, callback, properties, - resource.getReturnType()); - } else { - resource.getRuntime().invokeMethodAsyncSequentially(resource.getService(), functionName, null, - GrpcConstants.ON_MESSAGE_METADATA, callback, properties, - resource.getReturnType()); - } - } else { - if (serviceObjectType.isIsolated() && serviceObjectType.isIsolated(functionName)) { - resource.getRuntime().invokeMethodAsyncConcurrently(resource.getService(), functionName, null, - GrpcConstants.ON_MESSAGE_METADATA, callback, properties, - resource.getReturnType(), requestParams); - } else { - resource.getRuntime().invokeMethodAsyncSequentially(resource.getService(), functionName, null, - GrpcConstants.ON_MESSAGE_METADATA, callback, properties, - resource.getReturnType(), requestParams); + Thread.startVirtualThread(() -> { + try { + boolean isEmpty = isEmpty(requestParams); + boolean isConcurrentSafe = serviceObjectType.isIsolated() && serviceObjectType.isIsolated(functionName); + StrandMetadata metadata = new StrandMetadata(isConcurrentSafe, properties); + Object result; + if (isEmpty) { + result = resource.getRuntime().callMethod(resource.getService(), functionName, metadata); + } else { + result = resource.getRuntime().callMethod(resource.getService(), functionName, metadata, + requestParams); + } + callback.notifySuccess(result); + } catch (BError error) { + callback.notifyFailure(error); } - } + }); } Boolean isEmpty(Object[] requestParams) { @@ -230,12 +226,11 @@ Object[] computeResourceParams(ServiceResource resource, Object requestParam, Ht int i = 0; if ((signatureParamSize >= 1) && (signatureParams.get(0).getTag() == TypeTags.OBJECT_TYPE_TAG) && signatureParams.get(0).getName().contains(CALLER_TYPE)) { - paramValues = new Object[signatureParams.size() * 2]; + paramValues = new Object[signatureParams.size()]; paramValues[i] = getConnectionParameter(resource, responseObserver); - paramValues[i + 1] = true; - i = i + 2; + i = i + 1; } else { - paramValues = new Object[2]; + paramValues = new Object[1]; } if (resource.isHeaderRequired()) { BMap headerValues = MessageUtils.createHeaderMap(headers); @@ -268,11 +263,9 @@ Object[] computeResourceParams(ServiceResource resource, Object requestParam, Ht MessageUtils.getContextTypeName(resource.getRpcInputType()), valueMap); } paramValues[i] = contentContext; - paramValues[i + 1] = true; } } else if (requestParam != null) { paramValues[i] = requestParam; - paramValues[i + 1] = true; } return paramValues; } diff --git a/native/src/main/java/io/ballerina/stdlib/grpc/listener/StreamingServerCallHandler.java b/native/src/main/java/io/ballerina/stdlib/grpc/listener/StreamingServerCallHandler.java index e63d8093b..76218f136 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/listener/StreamingServerCallHandler.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/listener/StreamingServerCallHandler.java @@ -19,11 +19,13 @@ package io.ballerina.stdlib.grpc.listener; import com.google.protobuf.Descriptors; +import io.ballerina.runtime.api.concurrent.StrandMetadata; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.ObjectType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.TypeUtils; +import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BStream; import io.ballerina.runtime.observability.ObservabilityConstants; @@ -123,7 +125,7 @@ private static final class StreamingServerCallListener implements Listener { private final ServerCallStreamObserver responseObserver; private boolean halfClosed = false; - // Non private to avoid synthetic class + // Non-private to avoid synthetic class StreamingServerCallListener( StreamObserver requestObserver, ServerCallStreamObserver responseObserver) { @@ -185,15 +187,17 @@ void onStreamInvoke(ServiceResource resource, BStream requestStream, HttpHeaders responseObserver, isEmptyResponse(), this.methodDescriptor.getOutputType(), context); String functionName = resource.getFunctionName(); - ObjectType serviceObjectType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(resource.getService())); - if (serviceObjectType.isIsolated() && serviceObjectType.isIsolated(functionName)) { - resource.getRuntime().invokeMethodAsyncConcurrently(resource.getService(), resource.getFunctionName(), null, - GrpcConstants.ON_MESSAGE_METADATA, callback, properties, - resource.getReturnType(), requestParams); - } else { - resource.getRuntime().invokeMethodAsyncSequentially(resource.getService(), resource.getFunctionName(), null, - GrpcConstants.ON_MESSAGE_METADATA, callback, properties, - resource.getReturnType(), requestParams); - } + BObject service = resource.getService(); + ObjectType serviceObjectType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(service)); + Thread.startVirtualThread(() -> { + try { + boolean isConcurrentSafe = serviceObjectType.isIsolated() && serviceObjectType.isIsolated(functionName); + StrandMetadata metadata = new StrandMetadata(isConcurrentSafe, properties); + Object result = resource.getRuntime().callMethod(service, functionName, metadata, requestParams); + callback.notifySuccess(result); + } catch (BError error) { + callback.notifyFailure(error); + } + }); } } diff --git a/native/src/main/java/io/ballerina/stdlib/grpc/nativeimpl/client/FunctionUtils.java b/native/src/main/java/io/ballerina/stdlib/grpc/nativeimpl/client/FunctionUtils.java index c00f1bf3d..a1f58d638 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/nativeimpl/client/FunctionUtils.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/nativeimpl/client/FunctionUtils.java @@ -52,6 +52,7 @@ import java.net.URL; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.CompletableFuture; import static io.ballerina.stdlib.grpc.GrpcConstants.CLIENT_CONNECTOR; import static io.ballerina.stdlib.grpc.GrpcConstants.CONFIG; @@ -60,6 +61,7 @@ import static io.ballerina.stdlib.grpc.GrpcConstants.METHOD_DESCRIPTORS; import static io.ballerina.stdlib.grpc.GrpcConstants.SERVICE_STUB; import static io.ballerina.stdlib.grpc.GrpcUtil.getConnectionManager; +import static io.ballerina.stdlib.grpc.GrpcUtil.getResult; import static io.ballerina.stdlib.grpc.GrpcUtil.populatePoolingConfig; import static io.ballerina.stdlib.grpc.GrpcUtil.populateSenderConfigurations; import static io.ballerina.stdlib.grpc.MessageUtils.convertToHttpHeaders; @@ -230,7 +232,6 @@ public static Object externExecuteSimpleRPC(Environment env, BObject clientEndpo HttpHeaders headers = convertToHttpHeaders(headerValues); requestMsg.setHeaders(headers); Stub stub = (Stub) connectionStub; - DataContext dataContext = null; Map messageSizeMap = new HashMap<>(); messageSizeMap.put(MAX_INBOUND_MESSAGE_SIZE, (Long) clientEndpoint.getMapValue(CONFIG) @@ -238,24 +239,24 @@ public static Object externExecuteSimpleRPC(Environment env, BObject clientEndpo try { MethodDescriptor.MethodType methodType = getMethodType(methodDescriptor); if (methodType.equals(MethodDescriptor.MethodType.UNARY)) { - - dataContext = new DataContext(env, env.markAsync()); - stub.executeUnary(requestMsg, methodDescriptors.get(methodName.getValue()), - dataContext, messageSizeMap); + return env.yieldAndRun(() -> { + try { + CompletableFuture future = new CompletableFuture<>(); + DataContext dataContext = new DataContext(env, future); + stub.executeUnary(requestMsg, methodDescriptors.get(methodName.getValue()), + dataContext, messageSizeMap); + return getResult(future); + } catch (Exception e) { + return notifyErrorReply(INTERNAL, "gRPC Client Connector Error :" + e.getMessage()); + } + }); } else { return notifyErrorReply(INTERNAL, "Error while executing the client call. Method type " + methodType.name() + " not supported"); } } catch (Exception e) { - try { - if (dataContext != null) { - dataContext.getFuture().complete(e); - } - } finally { - return notifyErrorReply(INTERNAL, "gRPC Client Connector Error :" + e.getMessage()); - } + return notifyErrorReply(INTERNAL, "gRPC Client Connector Error :" + e.getMessage()); } - return null; } /** @@ -307,22 +308,25 @@ public static Object externExecuteServerStreaming(Environment env, BObject clien HttpHeaders headers = convertToHttpHeaders(headerValues); requestMsg.setHeaders(headers); Stub stub = (Stub) connectionStub; - DataContext dataContext = null; Map messageSizeMap = new HashMap<>(); messageSizeMap.put(MAX_INBOUND_MESSAGE_SIZE, (Long) clientEndpoint.getMapValue(CONFIG) .get(StringUtils.fromString((MAX_INBOUND_MESSAGE_SIZE)))); try { - dataContext = new DataContext(env, env.markAsync()); - stub.executeServerStreaming(requestMsg, methodDescriptors.get(methodName.getValue()), - dataContext, messageSizeMap); + return env.yieldAndRun(() -> { + try { + CompletableFuture future = new CompletableFuture<>(); + DataContext dataContext = new DataContext(env, future); + stub.executeServerStreaming(requestMsg, methodDescriptors.get(methodName.getValue()), + dataContext, messageSizeMap); + return getResult(future); + } catch (Exception e) { + return notifyErrorReply(INTERNAL, "gRPC Client Connector Error :" + e.getMessage()); + } + }); } catch (Exception e) { - if (dataContext != null) { - dataContext.getFuture().complete(e); - } return notifyErrorReply(INTERNAL, "gRPC Client Connector Error :" + e.getMessage()); } - return null; } /** diff --git a/native/src/main/java/io/ballerina/stdlib/grpc/nativeimpl/serviceendpoint/FunctionUtils.java b/native/src/main/java/io/ballerina/stdlib/grpc/nativeimpl/serviceendpoint/FunctionUtils.java index e7201b8af..6ac0a4f99 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/nativeimpl/serviceendpoint/FunctionUtils.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/nativeimpl/serviceendpoint/FunctionUtils.java @@ -20,10 +20,10 @@ import com.google.protobuf.Descriptors; import io.ballerina.runtime.api.Environment; -import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.ObjectType; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; @@ -209,26 +209,28 @@ public static Object immediateStop(BObject serverEndpoint) { return null; } - public static Object nextResult(BObject streamIterator) { - - BlockingQueue messageQueue = (BlockingQueue) streamIterator.getNativeData(GrpcConstants.MESSAGE_QUEUE); - try { - Message nextMessage = (Message) messageQueue.take(); - if (nextMessage.getHeaders() != null) { - streamIterator.addNativeData(GrpcConstants.HEADERS, - MessageUtils.createHeaderMap(nextMessage.getHeaders())); - } - if (nextMessage.isError()) { - return MessageUtils.getConnectorError(nextMessage.getError()); - } else { - return nextMessage.getbMessage(); + public static Object nextResult(Environment env, BObject streamIterator) { + return env.yieldAndRun(() -> { + BlockingQueue messageQueue = + (BlockingQueue) streamIterator.getNativeData(GrpcConstants.MESSAGE_QUEUE); + try { + Message nextMessage = (Message) messageQueue.take(); + if (nextMessage.getHeaders() != null) { + streamIterator.addNativeData(GrpcConstants.HEADERS, + MessageUtils.createHeaderMap(nextMessage.getHeaders())); + } + if (nextMessage.isError()) { + return MessageUtils.getConnectorError(nextMessage.getError()); + } else { + return nextMessage.getbMessage(); + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + String message = "Internal error occurred. The current thread got interrupted"; + throw MessageUtils.getConnectorError(new StatusRuntimeException(Status + .fromCode(Status.Code.INTERNAL.toStatus().getCode()).withDescription(message))); } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - String message = "Internal error occurred. The current thread got interrupted"; - throw MessageUtils.getConnectorError(new StatusRuntimeException(Status - .fromCode(Status.Code.INTERNAL.toStatus().getCode()).withDescription(message))); - } + }); } public static Object closeStream(Environment env, BObject streamIterator) { diff --git a/native/src/main/java/io/ballerina/stdlib/grpc/nativeimpl/streamingclient/FunctionUtils.java b/native/src/main/java/io/ballerina/stdlib/grpc/nativeimpl/streamingclient/FunctionUtils.java index 6ccda385f..2d2a68e1b 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/nativeimpl/streamingclient/FunctionUtils.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/nativeimpl/streamingclient/FunctionUtils.java @@ -20,9 +20,9 @@ import com.google.protobuf.Descriptors; import io.ballerina.runtime.api.Environment; -import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BMap; @@ -175,7 +175,7 @@ public static Object externIsBidirectional(BObject streamingConnection) { * @param streamingConnection streaming connection instance. * @return In streaming scenarios, return an `anydata`. */ - public static Object externReceive(BObject streamingConnection) { + public static Object externReceive(Environment env, BObject streamingConnection) { Boolean isStreamCancelled = (Boolean) streamingConnection.getNativeData(GrpcConstants.IS_STREAM_CANCELLED); if (isStreamCancelled != null && isStreamCancelled) { @@ -200,14 +200,21 @@ public static Object externReceive(BObject streamingConnection) { return ValueCreator.createStreamValue(TypeCreator.createStreamType(PredefinedTypes.TYPE_ANYDATA), streamIterator); } else { - Message nextMessage = (Message) messageQueue.take(); - streamingConnection.addNativeData(GrpcConstants.HEADERS, - MessageUtils.createHeaderMap(nextMessage.getHeaders())); - if (nextMessage.isError()) { - return MessageUtils.getConnectorError(nextMessage.getError()); - } else { - return nextMessage.getbMessage(); - } + return env.yieldAndRun(() -> { + try { + Message nextMessage = (Message) messageQueue.take(); + streamingConnection.addNativeData(GrpcConstants.HEADERS, + MessageUtils.createHeaderMap(nextMessage.getHeaders())); + if (nextMessage.isError()) { + return MessageUtils.getConnectorError(nextMessage.getError()); + } else { + return nextMessage.getbMessage(); + } + } catch (Exception e) { + LOG.error("Error while sending request message to server.", e); + return MessageUtils.getConnectorError(e); + } + }); } } catch (Exception e) { LOG.error("Error while sending request message to server.", e); diff --git a/native/src/main/java/io/ballerina/stdlib/grpc/stubs/Stub.java b/native/src/main/java/io/ballerina/stdlib/grpc/stubs/Stub.java index 879c59a90..1bb7d753c 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/stubs/Stub.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/stubs/Stub.java @@ -17,9 +17,9 @@ */ package io.ballerina.stdlib.grpc.stubs; -import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; diff --git a/native/src/test/java/io/ballerina/stdlib/grpc/nativeimpl/serviceendpoint/FunctionUtilsTest.java b/native/src/test/java/io/ballerina/stdlib/grpc/nativeimpl/serviceendpoint/FunctionUtilsTest.java index 07a8d26d1..f4a138ec1 100644 --- a/native/src/test/java/io/ballerina/stdlib/grpc/nativeimpl/serviceendpoint/FunctionUtilsTest.java +++ b/native/src/test/java/io/ballerina/stdlib/grpc/nativeimpl/serviceendpoint/FunctionUtilsTest.java @@ -20,9 +20,9 @@ import com.google.protobuf.DescriptorProtos; import com.google.protobuf.Descriptors; -import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BMap; diff --git a/test-utils/src/main/java/io/ballerina/stdlib/grpc/testutils/NativeTestUtils.java b/test-utils/src/main/java/io/ballerina/stdlib/grpc/testutils/NativeTestUtils.java index c33f0cccd..bc5b056ea 100644 --- a/test-utils/src/main/java/io/ballerina/stdlib/grpc/testutils/NativeTestUtils.java +++ b/test-utils/src/main/java/io/ballerina/stdlib/grpc/testutils/NativeTestUtils.java @@ -204,7 +204,7 @@ public static Object externInvokeRegisterErrorCase(BObject serviceEndpoint) { return externRegister(null, serviceEndpoint, null, null); } - public static Object externInvokeNextResultErrorCase(BObject streamIterator) { + public static Object externInvokeNextResultErrorCase(Environment env, BObject streamIterator) { BlockingQueue b = new BlockingQueue() { @Override public boolean add(Object o) { @@ -305,7 +305,7 @@ public void clear() {} }; streamIterator.addNativeData(GrpcConstants.MESSAGE_QUEUE, b); try { - nextResult(streamIterator); + nextResult(env, streamIterator); } catch (Exception e) { return e; }