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

Reduce dump time #2130

Closed
Closed
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
2 changes: 0 additions & 2 deletions .github/workflows/build-timestamped-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ jobs:
if: ${{ github.repository_owner == 'ballerina-platform' }}
uses: ballerina-platform/ballerina-library/.github/workflows/build-timestamp-master-template.yml@main
secrets: inherit
with:
additional-build-flags: "-x test"
3 changes: 0 additions & 3 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@ jobs:
if: ${{ github.repository_owner == 'ballerina-platform' }}
uses: ballerina-platform/ballerina-library/.github/workflows/pull-request-build-template.yml@main
secrets: inherit
with:
additional-ubuntu-test-flags: "-x test"
additional-windows-test-flags: "-x test"
2 changes: 1 addition & 1 deletion 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=1.15.0-SNAPSHOT
ballerinaLangVersion=2201.11.0-20241209-162400-0c015833
ballerinaLangVersion=2201.11.0-20241212-181000-a1e03c5d

checkstylePluginVersion=10.12.0
spotbugsPluginVersion=6.0.18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
import io.ballerina.runtime.api.values.BString;
import io.ballerina.runtime.api.values.BTypedesc;

import java.util.concurrent.CompletableFuture;

import static io.ballerina.stdlib.graphql.runtime.utils.ModuleUtils.getResult;

