Skip to content

Commit

Permalink
Merge pull request #2106 from HindujaB/java21
Browse files Browse the repository at this point in the history
Improve callMethod Logic for java 21
  • Loading branch information
warunalakshitha authored Nov 28, 2024
2 parents 9be4f77 + 4cb698e commit 149b571
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
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

0 comments on commit 149b571

Please sign in to comment.