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

[Bug]: Simple POST request from a cURL client fails with NPE for a Ballerina service ran using lang master #42027

Closed
TharmiganK opened this issue Jan 22, 2024 · 2 comments · Fixed by #42030
Assignees
Labels
Area/Scheduler jBallerina runtime scheduler related issues Priority/High Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug
Milestone

Comments

@TharmiganK
Copy link
Contributor

Description

When we invoke a Ballerina service which runs with lang master, then the a simple POST request fails with the following error:

java.lang.NullPointerException: Cannot invoke "io.ballerina.runtime.internal.scheduling.Scheduler.createFuture(io.ballerina.runtime.internal.scheduling.Strand, io.ballerina.runtime.api.async.Callback, java.util.Map, io.ballerina.runtime.api.types.Type, String, io.ballerina.runtime.api.async.StrandMetadata)

Note: This is not happening if we invoke the service by adding a Ballerina test in the same package. This might be the reason for not identifying this issue in the full build pipeline PR check

Steps to Reproduce

Service code used to reproduce this issue:

import ballerina/http;

type Album readonly & record {|
    string title;
    string artist;
|};

final table<Album> key(title) albums = table [
    {title: "Blue Train", artist: "John Coltrane"},
    {title: "Sarah Vaughan and Clifford Brown", artist: "Sarah Vaughan"}
];

service / on new http:Listener(9090) {
    resource function get albums() returns Album[] {
        return albums.toArray();
    }

    resource function post albums(Album album) returns Album|http:Conflict {
        if albums.hasKey(album.title) {
            return http:CONFLICT;
        }
        albums.add(album);
        return album;
    }
}

Steps to reproduce this issue:

  1. I have used the following timestamped version of lang - 2201.9.0-20240120-003700-f65e7994. This is also reproducible when we build the lang master and use it in the http module

  2. Clone the ballerina-http repository and update the lang version in the gradle.properties file

  3. Run ./gradlew clean build -x test -x check. This will create a temporary distribution in the target path in the repo root.

  4. Use the bal command in that target directory to run the above Ballerina service

  5. Make a cURL request: curl -v "http://localhost:9090/albums" -d '{"title": "test", "artist": "test"}' -H "content-type: application/json"

Affected Version(s)

Ballerina SwanLake Update 9

OS, DB, other environment details and versions

No response

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@TharmiganK TharmiganK added Type/Bug Priority/High Area/Scheduler jBallerina runtime scheduler related issues labels Jan 22, 2024
@ballerina-bot ballerina-bot added the Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime label Jan 22, 2024
@HindujaB
Copy link
Contributor

I checked the cause for this not happening in the bal test environment. For bal run when we invoke the moduleStart to start listening, there are no jobs to be run further in the same scheduler. Therefore, it is garbage collected and set to null. For bal test this scenario won't happen as we invoke testExecute after the moduleStart which will use the same scheduler.

Copy link

github-actions bot commented Feb 1, 2024

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@HindujaB HindujaB added the Reason/EngineeringMistake The issue occurred due to a mistake made in the past. label Feb 1, 2024
@warunalakshitha warunalakshitha added this to the 2201.9.0 milestone Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Scheduler jBallerina runtime scheduler related issues Priority/High Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants