Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve callMethod Logic for java 21 #2106

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package io.ballerina.stdlib.graphql.runtime.engine;

import io.ballerina.runtime.api.Environment;
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.ArrayType;
Expand Down Expand Up @@ -547,8 +546,7 @@ private void addConstraintValidationErrors(Environment environment, BArray error
Object[] arguments = {errors, fieldNode};
try {
Object result = environment.getRuntime()
.callMethod(this.responseGenerator, ADD_CONSTRAINT_ERRORS_METHOD,
new StrandMetadata(true, null), arguments);
.callMethod(this.responseGenerator, ADD_CONSTRAINT_ERRORS_METHOD, null, arguments);
executionCallback.notifySuccess(result);
} catch (BError bError) {
executionCallback.notifyFailure(bError);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +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.creators.ErrorCreator;
import io.ballerina.runtime.api.types.IntersectionType;
import io.ballerina.runtime.api.types.MethodType;
import io.ballerina.runtime.api.types.ObjectType;
import io.ballerina.runtime.api.types.RemoteMethodType;
import io.ballerina.runtime.api.types.ResourceMethodType;
import io.ballerina.runtime.api.types.ServiceType;
Expand Down Expand Up @@ -138,12 +136,8 @@ private static Object getResultObject(Environment environment, BObject context,
CompletableFuture<Object> subscriptionFutureResult = new CompletableFuture<>();
ExecutionCallback executionCallback = new ExecutionCallback(subscriptionFutureResult);
Object[] args = argumentHandler.getArguments();
HashMap<String, Object> properties = null;
if (ObserveUtils.isObservabilityEnabled() && ObserveUtils.isTracingEnabled()) {
properties = getPropertiesToPropagate(environment, context);
}
try {
Object result = callResourceMethod(environment.getRuntime(), service, methodName, properties, args);
Object result = callResourceMethod(environment.getRuntime(), service, methodName, args);
executionCallback.notifySuccess(result);
} catch (BError bError) {
executionCallback.notifyFailure(bError);
Expand All @@ -152,12 +146,8 @@ private static Object getResultObject(Environment environment, BObject context,
});
}

private static Object callResourceMethod(Runtime runtime, BObject service, String methodName,
HashMap<String, Object> properties, Object[] args) {
ObjectType objectType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(service));
boolean isIsolated = objectType.isIsolated() && objectType.isIsolated(methodName);
StrandMetadata strandMetadata = new StrandMetadata(isIsolated, properties);
return runtime.callMethod(service, methodName, strandMetadata, args);
private static Object callResourceMethod(Runtime runtime, BObject service, String methodName, Object[] args) {
return runtime.callMethod(service, methodName, null, args);
}

public static Object executeQueryResource(Environment environment, BObject context, BObject service,
Expand Down Expand Up @@ -196,13 +186,9 @@ public static Object executeInterceptor(Environment environment, BObject interce
CompletableFuture<Object> future = new CompletableFuture<>();
ExecutionCallback executionCallback = new ExecutionCallback(future);
Object[] arguments = getInterceptorArguments(context, field);
HashMap<String, Object> properties = null;
if (ObserveUtils.isObservabilityEnabled() && ObserveUtils.isTracingEnabled()) {
properties = getPropertiesToPropagate(environment, context);
}
try {
Object result = callResourceMethod(environment.getRuntime(), interceptor, remoteMethod.getName(),
properties, arguments);
arguments);
executionCallback.notifySuccess(result);
} catch (BError bError) {
executionCallback.notifyFailure(bError);
Expand Down Expand Up @@ -301,13 +287,9 @@ public static void executePrefetchMethod(Environment environment, BObject contex
ExecutionCallback executionCallback = new ExecutionCallback(future);
ArgumentHandler argumentHandler = new ArgumentHandler(resourceMethod, context, fieldObject, null, false);
Object[] arguments = argumentHandler.getArguments();
HashMap<String, Object> properties = null;
if (ObserveUtils.isObservabilityEnabled() && ObserveUtils.isTracingEnabled()) {
properties = getPropertiesToPropagate(environment, context);
}
try {
Object result = callResourceMethod(environment.getRuntime(), service, resourceMethod.getName(),
properties, arguments);
arguments);
executionCallback.notifySuccess(result);
} catch (BError bError) {
executionCallback.notifyFailure(bError);
Expand Down
Loading