diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 872ab065f..a9028d781 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,8 +1,8 @@ [package] org = "ballerina" name = "grpc" -version = "1.12.2" -distribution = "2201.10.0" +version = "1.13.0" +distribution = "2201.11.0" authors = ["Ballerina"] keywords = ["network", "grpc", "protobuf", "server-streaming", "client-streaming", "bidirectional-streaming"] repository = "https://github.com/ballerina-platform/module-ballerina-grpc" @@ -16,7 +16,7 @@ graalvmCompatible = true [[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "grpc-native" -version = "1.12.2" +ersion = "1.12.2" path = "../native/build/libs/grpc-native-1.12.2-SNAPSHOT.jar" [[platform.java21.dependency]] @@ -40,62 +40,62 @@ path = "./lib/http-native-2.13.0-20241029-110700-30ed05b.jar" [[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-common" -version = "4.1.108.Final" -path = "./lib/netty-common-4.1.108.Final.jar" +version = "4.1.115.Final" +path = "./lib/netty-common-4.1.115.Final.jar" [[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-buffer" -version = "4.1.108.Final" -path = "./lib/netty-buffer-4.1.108.Final.jar" +version = "4.1.115.Final" +path = "./lib/netty-buffer-4.1.115.Final.jar" [[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-transport" -version = "4.1.108.Final" -path = "./lib/netty-transport-4.1.108.Final.jar" +version = "4.1.115.Final" +path = "./lib/netty-transport-4.1.115.Final.jar" [[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-resolver" -version = "4.1.108.Final" -path = "./lib/netty-resolver-4.1.108.Final.jar" +version = "4.1.115.Final" +path = "./lib/netty-resolver-4.1.115.Final.jar" [[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-handler" -version = "4.1.108.Final" -path = "./lib/netty-handler-4.1.108.Final.jar" +version = "4.1.115.Final" +path = "./lib/netty-handler-4.1.115.Final.jar" [[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" +version = "4.1.115.Final" +path = "./lib/netty-codec-http-4.1.115.Final.jar" [[platform.java21.dependency]] groupId = "io.netty" artifactId = "netty-codec" -version = "4.1.108.Final" -path = "./lib/netty-codec-4.1.108.Final.jar" +version = "4.1.115.Final" +path = "./lib/netty-codec-4.1.115.Final.jar" [[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" +version = "4.1.115.Final" +path = "./lib/netty-handler-proxy-4.1.115.Final.jar" [[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" +version = "4.1.115.Final" +path = "./lib/netty-codec-http2-4.1.115.Final.jar" [[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" +version = "4.1.115.Final" +path = "./lib/netty-transport-native-unix-common-4.1.115.Final.jar" [[platform.java21.dependency]] groupId = "commons.pool.wso2" @@ -163,8 +163,8 @@ path = "./lib/proto-google-common-protos-1.17.0.jar" [[platform.java21.dependency]] groupId = "org.ballerinalang" artifactId = "formatter-core" -version = "2201.10.0-20241025-103700-5c9e6a27" -path = "./lib/formatter-core-2201.10.0-20241025-103700-5c9e6a27.jar" +version = "2201.11.0-20241008-112400-81975006" +path = "./lib/formatter-core-2201.11.0-20241008-112400-81975006.jar" [[platform.java21.dependency]] groupId = "org.ballerinalang" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 4d6e296c9..c8d9bbcc6 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -52,6 +52,16 @@ modules = [ {org = "ballerina", packageName = "crypto", moduleName = "crypto"} ] +[[package]] +org = "ballerina" +name = "data.jsondata" +version = "0.3.0" +scope = "testOnly" +dependencies = [ + {org = "ballerina", name = "jballerina.java"}, + {org = "ballerina", name = "lang.object"} +] + [[package]] org = "ballerina" name = "file" @@ -67,7 +77,7 @@ dependencies = [ [[package]] org = "ballerina" name = "grpc" -version = "1.12.2" +version = "1.13.0" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "crypto"}, @@ -100,6 +110,7 @@ dependencies = [ {org = "ballerina", name = "cache"}, {org = "ballerina", name = "constraint"}, {org = "ballerina", name = "crypto"}, + {org = "ballerina", name = "data.jsondata"}, {org = "ballerina", name = "file"}, {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, diff --git a/build-config/resources/Ballerina.toml b/build-config/resources/Ballerina.toml index d8faaa907..7528176f4 100644 --- a/build-config/resources/Ballerina.toml +++ b/build-config/resources/Ballerina.toml @@ -2,7 +2,7 @@ org = "ballerina" name = "grpc" version = "@toml.version@" -distribution = "2201.10.0" +distribution = "2201.11.0" authors = ["Ballerina"] keywords = ["network", "grpc", "protobuf", "server-streaming", "client-streaming", "bidirectional-streaming"] repository = "https://github.com/ballerina-platform/module-ballerina-grpc" diff --git a/build.gradle b/build.gradle index f582d3cff..3b9153846 100644 --- a/build.gradle +++ b/build.gradle @@ -92,6 +92,7 @@ subprojects { ballerinaStdLibs "io.ballerina.stdlib:random-ballerina:${stdlibRandomVersion}" ballerinaStdLibs "io.ballerina.stdlib:observe-ballerina:${observeVersion}" ballerinaStdLibs "io.ballerina:observe-ballerina:${observeInternalVersion}" + ballerinaStdLibs "io.ballerina.lib:data.jsondata-ballerina:${stdlibDataJsonDataVersion}" } } diff --git a/changelog.md b/changelog.md index 7912c1a47..7eae150a4 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,12 @@ This file contains all the notable changes done to the Ballerina gRPC package th The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- [Address CVE-2024-47535 vulnerability](https://github.com/ballerina-platform/ballerina-library/issues/7358) + ## [1.12.1] - 2024-09-26 ### Fixed diff --git a/gradle.properties b/gradle.properties index 96362b899..bbe1a4e9a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ org.gradle.caching=true group=io.ballerina.stdlib -version=1.12.2-SNAPSHOT +version=1.13.0-SNAPSHOT #dependency versions -ballerinaLangVersion=2201.10.0-20241025-103700-5c9e6a27 +ballerinaLangVersion=2201.11.0-20241112-214900-6b80ab87 ballerinaTomlParserVersion=1.2.2 checkstylePluginVersion=10.12.0 commonsLang3Version=3.8.1 @@ -10,7 +10,7 @@ slf4jVersion=1.7.30 protoGoogleCommonsVersion=1.17.0 protobufJavaVersion=3.25.5 jknackHandlebarsVersion=4.0.6 -nettyVersion=4.1.108.Final +nettyVersion=4.1.115.Final nettyTcnativeVersion=2.0.65.Final picocliVersion=4.0.1 githubSpotbugsVersion=6.0.18 @@ -26,29 +26,30 @@ bouncycastleVersion=1.78 wso2CommonsPoolVersion=1.5.6.wso2v1 #stdlib dependencies -stdlibIoVersion=1.6.2-20240928-084100-656404f -stdlibTimeVersion=2.5.1-20240930-120200-e59222b -stdlibUrlVersion=2.4.1-20240930-120200-b7fb9e1 +stdlibIoVersion=1.6.2-20241112-233100-995cf5f +stdlibTimeVersion=2.6.0-20241113-073800-201b904 +stdlibUrlVersion=2.4.1-20241113-073900-335ff51 -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 +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.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 +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.1-20241010-130800-733dbef -stdlibJwtVersion=2.13.1-20241010-123600-5ea6a94 -stdlibOAuth2Version=2.12.1-20241029-084800-d7ba9e5 +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-20241029-110700-30ed05b +stdlibHttpVersion=2.13.0-20241114-182900-7e9f66a # Ballerinax Observer -observeVersion=1.3.1-20241007-161000-645452d -observeInternalVersion=1.3.1-20241007-182700-a5f77a1 +observeVersion=1.4.0-20241113-092000-b83ae74 +observeInternalVersion=1.3.1-20241113-101700-265054d diff --git a/load-tests/route_guide_bidirectional_streaming/results/summary.csv b/load-tests/route_guide_bidirectional_streaming/results/summary.csv index ea5c02508..902fada76 100644 --- a/load-tests/route_guide_bidirectional_streaming/results/summary.csv +++ b/load-tests/route_guide_bidirectional_streaming/results/summary.csv @@ -575,3 +575,5 @@ gRPC Route Guide Bidirectional Streaming,3506,482.530775,479.591677,0.0,748.5674 gRPC Route Guide Bidirectional Streaming,3345,505.135709,502.420856,0.0,798.854974,0.0,165.343025,1039.034575,0.0,1.86,0,0,1727460701,0,10 gRPC Route Guide Bidirectional Streaming,3314,510.11138,501.833977,0.0,802.72178,0.0,149.377058,1466.109361,0.0,1.84,0,0,1727547032,0,10 gRPC Route Guide Bidirectional Streaming,3530,481.633746,485.867694,0.0,766.209934,0.0,157.652587,1175.187999,0.0,1.96,0,0,1729102459,0,10 +gRPC Route Guide Bidirectional Streaming,3268,514.845909,512.637627,0.0,808.647631,0.0,131.481928,1307.470988,0.0,1.82,0,0,1729188763,0,10 +gRPC Route Guide Bidirectional Streaming,3592,473.780663,476.37975,0.0,742.511928,0.0,152.013694,1023.708903,0.0,1.99,0,0,1731521579,0,10 diff --git a/load-tests/route_guide_client_streaming/results/summary.csv b/load-tests/route_guide_client_streaming/results/summary.csv index 347208c58..145e5371f 100644 --- a/load-tests/route_guide_client_streaming/results/summary.csv +++ b/load-tests/route_guide_client_streaming/results/summary.csv @@ -579,3 +579,5 @@ gRPC Route Guide Client Streaming,898997,1.400038,0.92562,0.0,1.891121,0.0,0.689 gRPC Route Guide Client Streaming,898994,1.441502,0.907615,0.0,2.142536,0.0,0.734512,197.075894,0.0,499.44,0,0,1727462786,0,10 gRPC Route Guide Client Streaming,898997,1.457238,0.914714,0.0,2.213433,0.0,0.728111,196.229934,0.0,499.44,0,0,1727549118,0,10 gRPC Route Guide Client Streaming,898997,1.253074,0.818204,0.0,1.829809,0.0,0.637603,382.899362,0.0,499.44,0,0,1729104567,0,10 +gRPC Route Guide Client Streaming,898998,1.647377,1.016311,0.0,2.835227,0.0,0.781205,203.05984,0.0,499.44,0,0,1729190815,0,10 +gRPC Route Guide Client Streaming,899001,1.227053,0.808098,0.0,1.758296,0.0,0.631299,223.038223,0.0,499.44,0,0,1731523627,0,10 diff --git a/load-tests/route_guide_server_streaming/results/summary.csv b/load-tests/route_guide_server_streaming/results/summary.csv index 041a653eb..ed7f6fd35 100644 --- a/load-tests/route_guide_server_streaming/results/summary.csv +++ b/load-tests/route_guide_server_streaming/results/summary.csv @@ -579,3 +579,5 @@ gRPC Route Guide Server Streaming,898998,5.987615,2.046317,0.0,18.504627,0.0,1.2 gRPC Route Guide Server Streaming,898996,8.16116,2.461642,0.0,48.984807,0.0,1.345322,210.027336,0.0,499.44,0,0,1727465663,0,10 gRPC Route Guide Server Streaming,898997,8.74801,2.659339,0.0,51.029056,0.0,1.35652,139.436291,0.0,499.44,0,0,1727552059,0,10 gRPC Route Guide Server Streaming,898994,4.752683,1.799709,0.0,13.739662,0.0,1.250806,180.150065,0.0,499.44,0,0,1729107184,0,10 +gRPC Route Guide Server Streaming,898998,13.869668,8.71621,0.0,54.957258,0.0,1.407411,196.414035,0.0,499.44,0,0,1729193305,0,10 +gRPC Route Guide Server Streaming,898997,4.404741,1.739797,0.0,13.110902,0.0,1.237798,194.497726,0.0,499.44,0,0,1731526731,0,10 diff --git a/load-tests/route_guide_unary/results/summary.csv b/load-tests/route_guide_unary/results/summary.csv index eaf51b9fc..61f78fd46 100644 --- a/load-tests/route_guide_unary/results/summary.csv +++ b/load-tests/route_guide_unary/results/summary.csv @@ -585,3 +585,5 @@ gRPC Route Guide Unary,898997,0.941409,0.715309,0.0,1.479118,0.0,0.509905,90.208 gRPC Route Guide Unary,898996,0.847067,0.675708,0.0,1.167135,0.0,0.472604,90.204033,0.0,499.44,0,0,1726085410,0,10 gRPC Route Guide Unary,898996,0.871588,0.67851,0.0,1.141717,0.0,0.504407,94.7139,0.0,499.44,0,0,1727554142,0,10 gRPC Route Guide Unary,898995,0.734134,0.599803,0.0,0.874304,0.0,0.432902,83.262678,0.0,499.44,0,0,1729109238,0,10 +gRPC Route Guide Unary,898999,0.976462,0.747409,0.0,1.259314,0.0,0.540303,100.586353,0.0,499.44,0,0,1729195393,0,10 +gRPC Route Guide Unary,898996,0.736169,0.596999,0.0,0.878098,0.0,0.4006,97.861689,0.0,499.44,0,0,1731528821,0,10 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 45225a573..accf77f51 100644 --- a/native/src/main/java/io/ballerina/stdlib/grpc/GrpcUtil.java +++ b/native/src/main/java/io/ballerina/stdlib/grpc/GrpcUtil.java @@ -18,9 +18,9 @@ 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; 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 0c9abfed1..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; 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 b74265fb7..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 @@ -19,6 +19,7 @@ import com.google.protobuf.Descriptors; 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; @@ -110,13 +111,10 @@ public void notifySuccess(Object response) { ObjectType serviceObjectType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(bObject)); 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(); - } + 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); @@ -209,14 +207,10 @@ public void notifySuccess(Object response) { ObjectType serviceObjectType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(bObject)); 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(); - } + 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); 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 637673645..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 @@ -19,6 +19,7 @@ import com.google.protobuf.Descriptors; 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; @@ -119,14 +120,10 @@ public void notifySuccess(Object response) { ObjectType serviceObjectType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(bObject)); 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(); - } + 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); @@ -222,14 +219,10 @@ public void notifySuccess(Object response) { ObjectType serviceObjectType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(bObject)); 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(); - } + 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); 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 940604478..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,12 +18,13 @@ 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.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; @@ -190,23 +191,14 @@ void onMessageInvoke(ServiceResource resource, Message request, StreamObserver r Thread.startVirtualThread(() -> { try { boolean isEmpty = isEmpty(requestParams); + boolean isConcurrentSafe = serviceObjectType.isIsolated() && serviceObjectType.isIsolated(functionName); + StrandMetadata metadata = new StrandMetadata(isConcurrentSafe, properties); 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(); - } + result = resource.getRuntime().callMethod(resource.getService(), functionName, metadata); } 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(); - } + result = resource.getRuntime().callMethod(resource.getService(), functionName, metadata, + requestParams); } callback.notifySuccess(result); } catch (BError error) { 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 f932c478e..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,6 +19,7 @@ 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; @@ -190,14 +191,9 @@ void onStreamInvoke(ServiceResource resource, BStream requestStream, HttpHeaders 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(); - } + 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/serviceendpoint/FunctionUtils.java b/native/src/main/java/io/ballerina/stdlib/grpc/nativeimpl/serviceendpoint/FunctionUtils.java index 241ed4af0..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; 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 d82af0c16..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; 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;