diff --git a/.github/workflows/build-timestamped-master.yml b/.github/workflows/build-timestamped-master.yml index 5402145f2..ff3e8a20d 100644 --- a/.github/workflows/build-timestamped-master.yml +++ b/.github/workflows/build-timestamped-master.yml @@ -14,5 +14,5 @@ jobs: call_workflow: name: Run Build Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/build-timestamp-master-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/build-timestamp-master-template.yml@java21 secrets: inherit diff --git a/.github/workflows/build-with-bal-test-graalvm.yml b/.github/workflows/build-with-bal-test-graalvm.yml index 313df8f04..1718f0c74 100644 --- a/.github/workflows/build-with-bal-test-graalvm.yml +++ b/.github/workflows/build-with-bal-test-graalvm.yml @@ -30,7 +30,7 @@ jobs: call_stdlib_workflow: name: Run StdLib Workflow if: ${{ github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'ballerina-platform') }} - uses: ballerina-platform/ballerina-library/.github/workflows/build-with-bal-test-graalvm-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/build-with-bal-test-graalvm-template.yml@java21 with: lang_tag: ${{ inputs.lang_tag }} lang_version: ${{ inputs.lang_version }} diff --git a/.github/workflows/central-publish.yml b/.github/workflows/central-publish.yml index 2634fd680..146858e8f 100644 --- a/.github/workflows/central-publish.yml +++ b/.github/workflows/central-publish.yml @@ -16,7 +16,7 @@ jobs: call_workflow: name: Run Central Publish Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/central-publish-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/central-publish-template.yml@java21 secrets: inherit with: environment: ${{ github.event.inputs.environment }} diff --git a/.github/workflows/process-load-test-result.yml b/.github/workflows/process-load-test-result.yml index 6aa142c97..4d64866c8 100644 --- a/.github/workflows/process-load-test-result.yml +++ b/.github/workflows/process-load-test-result.yml @@ -6,7 +6,7 @@ on: jobs: call_stdlib_process_load_test_results_workflow: name: Run StdLib Process Load Test Results Workflow - uses: ballerina-platform/ballerina-library/.github/workflows/process-load-test-results-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/process-load-test-results-template.yml@java21 with: results: ${{ toJson(github.event.client_payload.results) }} secrets: diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 2b681aef8..d04a0063d 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -9,7 +9,7 @@ jobs: call_workflow: name: Run Release Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/release-package-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/release-package-template.yml@java21 secrets: inherit with: package-name: grpc diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index ecfa72cec..660df057e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,5 +10,5 @@ jobs: call_workflow: name: Run PR Build Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/pull-request-build-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/pull-request-build-template.yml@java21 secrets: inherit diff --git a/.github/workflows/trigger-load-tests.yml b/.github/workflows/trigger-load-tests.yml index 10b4e563c..2fe4a24cf 100644 --- a/.github/workflows/trigger-load-tests.yml +++ b/.github/workflows/trigger-load-tests.yml @@ -22,7 +22,7 @@ jobs: call_stdlib_trigger_load_test_workflow: name: Run StdLib Load Test Workflow if: ${{ github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'ballerina-platform') }} - uses: ballerina-platform/ballerina-library/.github/workflows/trigger-load-tests-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/trigger-load-tests-template.yml@java21 with: repo_name: 'module-ballerina-grpc' runtime_artifacts_url: 'https://api.github.com/repos/ballerina-platform/module-ballerina-grpc/actions/artifacts' diff --git a/.github/workflows/trivy-scan.yml b/.github/workflows/trivy-scan.yml index c02c8ff42..41e8f6ad4 100644 --- a/.github/workflows/trivy-scan.yml +++ b/.github/workflows/trivy-scan.yml @@ -9,5 +9,5 @@ jobs: call_workflow: name: Run Trivy Scan Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/trivy-scan-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/trivy-scan-template.yml@java21 secrets: inherit 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 d03fe7094..872ab065f 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerina" name = "grpc" -version = "1.12.1" +version = "1.12.2" distribution = "2201.10.0" authors = ["Ballerina"] keywords = ["network", "grpc", "protobuf", "server-streaming", "client-streaming", "bidirectional-streaming"] @@ -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.12.1" -path = "../native/build/libs/grpc-native-1.12.1.jar" +version = "1.12.2" +path = "../native/build/libs/grpc-native-1.12.2-SNAPSHOT.jar" -[[platform.java17.dependency]] -path = "../test-utils/build/libs/grpc-test-utils-1.12.1.jar" +[[platform.java21.dependency]] +path = "../test-utils/build/libs/grpc-test-utils-1.12.2-SNAPSHOT.jar" scope = "testOnly" -[[platform.java17.dependency]] -path = "./lib/ballerina-cli-2201.10.0.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.12.0" -path = "./lib/http-native-2.12.0.jar" +version = "2.13.0" +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.108.Final" path = "./lib/netty-common-4.1.108.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-buffer" version = "4.1.108.Final" path = "./lib/netty-buffer-4.1.108.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-transport" version = "4.1.108.Final" path = "./lib/netty-transport-4.1.108.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-resolver" version = "4.1.108.Final" path = "./lib/netty-resolver-4.1.108.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-handler" version = "4.1.108.Final" path = "./lib/netty-handler-4.1.108.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-codec-http" version = "4.1.108.Final" path = "./lib/netty-codec-http-4.1.108.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-codec" version = "4.1.108.Final" path = "./lib/netty-codec-4.1.108.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-handler-proxy" version = "4.1.108.Final" path = "./lib/netty-handler-proxy-4.1.108.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-codec-http2" version = "4.1.108.Final" path = "./lib/netty-codec-http2-4.1.108.Final.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-transport-native-unix-common" version = "4.1.108.Final" path = "./lib/netty-transport-native-unix-common-4.1.108.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.10.0" -path = "./lib/formatter-core-2201.10.0.jar" +version = "2201.10.0-20241025-103700-5c9e6a27" +path = "./lib/formatter-core-2201.10.0-20241025-103700-5c9e6a27.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "org.ballerinalang" artifactId = "ballerina-parser" -version = "2201.10.0" -path = "./lib/ballerina-parser-2201.10.0.jar" +version = "2201.10.0-20241025-103700-5c9e6a27" +path = "./lib/ballerina-parser-2201.10.0-20241025-103700-5c9e6a27.jar" diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index 32560585a..12dc5f592 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -3,4 +3,4 @@ id = "grpc-compiler-plugin" class = "io.ballerina.stdlib.grpc.plugin.GrpcCompilerPlugin" [[dependency]] -path = "../compiler-plugin/build/libs/grpc-compiler-plugin-1.12.1.jar" +path = "../compiler-plugin/build/libs/grpc-compiler-plugin-1.12.2-SNAPSHOT.jar" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 064d095a6..4d6e296c9 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0" +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"} @@ -56,7 +55,7 @@ modules = [ [[package]] org = "ballerina" name = "file" -version = "1.10.0" +version = "1.10.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, @@ -68,7 +67,7 @@ dependencies = [ [[package]] org = "ballerina" name = "grpc" -version = "1.12.1" +version = "1.12.2" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "crypto"}, @@ -94,7 +93,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.12.0" +version = "2.13.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -127,7 +126,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"} @@ -144,7 +143,7 @@ modules = [ [[package]] org = "ballerina" name = "jwt" -version = "2.13.0" +version = "2.13.1" dependencies = [ {org = "ballerina", name = "cache"}, {org = "ballerina", name = "crypto"}, @@ -152,8 +151,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"} @@ -249,7 +247,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"}, @@ -263,7 +261,7 @@ modules = [ [[package]] org = "ballerina" name = "mime" -version = "2.10.0" +version = "2.10.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, @@ -275,13 +273,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 = [ @@ -291,7 +288,7 @@ modules = [ [[package]] org = "ballerina" name = "observe" -version = "1.3.0" +version = "1.3.1" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -299,7 +296,7 @@ dependencies = [ [[package]] org = "ballerina" name = "os" -version = "1.8.0" +version = "1.8.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, @@ -309,7 +306,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"} @@ -327,7 +324,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"} @@ -350,7 +347,7 @@ modules = [ [[package]] org = "ballerina" name = "time" -version = "2.4.0" +version = "2.5.1" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -361,7 +358,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 c11629927..d8faaa907 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 2b37bab26..96362b899 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.caching=true group=io.ballerina.stdlib version=1.12.2-SNAPSHOT #dependency versions -ballerinaLangVersion=2201.10.0 +ballerinaLangVersion=2201.10.0-20241025-103700-5c9e6a27 ballerinaTomlParserVersion=1.2.2 checkstylePluginVersion=10.12.0 commonsLang3Version=3.8.1 @@ -13,7 +13,7 @@ jknackHandlebarsVersion=4.0.6 nettyVersion=4.1.108.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,29 +26,29 @@ 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-20240928-084100-656404f +stdlibTimeVersion=2.5.1-20240930-120200-e59222b +stdlibUrlVersion=2.4.1-20240930-120200-b7fb9e1 -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.5.1-20240930-123400-5ecd396 +stdlibCryptoVersion=2.7.3-20240930-132000-5ecc9ab +stdlibLogVersion=2.10.1-20240930-154200-5ab2aa4 +stdlibOsVersion=1.8.1-20241001-120600-dd1626e +stdlibProtobufVersion=1.6.2-20240930-192700-1e42210 +stdlibRandomVersion=1.5.1-20240930-193000-e5c6c0e +stdlibTaskVersion=2.5.1-20241002-145700-5bdb843 -stdlibCacheVersion=3.8.0 -stdlibFileVersion=1.10.0 -stdlibMimeVersion=2.10.0 -stdlibUuidVersion=1.8.0 +stdlibCacheVersion=3.8.1-20241007-154900-63f4403 +stdlibFileVersion=1.10.1-20241007-160900-03f7b64 +stdlibMimeVersion=2.10.1-20241009-141200-8b6c9f0 +stdlibUuidVersion=1.8.1-20241009-134600-a05012b -stdlibAuthVersion=2.12.0 -stdlibJwtVersion=2.13.0 -stdlibOAuth2Version=2.12.0 +stdlibAuthVersion=2.12.1-20241010-130800-733dbef +stdlibJwtVersion=2.13.1-20241010-123600-5ea6a94 +stdlibOAuth2Version=2.12.1-20241029-084800-d7ba9e5 -stdlibHttpVersion=2.12.0 +stdlibHttpVersion=2.13.0-20241029-110700-30ed05b # Ballerinax Observer -observeVersion=1.3.0 -observeInternalVersion=1.3.0 +observeVersion=1.3.1-20241007-161000-645452d +observeInternalVersion=1.3.1-20241007-182700-a5f77a1 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/GrpcUtil.java b/native/src/main/java/io/ballerina/stdlib/grpc/GrpcUtil.java index 2452c0ac2..45225a573 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/GrpcUtil.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/GrpcUtil.java @@ -19,9 +19,11 @@ 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.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,14 @@ 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 (Throwable throwable) { + throw ErrorCreator.createError(throwable); + } + } } 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..0c9abfed1 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/ServicesBuilderUtils.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/ServicesBuilderUtils.java @@ -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..b74265fb7 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,7 +18,6 @@ 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.creators.ErrorCreator; import io.ballerina.runtime.api.types.ObjectType; @@ -56,15 +55,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 +70,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 +108,24 @@ 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 { + Object result; + if (serviceObjectType.isIsolated() && serviceObjectType.isIsolated(STREAMING_NEXT_FUNCTION)) { + result = runtime.startIsolatedWorker(bObject, STREAMING_NEXT_FUNCTION, null, null, null).get(); + } else { + result = runtime.startNonIsolatedWorker(bObject, STREAMING_NEXT_FUNCTION, null, null, null) + .get(); + } + 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 +141,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 +167,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 +176,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 +192,6 @@ public ReturnStreamUnitCallBack(Runtime runtime, StreamObserver requestSender, this.headers = headers; } - @Override public void notifySuccess(Object response) { if (response != null) { Message msg; @@ -207,22 +207,28 @@ 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 { + Object result; + if (serviceObjectType.isIsolated() && serviceObjectType.isIsolated(STREAMING_NEXT_FUNCTION)) { + result = runtime.startIsolatedWorker(bObject, STREAMING_NEXT_FUNCTION, null, null, null) + .get(); + } else { + result = runtime.startNonIsolatedWorker(bObject, STREAMING_NEXT_FUNCTION, null, null, null) + .get(); + } + 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..637673645 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,7 +18,6 @@ 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.creators.ErrorCreator; import io.ballerina.runtime.api.types.ObjectType; @@ -56,11 +55,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 +71,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 +117,25 @@ 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 { + Object result; + if (serviceObjectType.isIsolated() && serviceObjectType.isIsolated(STREAMING_NEXT_FUNCTION)) { + result = runtime.startIsolatedWorker(bObject, STREAMING_NEXT_FUNCTION, null, null, null) + .get(); + } else { + result = runtime.startNonIsolatedWorker(bObject, STREAMING_NEXT_FUNCTION, null, null, + null).get(); + } + 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 +156,6 @@ public void notifySuccess(Object response) { } } - @Override public void notifyFailure(BError error) { if (requestSender instanceof ServerCallHandler.ServerCallStreamObserver) { ServerCallHandler.ServerCallStreamObserver serverCallStreamObserver = (ServerCallHandler @@ -176,7 +180,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 +190,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 +205,6 @@ public ReturnStreamUnitCallBack(Runtime runtime, StreamObserver requestSender, this.headers = headers; } - @Override public void notifySuccess(Object response) { if (response != null) { Message msg; @@ -218,22 +220,27 @@ 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 { + Object result; + if (serviceObjectType.isIsolated() && serviceObjectType.isIsolated(STREAMING_NEXT_FUNCTION)) { + result = runtime.startIsolatedWorker(bObject, STREAMING_NEXT_FUNCTION, null, null, null) + .get(); + } else { + result = runtime.startNonIsolatedWorker(bObject, STREAMING_NEXT_FUNCTION, null, null, null) + .get(); + } + 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..940604478 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 @@ -20,12 +20,12 @@ 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.creators.ValueCreator; import io.ballerina.runtime.api.types.ArrayType; 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.BMap; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.observability.ObservabilityConstants; @@ -173,8 +173,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 +187,32 @@ 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); + Object result; + if (isEmpty) { + if (serviceObjectType.isIsolated() && serviceObjectType.isIsolated(functionName)) { + result = resource.getRuntime().startIsolatedWorker(resource.getService(), functionName, null, + GrpcConstants.ON_MESSAGE_METADATA, properties).get(); + } else { + result = resource.getRuntime().startNonIsolatedWorker(resource.getService(), functionName, null, + GrpcConstants.ON_MESSAGE_METADATA, properties).get(); + } + } else { + if (serviceObjectType.isIsolated() && serviceObjectType.isIsolated(functionName)) { + result = resource.getRuntime().startIsolatedWorker(resource.getService(), functionName, null, + GrpcConstants.ON_MESSAGE_METADATA, properties, requestParams).get(); + } else { + result = resource.getRuntime().startNonIsolatedWorker(resource.getService(), functionName, null, + GrpcConstants.ON_MESSAGE_METADATA, properties, requestParams).get(); + } + } + callback.notifySuccess(result); + } catch (BError error) { + callback.notifyFailure(error); } - } + }); } Boolean isEmpty(Object[] requestParams) { @@ -230,12 +234,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 +271,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..f932c478e 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 @@ -24,6 +24,7 @@ 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 +124,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 +186,22 @@ 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 { + Object result; + if (serviceObjectType.isIsolated() && serviceObjectType.isIsolated(functionName)) { + result = resource.getRuntime().startIsolatedWorker(service, functionName, null, + GrpcConstants.ON_MESSAGE_METADATA, properties, requestParams).get(); + } else { + result = resource.getRuntime().startNonIsolatedWorker(service, functionName, null, + GrpcConstants.ON_MESSAGE_METADATA, properties, requestParams).get(); + } + 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..241ed4af0 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 @@ -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..d82af0c16 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 @@ -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/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; }