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

[Connectors] Ballerina not reading connector info from .balx files properly #3222

Closed
pubudu91 opened this issue Aug 18, 2017 · 0 comments
Closed
Assignees

Comments

@pubudu91
Copy link
Contributor

There is an issue when reading .balx files and building the program model again. The connector info doesn't seem to be setting properly and it results in a null pointer exception being thrown at Java level. This issue is related to issue #3134 and PR #3176. Sample Ballerina code is given below:

import ballerina.lang.system;

function main (string[] args) {
	string test = testConnectorReturn("Pubudu", 26);
	system:println(test);

	string test2 = testConnectorReturnFromAction("Pubudu");
	system:println(test2);
}

connector Foo (string name, int age) {
    int userAge = 10 + age;
    string userName = "Ballerina" + name;

    action getUserName () (string) {
        return userName;
    }

    action getAge () (int) {
        return userAge;
    }
}

connector Bar (string name) {
    string userName = name;

    action returnConnectorFromAction () (Foo) {
        Foo foo = create Foo(userName, 1);
        return foo;
    }
}

function getFooConnector(string name, int age) (Foo) {
    Foo foo = create Foo(name, age);
    return foo;
}

function testConnectorReturn (string name, int age) (string) {
    Foo conn = getFooConnector(name, age);
    string userName = conn.getUserName();
    int userAge = conn.getAge();
    return "Username: " + userName + ", Age: " + userAge;
}

function testConnectorReturnFromAction (string name) (string) {
    Bar barCon = create Bar(name);
    Foo fooCon = barCon.returnConnectorFromAction();
    string userName = fooCon.getUserName();
    int userAge = fooCon.getAge();
    return "Username: " + userName + ", Age: " + userAge;
}

The error logged in the bre.log:

[2017-08-18 10:30:18,971]  ERROR {org.ballerinalang.launcher.Main} - ballerina: ballerina: invalid program file format 
org.ballerinalang.util.exceptions.ProgramFileFormatException: ballerina: invalid program file format
	at org.ballerinalang.BLangProgramLoader.read(BLangProgramLoader.java:52)
	at org.ballerinalang.launcher.LauncherUtils.runProgram(LauncherUtils.java:57)
	at org.ballerinalang.launcher.Main$RunCmd.execute(Main.java:233)
	at java.util.Optional.ifPresent(Optional.java:159)
	at org.ballerinalang.launcher.Main.main(Main.java:42)
Caused by: java.lang.NullPointerException
	at org.ballerinalang.util.codegen.ProgramFileReader.createBTypeFromSig(ProgramFileReader.java:791)
	at org.ballerinalang.util.codegen.ProgramFileReader.getParamTypes(ProgramFileReader.java:721)
	at org.ballerinalang.util.codegen.ProgramFileReader.setCallableUnitSignature(ProgramFileReader.java:712)
	at org.ballerinalang.util.codegen.ProgramFileReader.readConnectorInfoEntries(ProgramFileReader.java:462)
	at org.ballerinalang.util.codegen.ProgramFileReader.readPackageInfo(ProgramFileReader.java:337)
	at org.ballerinalang.util.codegen.ProgramFileReader.readProgramInternal(ProgramFileReader.java:135)
	at org.ballerinalang.util.codegen.ProgramFileReader.readProgram(ProgramFileReader.java:109)
	at org.ballerinalang.BLangProgramLoader.read(BLangProgramLoader.java:45)
	... 4 more
@pubudu91 pubudu91 changed the title Ballerina not reading connector info from .balx files properly [Connectors] Ballerina not reading connector info from .balx files properly Aug 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants