From 16c76f212389b9e6bdd8ea478c35d880ab3f8298 Mon Sep 17 00:00:00 2001 From: Thisaru Guruge Date: Thu, 20 Feb 2025 13:41:38 +0530 Subject: [PATCH] Fix Compiler Crash for Named Parameters in Listener Init (#2160) * Fix compiler crash for named parameters in listener init * [Automated] Update the native jar versions * Bump to the next minor version --- ballerina-tests/build.gradle | 2 + .../Ballerina.toml | 4 +- .../Dependencies.toml | 10 ++-- .../graphql-client-test-suite/Ballerina.toml | 4 +- .../Dependencies.toml | 10 ++-- .../Ballerina.toml | 4 +- .../Dependencies.toml | 10 ++-- .../Ballerina.toml | 4 +- .../Dependencies.toml | 10 ++-- .../Ballerina.toml | 4 +- .../Dependencies.toml | 10 ++-- .../graphql-service-test-suite/Ballerina.toml | 4 +- .../Dependencies.toml | 10 ++-- .../Ballerina.toml | 4 +- .../Dependencies.toml | 10 ++-- .../Ballerina.toml | 4 +- .../Dependencies.toml | 12 ++--- .../graphql-test-common/Ballerina.toml | 2 +- .../graphql-test-common/Dependencies.toml | 8 ++-- ballerina/Ballerina.toml | 10 ++-- ballerina/CompilerPlugin.toml | 4 +- ballerina/Dependencies.toml | 6 +-- changelog.md | 4 ++ .../compiler/ServiceValidationTest.java | 35 ++++++++++---- .../32_listener_init_parameters/service.bal | 7 +++ .../service/validator/ListenerValidator.java | 47 +++++++++++++++---- .../tests/test.bal | 15 ++---- gradle.properties | 2 +- 28 files changed, 154 insertions(+), 102 deletions(-) diff --git a/ballerina-tests/build.gradle b/ballerina-tests/build.gradle index 5fba1a8dc..fca347944 100644 --- a/ballerina-tests/build.gradle +++ b/ballerina-tests/build.gradle @@ -191,9 +191,11 @@ test { clean { delete "${project.projectDir}/${testCommonPackage}/target" + delete "${project.projectDir}/${testCommonPackage}/Dependencies.toml" testSuites.each { testPackage -> delete "${project.projectDir}/${testPackage}/target" + delete "${project.projectDir}/${testPackage}/Dependencies.toml" } } diff --git a/ballerina-tests/graphql-advanced-test-suite/Ballerina.toml b/ballerina-tests/graphql-advanced-test-suite/Ballerina.toml index b8c77b381..8b897e773 100644 --- a/ballerina-tests/graphql-advanced-test-suite/Ballerina.toml +++ b/ballerina-tests/graphql-advanced-test-suite/Ballerina.toml @@ -1,10 +1,10 @@ [package] org = "ballerina" name = "graphql_advanced_test_suite" -version = "1.15.0" +version = "1.16.0" [[dependency]] org = "ballerina" name = "graphql_test_common" repository = "local" -version = "1.15.0" +version = "1.16.0" diff --git a/ballerina-tests/graphql-advanced-test-suite/Dependencies.toml b/ballerina-tests/graphql-advanced-test-suite/Dependencies.toml index 1b0967516..e5313e1b2 100644 --- a/ballerina-tests/graphql-advanced-test-suite/Dependencies.toml +++ b/ballerina-tests/graphql-advanced-test-suite/Dependencies.toml @@ -73,7 +73,7 @@ dependencies = [ [[package]] org = "ballerina" name = "graphql" -version = "1.15.0" +version = "1.16.0" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -105,7 +105,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_advanced_test_suite" -version = "1.15.0" +version = "1.16.0" dependencies = [ {org = "ballerina", name = "constraint"}, {org = "ballerina", name = "graphql"}, @@ -123,7 +123,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_test_common" -version = "1.15.0" +version = "1.16.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "file"}, @@ -140,7 +140,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.13.0" +version = "2.13.3" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -396,7 +396,7 @@ dependencies = [ [[package]] org = "ballerina" name = "websocket" -version = "2.13.0" +version = "2.13.1" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "constraint"}, diff --git a/ballerina-tests/graphql-client-test-suite/Ballerina.toml b/ballerina-tests/graphql-client-test-suite/Ballerina.toml index 71213f0c7..9c9ac5c3b 100644 --- a/ballerina-tests/graphql-client-test-suite/Ballerina.toml +++ b/ballerina-tests/graphql-client-test-suite/Ballerina.toml @@ -1,10 +1,10 @@ [package] org = "ballerina" name = "graphql_client_test_suite" -version = "1.15.0" +version = "1.16.0" [[dependency]] org = "ballerina" name = "graphql_test_common" repository = "local" -version = "1.15.0" +version = "1.16.0" diff --git a/ballerina-tests/graphql-client-test-suite/Dependencies.toml b/ballerina-tests/graphql-client-test-suite/Dependencies.toml index f88e793f0..95d26223e 100644 --- a/ballerina-tests/graphql-client-test-suite/Dependencies.toml +++ b/ballerina-tests/graphql-client-test-suite/Dependencies.toml @@ -76,7 +76,7 @@ dependencies = [ [[package]] org = "ballerina" name = "graphql" -version = "1.15.0" +version = "1.16.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -109,7 +109,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_client_test_suite" -version = "1.15.0" +version = "1.16.0" dependencies = [ {org = "ballerina", name = "graphql"}, {org = "ballerina", name = "graphql_test_common"}, @@ -122,7 +122,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_test_common" -version = "1.15.0" +version = "1.16.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "file"}, @@ -139,7 +139,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.13.0" +version = "2.13.3" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -404,7 +404,7 @@ dependencies = [ [[package]] org = "ballerina" name = "websocket" -version = "2.13.0" +version = "2.13.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, diff --git a/ballerina-tests/graphql-dataloader-test-suite/Ballerina.toml b/ballerina-tests/graphql-dataloader-test-suite/Ballerina.toml index 86d497e6e..249ae9565 100644 --- a/ballerina-tests/graphql-dataloader-test-suite/Ballerina.toml +++ b/ballerina-tests/graphql-dataloader-test-suite/Ballerina.toml @@ -1,10 +1,10 @@ [package] org = "ballerina" name = "graphql_dataloader_test_suite" -version = "1.15.0" +version = "1.16.0" [[dependency]] org = "ballerina" name = "graphql_test_common" repository = "local" -version = "1.15.0" +version = "1.16.0" diff --git a/ballerina-tests/graphql-dataloader-test-suite/Dependencies.toml b/ballerina-tests/graphql-dataloader-test-suite/Dependencies.toml index 44f186ee2..dcbb7f767 100644 --- a/ballerina-tests/graphql-dataloader-test-suite/Dependencies.toml +++ b/ballerina-tests/graphql-dataloader-test-suite/Dependencies.toml @@ -76,7 +76,7 @@ dependencies = [ [[package]] org = "ballerina" name = "graphql" -version = "1.15.0" +version = "1.16.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -109,7 +109,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_dataloader_test_suite" -version = "1.15.0" +version = "1.16.0" dependencies = [ {org = "ballerina", name = "graphql"}, {org = "ballerina", name = "graphql_test_common"}, @@ -124,7 +124,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_test_common" -version = "1.15.0" +version = "1.16.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "file"}, @@ -141,7 +141,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.13.0" +version = "2.13.3" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -410,7 +410,7 @@ dependencies = [ [[package]] org = "ballerina" name = "websocket" -version = "2.13.0" +version = "2.13.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, diff --git a/ballerina-tests/graphql-interceptor-test-suite/Ballerina.toml b/ballerina-tests/graphql-interceptor-test-suite/Ballerina.toml index 8a5c28d90..0a050319f 100644 --- a/ballerina-tests/graphql-interceptor-test-suite/Ballerina.toml +++ b/ballerina-tests/graphql-interceptor-test-suite/Ballerina.toml @@ -1,10 +1,10 @@ [package] org = "ballerina" name = "graphql_interceptor_test_suite" -version = "1.15.0" +version = "1.16.0" [[dependency]] org = "ballerina" name = "graphql_test_common" repository = "local" -version = "1.15.0" +version = "1.16.0" diff --git a/ballerina-tests/graphql-interceptor-test-suite/Dependencies.toml b/ballerina-tests/graphql-interceptor-test-suite/Dependencies.toml index be0a5f46b..e56cda286 100644 --- a/ballerina-tests/graphql-interceptor-test-suite/Dependencies.toml +++ b/ballerina-tests/graphql-interceptor-test-suite/Dependencies.toml @@ -76,7 +76,7 @@ dependencies = [ [[package]] org = "ballerina" name = "graphql" -version = "1.15.0" +version = "1.16.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -109,7 +109,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_interceptor_test_suite" -version = "1.15.0" +version = "1.16.0" dependencies = [ {org = "ballerina", name = "graphql"}, {org = "ballerina", name = "graphql_test_common"}, @@ -124,7 +124,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_test_common" -version = "1.15.0" +version = "1.16.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "file"}, @@ -141,7 +141,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.13.0" +version = "2.13.3" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -413,7 +413,7 @@ dependencies = [ [[package]] org = "ballerina" name = "websocket" -version = "2.13.0" +version = "2.13.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, diff --git a/ballerina-tests/graphql-security-test-suite/Ballerina.toml b/ballerina-tests/graphql-security-test-suite/Ballerina.toml index 4f1c2c7bd..f39c23e08 100644 --- a/ballerina-tests/graphql-security-test-suite/Ballerina.toml +++ b/ballerina-tests/graphql-security-test-suite/Ballerina.toml @@ -1,10 +1,10 @@ [package] org = "ballerina" name = "graphql_security_test_suite" -version = "1.15.0" +version = "1.16.0" [[dependency]] org = "ballerina" name = "graphql_test_common" repository = "local" -version = "1.15.0" +version = "1.16.0" diff --git a/ballerina-tests/graphql-security-test-suite/Dependencies.toml b/ballerina-tests/graphql-security-test-suite/Dependencies.toml index fd8816c2a..3f866bfd7 100644 --- a/ballerina-tests/graphql-security-test-suite/Dependencies.toml +++ b/ballerina-tests/graphql-security-test-suite/Dependencies.toml @@ -76,7 +76,7 @@ dependencies = [ [[package]] org = "ballerina" name = "graphql" -version = "1.15.0" +version = "1.16.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -109,7 +109,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_security_test_suite" -version = "1.15.0" +version = "1.16.0" dependencies = [ {org = "ballerina", name = "graphql"}, {org = "ballerina", name = "graphql_test_common"}, @@ -123,7 +123,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_test_common" -version = "1.15.0" +version = "1.16.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "file"}, @@ -140,7 +140,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.13.0" +version = "2.13.3" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -409,7 +409,7 @@ dependencies = [ [[package]] org = "ballerina" name = "websocket" -version = "2.13.0" +version = "2.13.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, diff --git a/ballerina-tests/graphql-service-test-suite/Ballerina.toml b/ballerina-tests/graphql-service-test-suite/Ballerina.toml index e5e1519ef..03973be07 100644 --- a/ballerina-tests/graphql-service-test-suite/Ballerina.toml +++ b/ballerina-tests/graphql-service-test-suite/Ballerina.toml @@ -1,10 +1,10 @@ [package] org = "ballerina" name = "graphql_service_test_suite" -version = "1.15.0" +version = "1.16.0" [[dependency]] org = "ballerina" name = "graphql_test_common" repository = "local" -version = "1.15.0" +version = "1.16.0" diff --git a/ballerina-tests/graphql-service-test-suite/Dependencies.toml b/ballerina-tests/graphql-service-test-suite/Dependencies.toml index 5c6cbbeb3..48695e3de 100644 --- a/ballerina-tests/graphql-service-test-suite/Dependencies.toml +++ b/ballerina-tests/graphql-service-test-suite/Dependencies.toml @@ -70,7 +70,7 @@ dependencies = [ [[package]] org = "ballerina" name = "graphql" -version = "1.15.0" +version = "1.16.0" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -102,7 +102,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_service_test_suite" -version = "1.15.0" +version = "1.16.0" dependencies = [ {org = "ballerina", name = "graphql"}, {org = "ballerina", name = "graphql_test_common"}, @@ -120,7 +120,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_test_common" -version = "1.15.0" +version = "1.16.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "file"}, @@ -137,7 +137,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.13.0" +version = "2.13.3" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -396,7 +396,7 @@ modules = [ [[package]] org = "ballerina" name = "websocket" -version = "2.13.0" +version = "2.13.1" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "constraint"}, diff --git a/ballerina-tests/graphql-subgraph-test-suite/Ballerina.toml b/ballerina-tests/graphql-subgraph-test-suite/Ballerina.toml index d9513b046..d8060e33d 100644 --- a/ballerina-tests/graphql-subgraph-test-suite/Ballerina.toml +++ b/ballerina-tests/graphql-subgraph-test-suite/Ballerina.toml @@ -1,10 +1,10 @@ [package] org = "ballerina" name = "graphql_subgraph_test_suite" -version = "1.15.0" +version = "1.16.0" [[dependency]] org = "ballerina" name = "graphql_test_common" repository = "local" -version = "1.15.0" +version = "1.16.0" diff --git a/ballerina-tests/graphql-subgraph-test-suite/Dependencies.toml b/ballerina-tests/graphql-subgraph-test-suite/Dependencies.toml index 6c643955f..b2a9cdc77 100644 --- a/ballerina-tests/graphql-subgraph-test-suite/Dependencies.toml +++ b/ballerina-tests/graphql-subgraph-test-suite/Dependencies.toml @@ -70,7 +70,7 @@ dependencies = [ [[package]] org = "ballerina" name = "graphql" -version = "1.15.0" +version = "1.16.0" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -102,7 +102,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_subgraph_test_suite" -version = "1.15.0" +version = "1.16.0" dependencies = [ {org = "ballerina", name = "graphql"}, {org = "ballerina", name = "graphql_test_common"}, @@ -115,7 +115,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_test_common" -version = "1.15.0" +version = "1.16.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "file"}, @@ -132,7 +132,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.13.0" +version = "2.13.3" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -375,7 +375,7 @@ dependencies = [ [[package]] org = "ballerina" name = "websocket" -version = "2.13.0" +version = "2.13.1" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "constraint"}, diff --git a/ballerina-tests/graphql-subscription-test-suite/Ballerina.toml b/ballerina-tests/graphql-subscription-test-suite/Ballerina.toml index 7bdeb29e8..49cb376e8 100644 --- a/ballerina-tests/graphql-subscription-test-suite/Ballerina.toml +++ b/ballerina-tests/graphql-subscription-test-suite/Ballerina.toml @@ -1,10 +1,10 @@ [package] org = "ballerina" name = "graphql_subscription_test_suite" -version = "1.15.0" +version = "1.16.0" [[dependency]] org = "ballerina" name = "graphql_test_common" repository = "local" -version = "1.15.0" +version = "1.16.0" diff --git a/ballerina-tests/graphql-subscription-test-suite/Dependencies.toml b/ballerina-tests/graphql-subscription-test-suite/Dependencies.toml index 8564789de..be899895c 100644 --- a/ballerina-tests/graphql-subscription-test-suite/Dependencies.toml +++ b/ballerina-tests/graphql-subscription-test-suite/Dependencies.toml @@ -5,7 +5,7 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.11.0-20250127-101700-a4b67fe5" +distribution-version = "2201.11.0" [[package]] org = "ballerina" @@ -79,7 +79,7 @@ dependencies = [ [[package]] org = "ballerina" name = "graphql" -version = "1.15.0" +version = "1.16.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -112,7 +112,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_subscription_test_suite" -version = "1.15.0" +version = "1.16.0" dependencies = [ {org = "ballerina", name = "constraint"}, {org = "ballerina", name = "graphql"}, @@ -135,7 +135,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_test_common" -version = "1.15.0" +version = "1.16.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "file"}, @@ -152,7 +152,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.13.0" +version = "2.13.3" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -424,7 +424,7 @@ dependencies = [ [[package]] org = "ballerina" name = "websocket" -version = "2.13.0" +version = "2.13.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, diff --git a/ballerina-tests/graphql-test-common/Ballerina.toml b/ballerina-tests/graphql-test-common/Ballerina.toml index 22af14b38..c15bc0880 100644 --- a/ballerina-tests/graphql-test-common/Ballerina.toml +++ b/ballerina-tests/graphql-test-common/Ballerina.toml @@ -1,4 +1,4 @@ [package] org = "ballerina" name = "graphql_test_common" -version = "1.15.0" +version = "1.16.0" diff --git a/ballerina-tests/graphql-test-common/Dependencies.toml b/ballerina-tests/graphql-test-common/Dependencies.toml index 346c9a367..3d1b4c72f 100644 --- a/ballerina-tests/graphql-test-common/Dependencies.toml +++ b/ballerina-tests/graphql-test-common/Dependencies.toml @@ -73,7 +73,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql" -version = "1.15.0" +version = "1.16.0" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -105,7 +105,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql_test_common" -version = "1.15.0" +version = "1.16.0" dependencies = [ {org = "ballerina", name = "file"}, {org = "ballerina", name = "graphql"}, @@ -121,7 +121,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.13.0" +version = "2.13.3" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -369,7 +369,7 @@ dependencies = [ [[package]] org = "ballerina" name = "websocket" -version = "2.13.0" +version = "2.13.1" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "constraint"}, diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index b3ce01602..829aae38b 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerina" name = "graphql" -version = "1.15.0" +version = "1.16.0" authors = ["Ballerina"] keywords = ["gql", "network", "query", "service"] repository = "https://github.com/ballerina-platform/module-ballerina-graphql" @@ -30,11 +30,11 @@ graalvmCompatible = true [[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "graphql-native" -version = "1.15.0" -path = "../native/build/libs/graphql-native-1.15.0.jar" +version = "1.16.0" +path = "../native/build/libs/graphql-native-1.16.0-SNAPSHOT.jar" [[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "graphql-commons" -version = "1.15.0" -path = "../commons/build/libs/graphql-commons-1.15.0.jar" +version = "1.16.0" +path = "../commons/build/libs/graphql-commons-1.16.0-SNAPSHOT.jar" diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index 4e2f46346..d97923eb6 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -3,7 +3,7 @@ id = "graphql-compiler-plugin" class = "io.ballerina.stdlib.graphql.compiler.GraphqlCompilerPlugin" [[dependency]] -path = "../compiler-plugin/build/libs/graphql-compiler-plugin-1.15.0.jar" +path = "../compiler-plugin/build/libs/graphql-compiler-plugin-1.16.0-SNAPSHOT.jar" [[dependency]] -path = "../commons/build/libs/graphql-commons-1.15.0.jar" +path = "../commons/build/libs/graphql-commons-1.16.0-SNAPSHOT.jar" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index d444295a7..9bd003b56 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -82,7 +82,7 @@ modules = [ [[package]] org = "ballerina" name = "graphql" -version = "1.15.0" +version = "1.16.0" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -115,7 +115,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.13.0" +version = "2.13.3" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -402,7 +402,7 @@ modules = [ [[package]] org = "ballerina" name = "websocket" -version = "2.13.0" +version = "2.13.1" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "constraint"}, diff --git a/changelog.md b/changelog.md index 72dbe61f3..96bbd87f6 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Fixed + +- [[#7555] Fix Compiler Crash when Listener Init Parameters are Passed as Named Parameters](https://github.com/ballerina-platform/ballerina-library/issues/7555) + ## [1.15.0] - 2025-02-08 ### Added diff --git a/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/graphql/compiler/ServiceValidationTest.java b/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/graphql/compiler/ServiceValidationTest.java index 72015f6d2..65c985e59 100644 --- a/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/graphql/compiler/ServiceValidationTest.java +++ b/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/graphql/compiler/ServiceValidationTest.java @@ -406,23 +406,38 @@ public void testReturningOnlyError() { public void testListenerInitParameters() { String packagePath = "32_listener_init_parameters"; DiagnosticResult diagnosticResult = getDiagnosticResult(packagePath); - Assert.assertEquals(diagnosticResult.errorCount(), 5); + Assert.assertEquals(diagnosticResult.errorCount(), 10); Iterator diagnosticIterator = diagnosticResult.errors().iterator(); Diagnostic diagnostic = diagnosticIterator.next(); - assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 29, 58); + assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 30, 43); + + diagnostic = diagnosticIterator.next(); + assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 31, 49); + + diagnostic = diagnosticIterator.next(); + assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 32, 60); + + diagnostic = diagnosticIterator.next(); + assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 33, 66); + + diagnostic = diagnosticIterator.next(); + assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 34, 44); + + diagnostic = diagnosticIterator.next(); + assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 35, 50); diagnostic = diagnosticIterator.next(); - assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 30, 64); + assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 36, 73); diagnostic = diagnosticIterator.next(); - assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 31, 75); + assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 37, 79); diagnostic = diagnosticIterator.next(); - assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 32, 81); + assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 38, 95); diagnostic = diagnosticIterator.next(); - assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 34, 64); + assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 41, 49); } @Test(groups = "invalid") @@ -560,16 +575,16 @@ public void testInvalidListenerInitParameters() { Iterator diagnosticIterator = diagnosticResult.errors().iterator(); Diagnostic diagnostic = diagnosticIterator.next(); - assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 24, 58); + assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 24, 43); diagnostic = diagnosticIterator.next(); - assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 25, 64); + assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 25, 49); diagnostic = diagnosticIterator.next(); - assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 26, 75); + assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 26, 60); diagnostic = diagnosticIterator.next(); - assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 27, 81); + assertError(diagnostic, CompilationDiagnostic.INVALID_LISTENER_INIT, 27, 66); } @Test(groups = "invalid") diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/validator_tests/32_listener_init_parameters/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/validator_tests/32_listener_init_parameters/service.bal index 282424f84..6311e4744 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/validator_tests/32_listener_init_parameters/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/validator_tests/32_listener_init_parameters/service.bal @@ -26,10 +26,17 @@ graphql:ListenerConfiguration configs = { timeout: 1.0 }; +listener graphql:Listener listener0 = new (9090, configs); listener graphql:Listener listener1 = new(httpListener1, configs); listener graphql:Listener listener2 = check new(httpListener2, configs); listener graphql:Listener listener3 = new graphql:Listener(httpListener3, configs); listener graphql:Listener listener4 = check new graphql:Listener(httpListener4, configs); +listener graphql:Listener listener5 = new (listenTo = httpListener1, httpVersion = http:HTTP_2_0); +listener graphql:Listener listener6 = check new (listenTo = httpListener2, httpVersion = http:HTTP_2_0); +listener graphql:Listener listener7 = new (httpVersion = http:HTTP_2_0, listenTo = httpListener3); +listener graphql:Listener listener8 = check new (httpVersion = http:HTTP_2_0, listenTo = httpListener4); +listener graphql:Listener listener9 = new (httpVersion = http:HTTP_2_0, host = "192.168.1.1", listenTo = httpListener1); +listener graphql:Listener listener10 = check new (httpVersion = http:HTTP_2_0, host = "192.168.1.1", listenTo = 9090); service graphql:Service on new graphql:Listener(httpListener1, configs) { resource function get name() returns string { diff --git a/compiler-plugin/src/main/java/io/ballerina/stdlib/graphql/compiler/service/validator/ListenerValidator.java b/compiler-plugin/src/main/java/io/ballerina/stdlib/graphql/compiler/service/validator/ListenerValidator.java index 1ed723136..46e5f45d6 100644 --- a/compiler-plugin/src/main/java/io/ballerina/stdlib/graphql/compiler/service/validator/ListenerValidator.java +++ b/compiler-plugin/src/main/java/io/ballerina/stdlib/graphql/compiler/service/validator/ListenerValidator.java @@ -26,12 +26,14 @@ import io.ballerina.compiler.syntax.tree.FunctionArgumentNode; import io.ballerina.compiler.syntax.tree.ImplicitNewExpressionNode; import io.ballerina.compiler.syntax.tree.ListenerDeclarationNode; +import io.ballerina.compiler.syntax.tree.NamedArgumentNode; import io.ballerina.compiler.syntax.tree.PositionalArgumentNode; import io.ballerina.compiler.syntax.tree.SeparatedNodeList; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.projects.plugins.AnalysisTask; import io.ballerina.projects.plugins.SyntaxNodeAnalysisContext; import io.ballerina.stdlib.graphql.compiler.diagnostics.CompilationDiagnostic; +import io.ballerina.tools.diagnostics.Location; import static io.ballerina.stdlib.graphql.compiler.Utils.isGraphqlListener; import static io.ballerina.stdlib.graphql.compiler.service.validator.ValidatorUtils.updateContext; @@ -40,6 +42,8 @@ * Validates Ballerina GraphQL Listener Initializations. */ public class ListenerValidator implements AnalysisTask { + private static final String LISTEN_TO = "listenTo"; + @Override public void perform(SyntaxNodeAnalysisContext context) { if (context.node().kind() == SyntaxKind.EXPLICIT_NEW_EXPRESSION) { @@ -100,21 +104,46 @@ private void validateImplicitNewListener(SyntaxNodeAnalysisContext context, Impl private void validateListenerArguments(SyntaxNodeAnalysisContext context, SeparatedNodeList arguments) { + if (arguments.size() < 2) { + return; + } // two args are valid only if the first arg is numeric (i.e, port and config) - if (arguments.size() > 1) { - PositionalArgumentNode firstArg = (PositionalArgumentNode) arguments.get(0); - if (context.semanticModel().symbol(firstArg.expression()).isEmpty()) { + FunctionArgumentNode firstArg = arguments.get(0); + if (firstArg.kind() == SyntaxKind.POSITIONAL_ARG) { + PositionalArgumentNode positionalArgumentNode = (PositionalArgumentNode) firstArg; + if (context.semanticModel().symbol(positionalArgumentNode.expression()).isEmpty()) { return; } - Symbol firstArgSymbol = context.semanticModel().symbol(firstArg.expression()).get(); - if (firstArgSymbol.kind() == SymbolKind.VARIABLE) { - VariableSymbol variableSymbol = (VariableSymbol) firstArgSymbol; - if (variableSymbol.typeDescriptor().typeKind() == TypeDescKind.INT) { + Symbol firstArgSymbol = context.semanticModel().symbol(positionalArgumentNode.expression()).get(); + validateListenerArgSymbol(context, firstArgSymbol, positionalArgumentNode.location()); + } else if (firstArg.kind() == SyntaxKind.NAMED_ARG) { + validateListenerNamedArguments(context, arguments); + } + } + + private void validateListenerNamedArguments(SyntaxNodeAnalysisContext context, + SeparatedNodeList arguments) { + for (FunctionArgumentNode argument : arguments) { + // Casting directly to NamedArgumentNode as the kind is already checked + NamedArgumentNode namedArgument = (NamedArgumentNode) argument; + String argumentName = namedArgument.argumentName().name().text(); + if (argumentName.equals(LISTEN_TO)) { + if (context.semanticModel().symbol(namedArgument.expression()).isEmpty()) { return; } + Symbol argumentNodeSymbol = context.semanticModel().symbol(namedArgument.expression()).get(); + validateListenerArgSymbol(context, argumentNodeSymbol, namedArgument.location()); + } + } + } + + private void validateListenerArgSymbol(SyntaxNodeAnalysisContext context, Symbol argumentNodeSymbol, + Location location) { + if (argumentNodeSymbol.kind() == SymbolKind.VARIABLE) { + VariableSymbol variableSymbol = (VariableSymbol) argumentNodeSymbol; + if (variableSymbol.typeDescriptor().typeKind() != TypeDescKind.INT) { + updateContext(context, CompilationDiagnostic.INVALID_LISTENER_INIT, location); } - FunctionArgumentNode secondArg = arguments.get(1); - updateContext(context, CompilationDiagnostic.INVALID_LISTENER_INIT, secondArg.location()); } } } diff --git a/examples/simple_github_issue_tracker/tests/test.bal b/examples/simple_github_issue_tracker/tests/test.bal index b707da405..a03cbd40e 100644 --- a/examples/simple_github_issue_tracker/tests/test.bal +++ b/examples/simple_github_issue_tracker/tests/test.bal @@ -1,8 +1,7 @@ import ballerina/test; @test:Config { - groups: ["query"], - enable: true + groups: ["query"] } function testUser() returns error? { string query = "query { user { login } }"; @@ -18,8 +17,7 @@ function testUser() returns error? { } @test:Config { - groups: ["query"], - enable: true + groups: ["query"] } function testRepositories() returns error? { string query = "query { repositories { name }}"; @@ -31,8 +29,7 @@ function testRepositories() returns error? { } @test:Config { - groups: ["query"], - enable: true + groups: ["query"] } function testRepository() returns error? { string repoName = "Module-Ballerina-GraphQL"; @@ -49,8 +46,7 @@ function testRepository() returns error? { } @test:Config { - groups: ["query"], - enable: true + groups: ["query"] } function testBranches() returns error? { string repoName = "Module-Ballerina-GraphQL"; @@ -70,8 +66,7 @@ function testBranches() returns error? { } @test:Config { - groups: ["mutation"], - enable: true + groups: ["mutation"] } function createRepository() returns error? { string repoName = "Test-Repo"; diff --git a/gradle.properties b/gradle.properties index fb3ea1d78..54ade8256 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.caching=true group=io.ballerina.stdlib -version=1.15.1-SNAPSHOT +version=1.16.0-SNAPSHOT ballerinaLangVersion=2201.11.0 checkstylePluginVersion=10.12.0