From 24c0aee3789867dc4edcf2f87052a3c2d59c3b90 Mon Sep 17 00:00:00 2001 From: hindujaB Date: Wed, 13 Nov 2024 23:25:58 +0530 Subject: [PATCH] Migrate runtime APIs and fix compilation --- ballerina/Ballerina.toml | 8 ++-- gradle.properties | 37 ++++++++++--------- .../api/BallerinaHTTPConnectorListener.java | 24 ++++-------- .../http/api/HttpCallableUnitCallback.java | 6 +-- .../stdlib/http/api/HttpDispatcher.java | 4 +- .../HttpRequestInterceptorUnitCallback.java | 6 +-- .../stdlib/http/api/HttpResource.java | 4 +- .../HttpResponseInterceptorUnitCallback.java | 6 +-- .../stdlib/http/api/HttpService.java | 6 ++- .../ballerina/stdlib/http/api/HttpUtil.java | 6 ++- .../client/actions/AbstractHTTPAction.java | 2 +- .../api/client/actions/HttpClientAction.java | 11 ++---- .../http/api/nativeimpl/ExternFormatter.java | 2 +- .../http/api/nativeimpl/ExternRequest.java | 2 +- .../nativeimpl/ExternResponseProcessor.java | 10 ++--- .../http/api/nativeimpl/ExternUtils.java | 2 +- .../http/api/nativeimpl/ModuleUtils.java | 29 +-------------- .../http/api/nativeimpl/ParseHeader.java | 2 +- .../api/nativeimpl/connection/Respond.java | 8 +++- .../api/service/signature/HeaderParam.java | 2 +- .../api/service/signature/ParamHandler.java | 2 +- .../api/service/signature/ParamUtils.java | 30 +++++++-------- .../api/service/signature/PayloadParam.java | 5 +-- .../builder/AbstractPayloadBuilder.java | 16 ++++---- .../signature/builder/ArrayBuilder.java | 2 +- .../builder/BinaryPayloadBuilder.java | 2 +- .../signature/builder/JsonPayloadBuilder.java | 2 +- .../builder/StringPayloadBuilder.java | 2 +- .../signature/builder/XmlPayloadBuilder.java | 2 +- .../converter/StringToByteArrayConverter.java | 2 +- .../UrlEncodedStringToMapConverter.java | 4 +- .../stdlib/http/api/util/CacheUtils.java | 2 +- 32 files changed, 109 insertions(+), 139 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 389cd6ac0e..f494781687 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -22,14 +22,14 @@ path = "../native/build/libs/http-native-2.13.0-SNAPSHOT.jar" [[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "mime-native" -version = "2.10.1" -path = "./lib/mime-native-2.10.1-20241009-141200-8b6c9f0.jar" +version = "2.10.2" +path = "./lib/mime-native-2.10.2-20241113-154200-d953747.jar" [[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "constraint-native" -version = "1.5.1" -path = "./lib/constraint-native-1.5.1-20240930-123400-5ecd396.jar" +version = "1.6.0" +path = "./lib/constraint-native-1.6.0-20241113-090900-d276ad5.jar" [[platform.java21.dependency]] groupId = "io.netty" diff --git a/gradle.properties b/gradle.properties index 4fcf344ea6..d9219bb52a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ org.gradle.caching=true group=io.ballerina.stdlib version=2.13.0-SNAPSHOT -ballerinaLangVersion=2201.10.0-20241025-103700-5c9e6a27 +ballerinaLangVersion=2201.11.0-20241112-214900-6b80ab87 ballerinaTomlParserVersion=1.2.2 commonsLang3Version=3.12.0 nettyVersion=4.1.115.Final @@ -31,24 +31,27 @@ githubJohnrengelmanShadowVersion=8.1.1 underCouchDownloadVersion=5.4.0 researchgateReleaseVersion=2.8.0 -stdlibIoVersion=1.6.2-20241015-173200-3e70033 -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 -stdlibOsVersion=1.8.1-20241001-120600-dd1626e -stdlibTaskVersion=2.5.1-20241002-145700-5bdb843 -stdlibLogVersion=2.10.1-20240930-154200-5ab2aa4 -stdlibCryptoVersion=2.7.3-20240930-132000-5ecc9ab +stdlibConstraintVersion=1.6.0-20241113-090900-d276ad5 +stdlibOsVersion=1.8.1-20241113-122000-cca973b +stdlibTaskVersion=2.5.1-20241113-123500-f905281 +stdlibLogVersion=2.10.1-20241113-120000-4577868 +stdlibCryptoVersion=2.7.3-20241113-081400-d015a39 -stdlibFileVersion=1.10.1-20241007-160900-03f7b64 -stdlibMimeVersion=2.10.1-20241009-141200-8b6c9f0 -stdlibCacheVersion=3.8.1-20241007-154900-63f4403 +stdlibFileVersion=1.10.1-20241113-151700-e1a2e38 +stdlibMimeVersion=2.10.2-20241113-154200-d953747 +stdlibCacheVersion=3.8.1-20241113-125700-b75a1bf -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-20241113-163100-6d332e1 +stdlibJwtVersion=2.13.1-20241113-162400-b59ccfa +stdlibOAuth2Version=2.12.1-20241113-162400-4c6ddfe -observeVersion=1.3.1-20241007-161000-645452d -observeInternalVersion=1.3.1-20241015-172900-cdc3cb3 +balScanVersion=0.5.0 + +observeVersion=1.4.0-20241113-092000-b83ae74 +observeInternalVersion=1.3.1-20241113-101700-265054d diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/BallerinaHTTPConnectorListener.java b/native/src/main/java/io/ballerina/stdlib/http/api/BallerinaHTTPConnectorListener.java index 23d342c7a9..260b55ac3f 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/BallerinaHTTPConnectorListener.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/BallerinaHTTPConnectorListener.java @@ -18,6 +18,7 @@ package io.ballerina.stdlib.http.api; import io.ballerina.runtime.api.Runtime; +import io.ballerina.runtime.api.concurrent.StrandMetadata; import io.ballerina.runtime.api.constants.RuntimeConstants; import io.ballerina.runtime.api.types.ObjectType; import io.ballerina.runtime.api.utils.TypeUtils; @@ -28,7 +29,6 @@ import io.ballerina.runtime.observability.ObservabilityConstants; import io.ballerina.runtime.observability.ObserveUtils; import io.ballerina.runtime.observability.ObserverContext; -import io.ballerina.stdlib.http.api.nativeimpl.ModuleUtils; import io.ballerina.stdlib.http.transport.contract.HttpConnectorListener; import io.ballerina.stdlib.http.transport.message.HttpCarbonMessage; import org.slf4j.Logger; @@ -189,15 +189,10 @@ protected void extractPropertiesAndStartResourceExecution(HttpCarbonMessage inbo ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(service)); Thread.startVirtualThread(() -> { Object result; + boolean isIsolated = serviceType.isIsolated() && serviceType.isIsolated(resourceName); + StrandMetadata metaData = new StrandMetadata(isIsolated, properties); try { - if (serviceType.isIsolated() && serviceType.isIsolated(resourceName)) { - result = runtime.startIsolatedWorker(service, resourceName, null, - ModuleUtils.getOnMessageMetaData(), properties, signatureParams).get(); - - } else { - result = runtime.startNonIsolatedWorker(service, resourceName, null, - ModuleUtils.getOnMessageMetaData(), properties, signatureParams).get(); - } + result = runtime.callMethod(service, resourceName, metaData, signatureParams); callback.handleResult(result); } catch (BError error) { callback.handlePanic(error); @@ -254,15 +249,10 @@ protected void extractPropertiesAndStartInterceptorResourceExecution(HttpCarbonM ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(service)); Thread.startVirtualThread(() -> { - Object result; + boolean isIsolated = serviceType.isIsolated() && serviceType.isIsolated(resourceName); + StrandMetadata metaData = new StrandMetadata(isIsolated, properties); try { - if (serviceType.isIsolated() && serviceType.isIsolated(resourceName)) { - result = runtime.startIsolatedWorker(service, resourceName, null, - ModuleUtils.getOnMessageMetaData(), properties, signatureParams).get(); - } else { - result = runtime.startNonIsolatedWorker(service, resourceName, null, - ModuleUtils.getOnMessageMetaData(), properties, signatureParams).get(); - } + Object result = runtime.callMethod(service, resourceName, metaData, signatureParams); callback.handleResult(result); } catch (BError error) { callback.handlePanic(error); diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/HttpCallableUnitCallback.java b/native/src/main/java/io/ballerina/stdlib/http/api/HttpCallableUnitCallback.java index b15e38bff9..35eb40cc34 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/HttpCallableUnitCallback.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/HttpCallableUnitCallback.java @@ -17,13 +17,13 @@ package io.ballerina.stdlib.http.api; import io.ballerina.runtime.api.Runtime; +import io.ballerina.runtime.api.concurrent.StrandMetadata; import io.ballerina.runtime.api.utils.StringUtils; 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.ObserveUtils; import io.ballerina.runtime.observability.ObserverContext; -import io.ballerina.stdlib.http.api.nativeimpl.ModuleUtils; import io.ballerina.stdlib.http.transport.message.HttpCarbonMessage; import java.util.Locale; @@ -117,8 +117,8 @@ private void returnErrorResponse(BError error) { public void invokeBalMethod(Object[] paramFeed, String methodName) { Thread.startVirtualThread(() -> { try { - runtime.startNonIsolatedWorker(caller, methodName, null, - ModuleUtils.getNotifySuccessMetaData(), null, paramFeed).get(); + StrandMetadata metaData = new StrandMetadata(false, null); + runtime.callMethod(caller, methodName, metaData, paramFeed); stopObserverContext(); } catch (BError error) { sendFailureResponse(error); diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/HttpDispatcher.java b/native/src/main/java/io/ballerina/stdlib/http/api/HttpDispatcher.java index 1b288db1d2..f6543492eb 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/HttpDispatcher.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/HttpDispatcher.java @@ -465,8 +465,8 @@ private static Object invokeJwtDecode(Runtime runtime, String authHeader) { if (splitValues.length != 2) { return null; } - Object result = runtime.call(ValueCreator.createObjectValue(ModuleUtils.getHttpPackage(), - JWT_DECODER_CLASS_NAME), JWT_DECODE_METHOD_NAME, StringUtils.fromString(splitValues[1])); + Object result = runtime.callMethod(ValueCreator.createObjectValue(ModuleUtils.getHttpPackage(), + JWT_DECODER_CLASS_NAME), JWT_DECODE_METHOD_NAME, null, StringUtils.fromString(splitValues[1])); if (!(result instanceof Exception)) { jwtInformation[0] = result; } diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/HttpRequestInterceptorUnitCallback.java b/native/src/main/java/io/ballerina/stdlib/http/api/HttpRequestInterceptorUnitCallback.java index 47408052b0..768df2b278 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/HttpRequestInterceptorUnitCallback.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/HttpRequestInterceptorUnitCallback.java @@ -19,12 +19,12 @@ package io.ballerina.stdlib.http.api; import io.ballerina.runtime.api.Runtime; +import io.ballerina.runtime.api.concurrent.StrandMetadata; import io.ballerina.runtime.api.types.ServiceType; import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BObject; -import io.ballerina.stdlib.http.api.nativeimpl.ModuleUtils; import io.ballerina.stdlib.http.transport.message.HttpCarbonMessage; import static io.ballerina.stdlib.http.api.HttpErrorType.INTERNAL_INTERCEPTOR_RETURN_ERROR; @@ -171,8 +171,8 @@ private void returnResponse(Object result) { public void invokeBalMethod(Object[] paramFeed, String methodName) { Thread.startVirtualThread(() -> { try { - runtime.startNonIsolatedWorker(caller, methodName, null, ModuleUtils.getNotifySuccessMetaData(), null - , paramFeed).get(); + StrandMetadata metaData = new StrandMetadata(false, null); + runtime.callMethod(caller, methodName, metaData, paramFeed); } catch (BError error) { cleanupRequestMessage(); HttpUtil.handleFailure(requestMessage, error); diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/HttpResource.java b/native/src/main/java/io/ballerina/stdlib/http/api/HttpResource.java index f3d1c9c85d..a570520160 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/HttpResource.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/HttpResource.java @@ -17,18 +17,18 @@ */ package io.ballerina.stdlib.http.api; -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.ArrayType; import io.ballerina.runtime.api.types.FiniteType; import io.ballerina.runtime.api.types.MapType; 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.RemoteMethodType; import io.ballerina.runtime.api.types.ResourceMethodType; 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/http/api/HttpResponseInterceptorUnitCallback.java b/native/src/main/java/io/ballerina/stdlib/http/api/HttpResponseInterceptorUnitCallback.java index ba3b1c8b8d..921d31de83 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/HttpResponseInterceptorUnitCallback.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/HttpResponseInterceptorUnitCallback.java @@ -20,12 +20,12 @@ import io.ballerina.runtime.api.Environment; import io.ballerina.runtime.api.Runtime; +import io.ballerina.runtime.api.concurrent.StrandMetadata; import io.ballerina.runtime.api.types.ServiceType; import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BObject; -import io.ballerina.stdlib.http.api.nativeimpl.ModuleUtils; import io.ballerina.stdlib.http.api.nativeimpl.connection.Respond; import io.ballerina.stdlib.http.transport.message.HttpCarbonMessage; @@ -156,8 +156,8 @@ private void returnResponse(Object result) { public void invokeBalMethod(Object[] paramFeed, String methodName) { Thread.startVirtualThread(() -> { try { - this.getRuntime().startIsolatedWorker(caller, methodName, null, - ModuleUtils.getNotifySuccessMetaData(), null, paramFeed).get(); + StrandMetadata metaData = new StrandMetadata(true, null); + this.getRuntime().callMethod(caller, methodName, metaData, paramFeed); stopObserverContext(); dataContext.notifyOutboundResponseStatus(null); } catch (BError error) { diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/HttpService.java b/native/src/main/java/io/ballerina/stdlib/http/api/HttpService.java index c3c3813620..7c52cf64f0 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/HttpService.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/HttpService.java @@ -17,14 +17,15 @@ */ package io.ballerina.stdlib.http.api; -import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.Runtime; +import io.ballerina.runtime.api.concurrent.StrandMetadata; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.flags.SymbolFlags; import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.MethodType; import io.ballerina.runtime.api.types.ObjectType; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.types.ResourceMethodType; import io.ballerina.runtime.api.types.ServiceType; import io.ballerina.runtime.api.utils.StringUtils; @@ -490,7 +491,8 @@ public static void populateInterceptorServicesRegistries(List { try { - String strandParentFunctionName = Objects.isNull(env.getStrandMetadata()) ? null : - env.getStrandMetadata().getParentFunctionName(); - if (Objects.nonNull(strandParentFunctionName) && strandParentFunctionName.equals("onMessage")) { - env.setStrandLocal(MAIN_STRAND, true); - } - return env.getRuntime().call(client, methodName, paramFeed); + return env.getRuntime().callMethod(client, methodName, new StrandMetadata(true, null), paramFeed); } catch (BError bError) { return HttpUtil.createHttpError("client method invocation failed: " + bError.getErrorMessage(), HttpErrorType.CLIENT_ERROR, bError); diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternFormatter.java b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternFormatter.java index ff37fd8856..06bccab2d1 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternFormatter.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternFormatter.java @@ -18,9 +18,9 @@ package io.ballerina.stdlib.http.api.nativeimpl; -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.BString; diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternRequest.java b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternRequest.java index 9f983561aa..3da6be6a16 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternRequest.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternRequest.java @@ -18,10 +18,10 @@ package io.ballerina.stdlib.http.api.nativeimpl; -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.MapType; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BString; diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternResponseProcessor.java b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternResponseProcessor.java index b326d2aa60..ff1d8184b2 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternResponseProcessor.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternResponseProcessor.java @@ -18,8 +18,6 @@ package io.ballerina.stdlib.http.api.nativeimpl; import io.ballerina.runtime.api.Environment; -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; @@ -28,9 +26,11 @@ import io.ballerina.runtime.api.types.Field; import io.ballerina.runtime.api.types.MapType; 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.ReferenceType; 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.JsonUtils; import io.ballerina.runtime.api.utils.StringUtils; @@ -252,7 +252,7 @@ private static Object generateStatusCodeResponseType(BObject response, boolean r payloadType = statusCodeRecordType.getFields().get(STATUS_CODE_RESPONSE_BODY_FIELD).getFieldType(); } try { - return env.getRuntime().call(response, BUILD_STATUS_CODE_RESPONSE, + return env.getRuntime().callMethod(response, BUILD_STATUS_CODE_RESPONSE, null, Objects.isNull(payloadType) ? null : ValueCreator.createTypedescValue(payloadType), ValueCreator.createTypedescValue(statusCodeRecordType), requireValidation, status, headers, mediaType, @@ -507,7 +507,7 @@ private static Object validateConstraints(boolean requireValidation, Object conv private static Object getStatusCodeResponseBindingError(Environment env, BObject response, String reasonPhrase) { try { - return env.getRuntime().call(response, GET_STATUS_CODE_RESPONSE_BINDING_ERROR, + return env.getRuntime().callMethod(response, GET_STATUS_CODE_RESPONSE_BINDING_ERROR, null, StringUtils.fromString(reasonPhrase)); } catch (BError error) { return createHttpError(APPLICATION_RES_ERROR_CREATION_FAILED, STATUS_CODE_RESPONSE_BINDING_ERROR, error); @@ -521,7 +521,7 @@ private static Object getStatusCodeResponseDataBindingError(Environment env, BOb BError cause, boolean isDefaultStatusCodeResponse, String errorType) { try { - return env.getRuntime().call(response, GET_STATUS_CODE_RESPONSE_DATA_BINDING_ERROR, + return env.getRuntime().callMethod(response, GET_STATUS_CODE_RESPONSE_DATA_BINDING_ERROR, null, StringUtils.fromString(reasonPhrase), isDefaultStatusCodeResponse, StringUtils.fromString(errorType), cause); } catch (BError error) { diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternUtils.java b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternUtils.java index 79e9e23422..87ad79e356 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternUtils.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ExternUtils.java @@ -16,10 +16,10 @@ package io.ballerina.stdlib.http.api.nativeimpl; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.creators.ErrorCreator; 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.utils.StringUtils; import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BError; diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ModuleUtils.java b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ModuleUtils.java index 59ff25b6d4..abb9af0ccb 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ModuleUtils.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ModuleUtils.java @@ -20,12 +20,9 @@ import io.ballerina.runtime.api.Environment; import io.ballerina.runtime.api.Module; -import io.ballerina.runtime.api.async.StrandMetadata; import io.ballerina.stdlib.http.api.HttpConstants; -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.http.api.HttpConstants.PROTOCOL_HTTP; /** * This class will hold module related utility functions. @@ -36,20 +33,14 @@ public class ModuleUtils { private static Module httpModule; private static Module httpStatusModule; - private static StrandMetadata onMessageMetaData; - private static StrandMetadata notifySuccessMetaData; private static String packageIdentifier; private ModuleUtils() {} public static void setModule(Environment env) { httpModule = env.getCurrentModule(); - onMessageMetaData = new StrandMetadata(BALLERINA_BUILTIN_PKG_PREFIX, PROTOCOL_HTTP, httpModule.getVersion(), - "onMessage"); - notifySuccessMetaData = new StrandMetadata(BALLERINA_BUILTIN_PKG_PREFIX, PROTOCOL_HTTP, httpModule.getVersion(), - "notifySuccess"); packageIdentifier = HttpConstants.PACKAGE + ORG_NAME_SEPARATOR + HttpConstants.PROTOCOL_HTTP + - HttpConstants.COLON + httpModule.getVersion(); + HttpConstants.COLON + httpModule.getMajorVersion(); } public static void setHttpStatusModule(Environment env) { @@ -74,24 +65,6 @@ public static Module getHttpStatusPackage() { return httpStatusModule; } - /** - * Gets the metadata of onMessage() method to invoke resource method. - * - * @return metadata of onMessage() method - */ - public static StrandMetadata getOnMessageMetaData() { - return onMessageMetaData; - } - - /** - * Gets the metadata of notifySuccess() method to invoke Caller.returnResponse() method. - * - * @return metadata of notifySuccess() method - */ - public static StrandMetadata getNotifySuccessMetaData() { - return notifySuccessMetaData; - } - /** * Gets ballerina http package identifier. * diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ParseHeader.java b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ParseHeader.java index 7443d5a53b..5efba561df 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ParseHeader.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/ParseHeader.java @@ -17,10 +17,10 @@ */ package io.ballerina.stdlib.http.api.nativeimpl; -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.ArrayType; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.types.RecordType; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.values.BArray; diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/connection/Respond.java b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/connection/Respond.java index 155eaadf9c..f10acc82a5 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/connection/Respond.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/nativeimpl/connection/Respond.java @@ -20,6 +20,9 @@ import io.ballerina.runtime.api.Environment; import io.ballerina.runtime.api.Runtime; +import io.ballerina.runtime.api.concurrent.StrandMetadata; +import io.ballerina.runtime.api.types.ObjectType; +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.observability.ObserveUtils; @@ -262,7 +265,10 @@ private static void startInterceptResponseMethod(HttpCarbonMessage inboundMessag String methodName = service.getServiceType().equals(HttpConstants.RESPONSE_ERROR_INTERCEPTOR) ? HttpConstants.INTERCEPT_RESPONSE_ERROR : HttpConstants.INTERCEPT_RESPONSE; try { - Object result = runtime.call(serviceObj, methodName, signatureParams); + ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(serviceObj)); + Object result = runtime.callMethod(serviceObj, methodName, + new StrandMetadata(serviceType.isIsolated() && serviceType.isIsolated(methodName), null), + signatureParams); callback.handleResult(result); } catch (BError bError) { callback.handlePanic(bError); diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/HeaderParam.java b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/HeaderParam.java index 9d4de89504..1a32b033a7 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/HeaderParam.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/HeaderParam.java @@ -29,7 +29,7 @@ import java.util.List; import java.util.Map; -import static io.ballerina.runtime.api.TypeTags.RECORD_TYPE_TAG; +import static io.ballerina.runtime.api.types.TypeTags.RECORD_TYPE_TAG; import static io.ballerina.stdlib.http.api.HttpConstants.HEADER_PARAM; import static io.ballerina.stdlib.http.api.HttpErrorType.INTERNAL_HEADER_VALIDATION_LISTENER_ERROR; diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/ParamHandler.java b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/ParamHandler.java index 213d80318d..d884f7b914 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/ParamHandler.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/ParamHandler.java @@ -18,10 +18,10 @@ package io.ballerina.stdlib.http.api.service.signature; -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.MapType; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.types.ResourceMethodType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.IdentifierUtils; diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/ParamUtils.java b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/ParamUtils.java index 3fdd17b173..cd12a54da1 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/ParamUtils.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/ParamUtils.java @@ -18,16 +18,16 @@ package io.ballerina.stdlib.http.api.service.signature; -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.FiniteType; import io.ballerina.runtime.api.types.IntersectionType; +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.types.UnionType; import io.ballerina.runtime.api.utils.JsonUtils; import io.ballerina.runtime.api.utils.StringUtils; @@ -42,19 +42,19 @@ import java.util.List; import java.util.Set; -import static io.ballerina.runtime.api.TypeTags.ARRAY_TAG; -import static io.ballerina.runtime.api.TypeTags.BOOLEAN_TAG; -import static io.ballerina.runtime.api.TypeTags.DECIMAL_TAG; -import static io.ballerina.runtime.api.TypeTags.FINITE_TYPE_TAG; -import static io.ballerina.runtime.api.TypeTags.FLOAT_TAG; -import static io.ballerina.runtime.api.TypeTags.INTERSECTION_TAG; -import static io.ballerina.runtime.api.TypeTags.INT_TAG; -import static io.ballerina.runtime.api.TypeTags.MAP_TAG; -import static io.ballerina.runtime.api.TypeTags.NULL_TAG; -import static io.ballerina.runtime.api.TypeTags.READONLY_TAG; -import static io.ballerina.runtime.api.TypeTags.RECORD_TYPE_TAG; -import static io.ballerina.runtime.api.TypeTags.STRING_TAG; -import static io.ballerina.runtime.api.TypeTags.UNION_TAG; +import static io.ballerina.runtime.api.types.TypeTags.ARRAY_TAG; +import static io.ballerina.runtime.api.types.TypeTags.BOOLEAN_TAG; +import static io.ballerina.runtime.api.types.TypeTags.DECIMAL_TAG; +import static io.ballerina.runtime.api.types.TypeTags.FINITE_TYPE_TAG; +import static io.ballerina.runtime.api.types.TypeTags.FLOAT_TAG; +import static io.ballerina.runtime.api.types.TypeTags.INTERSECTION_TAG; +import static io.ballerina.runtime.api.types.TypeTags.INT_TAG; +import static io.ballerina.runtime.api.types.TypeTags.MAP_TAG; +import static io.ballerina.runtime.api.types.TypeTags.NULL_TAG; +import static io.ballerina.runtime.api.types.TypeTags.READONLY_TAG; +import static io.ballerina.runtime.api.types.TypeTags.RECORD_TYPE_TAG; +import static io.ballerina.runtime.api.types.TypeTags.STRING_TAG; +import static io.ballerina.runtime.api.types.TypeTags.UNION_TAG; import static io.ballerina.stdlib.http.api.HttpConstants.PATH_PARAM; import static io.ballerina.stdlib.http.api.HttpConstants.QUERY_PARAM; diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/PayloadParam.java b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/PayloadParam.java index 4ce31f8fcb..375f289a1d 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/PayloadParam.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/PayloadParam.java @@ -18,11 +18,11 @@ package io.ballerina.stdlib.http.api.service.signature; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.IntersectionType; 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.TypeUtils; import io.ballerina.runtime.api.values.BError; @@ -39,7 +39,6 @@ import java.util.ArrayList; import java.util.List; -import static io.ballerina.runtime.api.TypeTags.ARRAY_TAG; import static io.ballerina.stdlib.http.api.HttpErrorType.INTERNAL_PAYLOAD_BINDING_LISTENER_ERROR; import static io.ballerina.stdlib.http.api.HttpErrorType.INTERNAL_PAYLOAD_VALIDATION_LISTENER_ERROR; import static io.ballerina.stdlib.http.api.service.signature.builder.AbstractPayloadBuilder.getBuilder; @@ -146,7 +145,7 @@ private void populateFeedWithAlreadyBuiltPayload(Object[] paramFeed, BObject inR Type payloadType, Object dataSource) { try { switch (payloadType.getTag()) { - case ARRAY_TAG: + case TypeTags.ARRAY_TAG: int actualTypeTag = TypeUtils.getReferredType(((ArrayType) payloadType).getElementType()).getTag(); if (actualTypeTag == TypeTags.BYTE_TAG) { paramFeed[index] = validateConstraints(dataSource); diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/AbstractPayloadBuilder.java b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/AbstractPayloadBuilder.java index 9140d229a8..222542c3a7 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/AbstractPayloadBuilder.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/AbstractPayloadBuilder.java @@ -18,10 +18,10 @@ package io.ballerina.stdlib.http.api.service.signature.builder; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.MapType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.types.TypedescType; import io.ballerina.runtime.api.types.UnionType; import io.ballerina.runtime.api.utils.TypeUtils; @@ -32,13 +32,13 @@ import java.util.List; import java.util.Locale; -import static io.ballerina.runtime.api.TypeTags.ARRAY_TAG; -import static io.ballerina.runtime.api.TypeTags.BYTE_ARRAY_TAG; -import static io.ballerina.runtime.api.TypeTags.BYTE_TAG; -import static io.ballerina.runtime.api.TypeTags.MAP_TAG; -import static io.ballerina.runtime.api.TypeTags.NULL_TAG; -import static io.ballerina.runtime.api.TypeTags.STRING_TAG; -import static io.ballerina.runtime.api.TypeTags.XML_TAG; +import static io.ballerina.runtime.api.types.TypeTags.ARRAY_TAG; +import static io.ballerina.runtime.api.types.TypeTags.BYTE_ARRAY_TAG; +import static io.ballerina.runtime.api.types.TypeTags.BYTE_TAG; +import static io.ballerina.runtime.api.types.TypeTags.MAP_TAG; +import static io.ballerina.runtime.api.types.TypeTags.NULL_TAG; +import static io.ballerina.runtime.api.types.TypeTags.STRING_TAG; +import static io.ballerina.runtime.api.types.TypeTags.XML_TAG; /** * The abstract class to build and convert the payload based on the content-type header. If the content type is not diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/ArrayBuilder.java b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/ArrayBuilder.java index 431bc01a26..0c9e0927dd 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/ArrayBuilder.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/ArrayBuilder.java @@ -18,9 +18,9 @@ package io.ballerina.stdlib.http.api.service.signature.builder; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.values.BObject; /** diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/BinaryPayloadBuilder.java b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/BinaryPayloadBuilder.java index 2c5b19037b..43e70e8f20 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/BinaryPayloadBuilder.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/BinaryPayloadBuilder.java @@ -18,9 +18,9 @@ package io.ballerina.stdlib.http.api.service.signature.builder; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.types.ArrayType; 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.values.BArray; import io.ballerina.runtime.api.values.BObject; diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/JsonPayloadBuilder.java b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/JsonPayloadBuilder.java index c66147d8c9..be220443ea 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/JsonPayloadBuilder.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/JsonPayloadBuilder.java @@ -18,8 +18,8 @@ package io.ballerina.stdlib.http.api.service.signature.builder; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.utils.ValueUtils; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BRefValue; diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/StringPayloadBuilder.java b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/StringPayloadBuilder.java index 90e963d6ac..11f78a3a6f 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/StringPayloadBuilder.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/StringPayloadBuilder.java @@ -18,10 +18,10 @@ package io.ballerina.stdlib.http.api.service.signature.builder; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.MapType; 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.values.BError; import io.ballerina.runtime.api.values.BObject; diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/XmlPayloadBuilder.java b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/XmlPayloadBuilder.java index e7f024d754..ac5fbc7c74 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/XmlPayloadBuilder.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/builder/XmlPayloadBuilder.java @@ -18,8 +18,8 @@ package io.ballerina.stdlib.http.api.service.signature.builder; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BXml; import io.ballerina.stdlib.http.api.HttpErrorType; diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/converter/StringToByteArrayConverter.java b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/converter/StringToByteArrayConverter.java index b1169dd0d0..b0cb33fd9b 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/converter/StringToByteArrayConverter.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/converter/StringToByteArrayConverter.java @@ -18,9 +18,9 @@ package io.ballerina.stdlib.http.api.service.signature.converter; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.values.BString; import io.ballerina.stdlib.http.api.HttpErrorType; import io.ballerina.stdlib.http.api.HttpUtil; diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/converter/UrlEncodedStringToMapConverter.java b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/converter/UrlEncodedStringToMapConverter.java index 018009ebd4..800ff00248 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/converter/UrlEncodedStringToMapConverter.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/service/signature/converter/UrlEncodedStringToMapConverter.java @@ -18,11 +18,11 @@ package io.ballerina.stdlib.http.api.service.signature.converter; -import io.ballerina.runtime.api.PredefinedTypes; 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.MapType; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.values.BMap; @@ -36,7 +36,7 @@ import java.util.HashMap; import java.util.Map; -import static io.ballerina.runtime.api.TypeTags.STRING_TAG; +import static io.ballerina.runtime.api.types.TypeTags.STRING_TAG; /** * The converter binds the URL encoded string payload to a Map. diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/util/CacheUtils.java b/native/src/main/java/io/ballerina/stdlib/http/api/util/CacheUtils.java index 6127f0bf61..112a08eaef 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/util/CacheUtils.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/util/CacheUtils.java @@ -18,7 +18,7 @@ package io.ballerina.stdlib.http.api.util; -import io.ballerina.runtime.api.PredefinedTypes; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.values.BString; import io.ballerina.stdlib.http.transport.message.HttpCarbonMessage;