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

Remove unnecessary virtual thread creation #2267

Merged
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
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.11.0-20241218-101200-109f6cc7"
distribution-version = "2201.11.0-20250109-162500-c85851f4"

[[package]]
org = "ballerina"
Expand Down
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=2.13.0-SNAPSHOT
ballerinaLangVersion=2201.11.0-20241218-101200-109f6cc7
ballerinaLangVersion=2201.11.0-20250109-162500-c85851f4
ballerinaTomlParserVersion=1.2.2
commonsLang3Version=3.12.0
nettyVersion=4.1.115.Final
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,13 @@ private void returnErrorResponse(BError error) {
}

public void invokeBalMethod(Object[] paramFeed, String methodName) {
Thread.startVirtualThread(() -> {
try {
StrandMetadata metaData = new StrandMetadata(false, null);
runtime.callMethod(caller, methodName, metaData, paramFeed);
stopObserverContext();
} catch (BError error) {
sendFailureResponse(error);
}
});
try {
StrandMetadata metaData = new StrandMetadata(true, null);
runtime.callMethod(caller, methodName, metaData, paramFeed);
stopObserverContext();
} catch (BError error) {
sendFailureResponse(error);
}
}

public void stopObserverContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,13 @@ private void returnResponse(Object result) {
}

public void invokeBalMethod(Object[] paramFeed, String methodName) {
Thread.startVirtualThread(() -> {
try {
StrandMetadata metaData = new StrandMetadata(false, null);
runtime.callMethod(caller, methodName, metaData, paramFeed);
} catch (BError error) {
cleanupRequestMessage();
HttpUtil.handleFailure(requestMessage, error);
}
});
try {
StrandMetadata metaData = new StrandMetadata(true, null);
runtime.callMethod(caller, methodName, metaData, paramFeed);
} catch (BError error) {
cleanupRequestMessage();
HttpUtil.handleFailure(requestMessage, error);
}
}

private int getRequestInterceptorId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,16 @@ private void returnResponse(Object result) {

@Override
public void invokeBalMethod(Object[] paramFeed, String methodName) {
Thread.startVirtualThread(() -> {
try {
StrandMetadata metaData = new StrandMetadata(true, null);
this.getRuntime().callMethod(caller, methodName, metaData, paramFeed);
stopObserverContext();
dataContext.notifyOutboundResponseStatus(null);
} catch (BError error) {
dataContext.notifyOutboundResponseStatus(null);
sendFailureResponse(error);
}
});

try {
StrandMetadata metaData = new StrandMetadata(true, null);
this.getRuntime().callMethod(caller, methodName, metaData, paramFeed);
stopObserverContext();
dataContext.notifyOutboundResponseStatus(null);
} catch (BError error) {
dataContext.notifyOutboundResponseStatus(null);
sendFailureResponse(error);
}
}

private int getResponseInterceptorId() {
Expand Down
Loading