/**
* This class is used to execute a GraphQL document using the Ballerina GraphQL client.
*/
Expand Down Expand Up @@ -67,15 +63,11 @@ private static Object invokeClientMethod(Environment env, BObject client, BStrin

private static Object invokeClientMethod(Environment env, BObject client, String methodName, Object[] paramFeed) {
return env.yieldAndRun(() -> {
CompletableFuture<Object> balFuture = new CompletableFuture<>();
QueryExecutorCallback executorCallback = new QueryExecutorCallback(balFuture);
try {
Object result = env.getRuntime().callMethod(client, methodName, null, paramFeed);
executorCallback.notifySuccess(result);
return env.getRuntime().callMethod(client, methodName, null, paramFeed);
} catch (BError bError) {
executorCallback.notifyFailure(bError);
return bError;
}
return getResult(balFuture);
});
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;

import static io.ballerina.runtime.api.types.TypeTags.INTERSECTION_TAG;
import static io.ballerina.stdlib.graphql.runtime.engine.EngineUtils.ARGUMENTS_FIELD;
Expand All @@ -64,6 +63,7 @@
import static io.ballerina.stdlib.graphql.runtime.engine.EngineUtils.isEnum;
import static io.ballerina.stdlib.graphql.runtime.engine.EngineUtils.isIgnoreType;
import static io.ballerina.stdlib.graphql.runtime.utils.Utils.INTERNAL_NODE;
import static io.ballerina.stdlib.graphql.runtime.utils.Utils.handleBErrorAndExit;
import static io.ballerina.stdlib.graphql.runtime.utils.Utils.isContext;
import static io.ballerina.stdlib.graphql.runtime.utils.Utils.isField;
import static io.ballerina.stdlib.graphql.runtime.utils.Utils.isFileUpload;
Expand Down Expand Up @@ -540,16 +540,13 @@ private boolean isRepresentationArgument(Type type) {

private void addConstraintValidationErrors(Environment environment, BArray errors) {
environment.yieldAndRun(() -> {
CompletableFuture<Object> future = new CompletableFuture<>();
ExecutionCallback executionCallback = new ExecutionCallback(future);
BObject fieldNode = this.field.getObjectValue(INTERNAL_NODE);
Object[] arguments = {errors, fieldNode};
try {
Object result = environment.getRuntime()
.callMethod(this.responseGenerator, ADD_CONSTRAINT_ERRORS_METHOD, null, arguments);
executionCallback.notifySuccess(result);
environment.getRuntime().callMethod(this.responseGenerator, ADD_CONSTRAINT_ERRORS_METHOD, null,
arguments);
} catch (BError bError) {
executionCallback.notifyFailure(bError);
handleBErrorAndExit(bError);
}
return null;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
import io.ballerina.runtime.api.values.BObject;
import io.ballerina.runtime.api.values.BTypedesc;

import java.util.concurrent.CompletableFuture;

import static io.ballerina.stdlib.graphql.runtime.utils.ModuleUtils.getResult;
import static io.ballerina.stdlib.graphql.runtime.utils.Utils.handleBErrorAndExit;

/**
* This class provides native implementations of the Ballerina DataLoader class.
Expand All @@ -38,17 +36,13 @@ private DataLoader() {

public static Object get(Environment env, BObject dataLoader, Object key, BTypedesc typedesc) {
return env.yieldAndRun(() -> {
CompletableFuture<Object> balFuture = new CompletableFuture<>();
Object[] paramFeed = getProcessGetMethodParams(key, typedesc);
ExecutionCallback executionCallback = new ExecutionCallback(balFuture);
try {
Object result = env.getRuntime().callMethod(dataLoader, DATA_LOADER_PROCESSES_GET_METHOD_NAME, null,
paramFeed);
executionCallback.notifySuccess(result);
return env.getRuntime().callMethod(dataLoader, DATA_LOADER_PROCESSES_GET_METHOD_NAME, null, paramFeed);
} catch (BError bError) {
executionCallback.notifyFailure(bError);
handleBErrorAndExit(bError);
}
return getResult(balFuture);
return null;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.CompletableFuture;

import static io.ballerina.runtime.observability.ObservabilityConstants.KEY_OBSERVER_CONTEXT;
import static io.ballerina.stdlib.graphql.commons.utils.TypeUtils.removeEscapeCharacter;
Expand All @@ -64,10 +63,10 @@
import static io.ballerina.stdlib.graphql.runtime.engine.EngineUtils.SUBSCRIBE_ACCESSOR;
import static io.ballerina.stdlib.graphql.runtime.engine.EngineUtils.isPathsMatching;
import static io.ballerina.stdlib.graphql.runtime.utils.ModuleUtils.getModule;
import static io.ballerina.stdlib.graphql.runtime.utils.ModuleUtils.getResult;
import static io.ballerina.stdlib.graphql.runtime.utils.Utils.ERROR_TYPE;
import static io.ballerina.stdlib.graphql.runtime.utils.Utils.INTERNAL_NODE;
import static io.ballerina.stdlib.graphql.runtime.utils.Utils.createError;
import static io.ballerina.stdlib.graphql.runtime.utils.Utils.handleBErrorAndExit;

/**
* This handles Ballerina GraphQL Engine.
Expand Down Expand Up @@ -133,16 +132,13 @@ private static Object getResultObject(Environment environment, BObject context,
return null;
}
return environment.yieldAndRun(() -> {
CompletableFuture<Object> subscriptionFutureResult = new CompletableFuture<>();
ExecutionCallback executionCallback = new ExecutionCallback(subscriptionFutureResult);
Object[] args = argumentHandler.getArguments();
try {
Object result = callResourceMethod(environment.getRuntime(), service, methodName, args);
executionCallback.notifySuccess(result);
return callResourceMethod(environment.getRuntime(), service, methodName, args);
} catch (BError bError) {
executionCallback.notifyFailure(bError);
handleBErrorAndExit(bError);
}
return getResult(subscriptionFutureResult);
return null;
});
}

Expand Down Expand Up @@ -183,17 +179,13 @@ public static Object executeInterceptor(Environment environment, BObject interce
return null;
}
return environment.yieldAndRun(() -> {
CompletableFuture<Object> future = new CompletableFuture<>();
ExecutionCallback executionCallback = new ExecutionCallback(future);
Object[] arguments = getInterceptorArguments(context, field);
try {
Object result = callResourceMethod(environment.getRuntime(), interceptor, remoteMethod.getName(),
arguments);
executionCallback.notifySuccess(result);
return callResourceMethod(environment.getRuntime(), interceptor, remoteMethod.getName(), arguments);
} catch (BError bError) {
executionCallback.notifyFailure(bError);
handleBErrorAndExit(bError);
}
return getResult(future);
return null;
});
}

Expand Down Expand Up @@ -283,16 +275,12 @@ public static boolean hasPrefetchMethod(BObject serviceObject, BString prefetchM
public static void executePrefetchMethod(Environment environment, BObject context, BObject service,
MethodType resourceMethod, BObject fieldObject) {
environment.yieldAndRun(() -> {
CompletableFuture<Object> future = new CompletableFuture<>();
ExecutionCallback executionCallback = new ExecutionCallback(future);
ArgumentHandler argumentHandler = new ArgumentHandler(resourceMethod, context, fieldObject, null, false);
Object[] arguments = argumentHandler.getArguments();
try {
Object result = callResourceMethod(environment.getRuntime(), service, resourceMethod.getName(),
arguments);
executionCallback.notifySuccess(result);
return callResourceMethod(environment.getRuntime(), service, resourceMethod.getName(), arguments);
} catch (BError bError) {
executionCallback.notifyFailure(bError);
handleBErrorAndExit(bError);
}
return null;
});
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,13 @@ private static boolean hasExpectedModuleName(Type type, String expectedModuleNam
public static BString getHashCode(BObject object) {
return StringUtils.fromString(Integer.toString(object.hashCode()));
}

public static void handleBErrorAndExit(BError bError) {
bError.printStackTrace();
// Service level `panic` is captured in this method.
// Since, `panic` is due to a critical application bug or resource exhaustion we need to exit the
// application.
// Please refer: https://github.com/ballerina-platform/ballerina-standard-library/issues/2714
System.exit(1);
}
}
14 changes: 7 additions & 7 deletions spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
<Bug pattern="BC_UNCONFIRMED_CAST" />
</And>
</Match>
<Match>
<And>
<Class name="io.ballerina.stdlib.graphql.runtime.engine.ExecutionCallback" />
<Method name = "notifyFailure" />
<Bug pattern="DM_EXIT" />
</And>
</Match>
<Match>
<Bug pattern="EI_EXPOSE_REP, EI_EXPOSE_REP2" />
</Match>
Expand All @@ -53,4 +46,11 @@
<Method name = "getServiceResolver" />
<Bug pattern="DCN_NULLPOINTER_EXCEPTION" />
</Match>
<Match>
<And>
<Class name="io.ballerina.stdlib.graphql.runtime.utils.Utils" />
<Method name = "handleBErrorAndExit" />
<Bug pattern="DM_EXIT" />
</And>
</Match>
</FindBugsFilter>
Loading