Skip to content

Commit

Permalink
Migrate runtime APIs and fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
HindujaB committed Nov 13, 2024
1 parent 6f660e7 commit 24c0aee
Show file tree
Hide file tree
Showing 32 changed files with 109 additions and 139 deletions.
8 changes: 4 additions & 4 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
37 changes: 20 additions & 17 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -490,7 +491,8 @@ public static void populateInterceptorServicesRegistries(List<HTTPInterceptorSer
if (includesInterceptableService) {
final Object[] createdInterceptors = new Object[1];
try {
Object response = runtime.call(service.getBalService(), CREATE_INTERCEPTORS_FUNCTION_NAME);
Object response = runtime.callMethod(service.getBalService(), CREATE_INTERCEPTORS_FUNCTION_NAME,
new StrandMetadata(true, null));
if (response instanceof BError) {
log.error("Error occurred while creating interceptors", response);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.Module;
import io.ballerina.runtime.api.Runtime;
import io.ballerina.runtime.api.TypeTags;
import io.ballerina.runtime.api.concurrent.StrandMetadata;
import io.ballerina.runtime.api.creators.ErrorCreator;
import io.ballerina.runtime.api.creators.ValueCreator;
import io.ballerina.runtime.api.types.Field;
Expand All @@ -31,6 +31,7 @@
import io.ballerina.runtime.api.types.RecordType;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.types.TypeId;
import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.utils.JsonUtils;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.utils.TypeUtils;
Expand Down Expand Up @@ -1644,7 +1645,8 @@ public static void populateInterceptorServicesFromService(BObject serviceEndpoin
public static void populateInterceptorServicesFromListener(BObject serviceEndpoint, Runtime runtime) {
final BArray[] interceptorResponse = new BArray[1];
try {
Object result = runtime.call(serviceEndpoint, CREATE_INTERCEPTORS_FUNCTION_NAME);
Object result = runtime.callMethod(serviceEndpoint, CREATE_INTERCEPTORS_FUNCTION_NAME,
new StrandMetadata(false, null));
if (result instanceof BArray) {
interceptorResponse[0] = (BArray) result;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
package io.ballerina.stdlib.http.api.client.actions;

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.ArrayType;
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.BError;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
package io.ballerina.stdlib.http.api.client.actions;

import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.TypeTags;
import io.ballerina.runtime.api.concurrent.StrandMetadata;
import io.ballerina.runtime.api.types.RecordType;
import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.api.values.BError;
Expand Down Expand Up @@ -55,7 +56,6 @@
import static io.ballerina.stdlib.http.api.HttpConstants.EMPTY;
import static io.ballerina.stdlib.http.api.HttpConstants.EQUAL_SIGN;
import static io.ballerina.stdlib.http.api.HttpConstants.ESCAPE_SLASH;
import static io.ballerina.stdlib.http.api.HttpConstants.MAIN_STRAND;
import static io.ballerina.stdlib.http.api.HttpConstants.QUESTION_MARK;
import static io.ballerina.stdlib.http.api.HttpConstants.QUOTATION_MARK;
import static io.ballerina.stdlib.http.api.HttpConstants.REGEX_FOR_FIELD;
Expand Down Expand Up @@ -208,12 +208,7 @@ private static Object invokeClientMethod(Environment env, BObject client, BStrin
private static Object invokeClientMethod(Environment env, BObject client, String methodName, Object[] paramFeed) {
return env.yieldAndRun(() -> {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 24c0aee

Please sign in to comment.