From 85875fb3fff0ceb9657946026bc9f98f9dbc86de Mon Sep 17 00:00:00 2001 From: ravinperera00 Date: Sun, 3 Nov 2024 12:15:08 +0530 Subject: [PATCH 1/2] Migrate to Java 21 --- .../workflows/build-timestamped-master.yml | 2 +- .../workflows/build-with-bal-test-graalvm.yml | 2 +- .github/workflows/central-publish.yml | 2 +- .github/workflows/publish-release.yml | 2 +- .github/workflows/pull-request.yml | 2 +- .github/workflows/trivy-scan.yml | 2 +- README.md | 2 +- ballerina-tests/Ballerina.toml | 8 +-- ballerina-tests/Dependencies.toml | 45 ++++++------ ballerina/Ballerina.toml | 10 +-- ballerina/CompilerPlugin.toml | 2 +- ballerina/Dependencies.toml | 45 ++++++------ build-config/resources/Ballerina.toml | 4 +- build-config/resources/BallerinaTest.toml | 4 +- build.gradle | 8 +-- compiler-plugin-tests/build.gradle | 7 +- compiler-plugin/build.gradle | 7 +- .../ServiceDeclarationValidator.java | 4 ++ gradle.properties | 45 ++++++------ native/build.gradle | 7 +- .../ballerina/stdlib/websub/ModuleUtils.java | 41 +++++++++++ .../websub/NativeHttpToWebsubAdaptor.java | 44 +++++++----- .../stdlib/websub/SubscriberCallback.java | 71 ------------------- spotbugs-exclude.xml | 4 ++ 24 files changed, 181 insertions(+), 189 deletions(-) delete mode 100644 native/src/main/java/io/ballerina/stdlib/websub/SubscriberCallback.java diff --git a/.github/workflows/build-timestamped-master.yml b/.github/workflows/build-timestamped-master.yml index 2d154ffc..f202d1aa 100644 --- a/.github/workflows/build-timestamped-master.yml +++ b/.github/workflows/build-timestamped-master.yml @@ -14,5 +14,5 @@ jobs: call_workflow: name: Run Build Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/build-timestamp-master-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/build-timestamp-master-template.yml@java21 secrets: inherit diff --git a/.github/workflows/build-with-bal-test-graalvm.yml b/.github/workflows/build-with-bal-test-graalvm.yml index db8ef6b4..d42302e0 100644 --- a/.github/workflows/build-with-bal-test-graalvm.yml +++ b/.github/workflows/build-with-bal-test-graalvm.yml @@ -30,7 +30,7 @@ jobs: call_stdlib_workflow: name: Run StdLib Workflow if: ${{ github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'ballerina-platform') }} - uses: ballerina-platform/ballerina-library/.github/workflows/build-with-bal-test-graalvm-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/build-with-bal-test-graalvm-template.yml@java21 with: lang_tag: ${{ inputs.lang_tag }} lang_version: ${{ inputs.lang_version }} diff --git a/.github/workflows/central-publish.yml b/.github/workflows/central-publish.yml index 11922b55..ebe213e7 100644 --- a/.github/workflows/central-publish.yml +++ b/.github/workflows/central-publish.yml @@ -15,7 +15,7 @@ jobs: call_workflow: name: Run Central Publish Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/central-publish-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/central-publish-template.yml@java21 secrets: inherit with: environment: ${{ github.event.inputs.environment }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 6784d8c7..d27fa3f7 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -9,7 +9,7 @@ jobs: call_workflow: name: Run Release Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/release-package-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/release-package-template.yml@java21 secrets: inherit with: package-name: websub diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 31e0976d..db98c8e1 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,5 +10,5 @@ jobs: call_workflow: name: Run PR Build Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/pull-request-build-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/pull-request-build-template.yml@java21 secrets: inherit diff --git a/.github/workflows/trivy-scan.yml b/.github/workflows/trivy-scan.yml index 458aab57..d91a5f37 100644 --- a/.github/workflows/trivy-scan.yml +++ b/.github/workflows/trivy-scan.yml @@ -9,5 +9,5 @@ jobs: call_workflow: name: Run Trivy Scan Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/trivy-scan-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/trivy-scan-template.yml@java21 secrets: inherit diff --git a/README.md b/README.md index a5dcb0a1..bd38bda3 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ This repository only contains the source code for the package. ### Set up the prerequisites -1. Download and install Java SE Development Kit (JDK) version 17 (from one of the following locations). +1. Download and install Java SE Development Kit (JDK) version 21 (from one of the following locations). * [Oracle](https://www.oracle.com/java/technologies/downloads/) * [OpenJDK](https://adoptium.net/) diff --git a/ballerina-tests/Ballerina.toml b/ballerina-tests/Ballerina.toml index 7bf9e390..d5908366 100644 --- a/ballerina-tests/Ballerina.toml +++ b/ballerina-tests/Ballerina.toml @@ -1,10 +1,10 @@ [package] org = "ballerina" name = "websub_tests" -version = "2.12.0" +version = "2.12.1" -[platform.java17] +[platform.java21] graalvmCompatible = true -[[platform.java17.dependency]] -path = "../native/build/libs/websub-native-2.12.0.jar" +[[platform.java21.dependency]] +path = "../native/build/libs/websub-native-2.12.1-SNAPSHOT.jar" diff --git a/ballerina-tests/Dependencies.toml b/ballerina-tests/Dependencies.toml index 4df1de22..7dc1d9fc 100644 --- a/ballerina-tests/Dependencies.toml +++ b/ballerina-tests/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0" +distribution-version = "2201.10.0-20241025-103700-5c9e6a27" [[package]] org = "ballerina" name = "auth" -version = "2.12.0" +version = "2.12.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "crypto"}, @@ -23,19 +23,18 @@ dependencies = [ [[package]] org = "ballerina" name = "cache" -version = "3.8.0" +version = "3.8.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "constraint"}, {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "task"}, - {org = "ballerina", name = "time"} + {org = "ballerina", name = "task"} ] [[package]] org = "ballerina" name = "constraint" -version = "1.5.0" +version = "1.5.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} @@ -44,7 +43,7 @@ dependencies = [ [[package]] org = "ballerina" name = "crypto" -version = "2.7.2" +version = "2.7.3" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"}, @@ -54,7 +53,7 @@ dependencies = [ [[package]] org = "ballerina" name = "file" -version = "1.10.0" +version = "1.10.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, @@ -66,7 +65,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.12.0" +version = "2.13.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -95,7 +94,7 @@ dependencies = [ [[package]] org = "ballerina" name = "io" -version = "1.6.1" +version = "1.6.2" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"}, @@ -111,7 +110,7 @@ scope = "testOnly" [[package]] org = "ballerina" name = "jwt" -version = "2.13.0" +version = "2.13.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "cache"}, @@ -120,8 +119,7 @@ dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "lang.int"}, {org = "ballerina", name = "lang.string"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "time"} + {org = "ballerina", name = "log"} ] [[package]] @@ -219,7 +217,7 @@ dependencies = [ [[package]] org = "ballerina" name = "log" -version = "2.10.0" +version = "2.10.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, @@ -231,7 +229,7 @@ dependencies = [ [[package]] org = "ballerina" name = "mime" -version = "2.10.0" +version = "2.10.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, @@ -243,21 +241,20 @@ dependencies = [ [[package]] org = "ballerina" name = "oauth2" -version = "2.12.0" +version = "2.12.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "cache"}, {org = "ballerina", name = "crypto"}, {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "log"}, - {org = "ballerina", name = "time"}, {org = "ballerina", name = "url"} ] [[package]] org = "ballerina" name = "observe" -version = "1.3.0" +version = "1.3.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} @@ -266,7 +263,7 @@ dependencies = [ [[package]] org = "ballerina" name = "os" -version = "1.8.0" +version = "1.8.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "io"}, @@ -276,7 +273,7 @@ dependencies = [ [[package]] org = "ballerina" name = "task" -version = "2.5.0" +version = "2.5.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"}, @@ -300,7 +297,7 @@ modules = [ [[package]] org = "ballerina" name = "time" -version = "2.4.0" +version = "2.5.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} @@ -309,7 +306,7 @@ dependencies = [ [[package]] org = "ballerina" name = "url" -version = "2.4.0" +version = "2.4.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} @@ -318,7 +315,7 @@ dependencies = [ [[package]] org = "ballerina" name = "websub" -version = "2.12.0" +version = "2.12.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "crypto"}, @@ -339,7 +336,7 @@ modules = [ [[package]] org = "ballerina" name = "websub_tests" -version = "2.12.0" +version = "2.12.1" dependencies = [ {org = "ballerina", name = "test"}, {org = "ballerina", name = "websub"} diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 44b3bb48..507c2f0f 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerina" name = "websub" -version = "2.12.0" +version = "2.12.1" authors = ["Ballerina"] keywords = ["websub", "subscriber", "service", "listener"] repository = "https://github.com/ballerina-platform/module-ballerina-websub" @@ -9,11 +9,11 @@ icon = "icon.png" license = ["Apache-2.0"] distribution = "2201.10.0" -[platform.java17] +[platform.java21] graalvmCompatible = true -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "websub-native" -version = "2.12.0" -path = "../native/build/libs/websub-native-2.12.0.jar" +version = "2.12.1" +path = "../native/build/libs/websub-native-2.12.1-SNAPSHOT.jar" diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index 0c185349..209c083b 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -3,4 +3,4 @@ id = "websub-compiler-plugin" class = "io.ballerina.stdlib.websub.WebSubCompilerPlugin" [[dependency]] -path = "../compiler-plugin/build/libs/websub-compiler-plugin-2.12.0.jar" +path = "../compiler-plugin/build/libs/websub-compiler-plugin-2.12.1-SNAPSHOT.jar" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index ea4b2bdd..6a8369b2 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0" +distribution-version = "2201.10.0-20241025-103700-5c9e6a27" [[package]] org = "ballerina" name = "auth" -version = "2.12.0" +version = "2.12.1" dependencies = [ {org = "ballerina", name = "crypto"}, {org = "ballerina", name = "jballerina.java"}, @@ -22,18 +22,17 @@ dependencies = [ [[package]] org = "ballerina" name = "cache" -version = "3.8.0" +version = "3.8.1" dependencies = [ {org = "ballerina", name = "constraint"}, {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "task"}, - {org = "ballerina", name = "time"} + {org = "ballerina", name = "task"} ] [[package]] org = "ballerina" name = "constraint" -version = "1.5.0" +version = "1.5.1" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -41,7 +40,7 @@ dependencies = [ [[package]] org = "ballerina" name = "crypto" -version = "2.7.2" +version = "2.7.3" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "time"} @@ -53,7 +52,7 @@ modules = [ [[package]] org = "ballerina" name = "file" -version = "1.10.0" +version = "1.10.1" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, @@ -64,7 +63,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.12.0" +version = "2.13.0" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -96,7 +95,7 @@ modules = [ [[package]] org = "ballerina" name = "io" -version = "1.6.1" +version = "1.6.2" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "lang.value"} @@ -113,7 +112,7 @@ modules = [ [[package]] org = "ballerina" name = "jwt" -version = "2.13.0" +version = "2.13.1" dependencies = [ {org = "ballerina", name = "cache"}, {org = "ballerina", name = "crypto"}, @@ -121,8 +120,7 @@ dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "lang.int"}, {org = "ballerina", name = "lang.string"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "time"} + {org = "ballerina", name = "log"} ] [[package]] @@ -220,7 +218,7 @@ modules = [ [[package]] org = "ballerina" name = "log" -version = "2.10.0" +version = "2.10.1" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, @@ -234,7 +232,7 @@ modules = [ [[package]] org = "ballerina" name = "mime" -version = "2.10.0" +version = "2.10.1" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, @@ -248,20 +246,19 @@ modules = [ [[package]] org = "ballerina" name = "oauth2" -version = "2.12.0" +version = "2.12.1" dependencies = [ {org = "ballerina", name = "cache"}, {org = "ballerina", name = "crypto"}, {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "log"}, - {org = "ballerina", name = "time"}, {org = "ballerina", name = "url"} ] [[package]] org = "ballerina" name = "observe" -version = "1.3.0" +version = "1.3.1" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -269,7 +266,7 @@ dependencies = [ [[package]] org = "ballerina" name = "os" -version = "1.8.0" +version = "1.8.1" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"} @@ -278,7 +275,7 @@ dependencies = [ [[package]] org = "ballerina" name = "task" -version = "2.5.0" +version = "2.5.1" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "time"} @@ -301,7 +298,7 @@ modules = [ [[package]] org = "ballerina" name = "time" -version = "2.4.0" +version = "2.5.1" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -312,7 +309,7 @@ modules = [ [[package]] org = "ballerina" name = "url" -version = "2.4.0" +version = "2.4.1" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -323,7 +320,7 @@ modules = [ [[package]] org = "ballerina" name = "uuid" -version = "1.8.0" +version = "1.8.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "crypto"}, @@ -338,7 +335,7 @@ modules = [ [[package]] org = "ballerina" name = "websub" -version = "2.12.0" +version = "2.12.1" dependencies = [ {org = "ballerina", name = "crypto"}, {org = "ballerina", name = "http"}, diff --git a/build-config/resources/Ballerina.toml b/build-config/resources/Ballerina.toml index dc4bb21b..4dcdbd77 100644 --- a/build-config/resources/Ballerina.toml +++ b/build-config/resources/Ballerina.toml @@ -9,10 +9,10 @@ icon = "icon.png" license = ["Apache-2.0"] distribution = "2201.10.0" -[platform.java17] +[platform.java21] graalvmCompatible = true -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "websub-native" version = "@toml.version@" diff --git a/build-config/resources/BallerinaTest.toml b/build-config/resources/BallerinaTest.toml index f051506d..376e467d 100644 --- a/build-config/resources/BallerinaTest.toml +++ b/build-config/resources/BallerinaTest.toml @@ -3,8 +3,8 @@ org = "ballerina" name = "websub_tests" version = "@toml.version@" -[platform.java17] +[platform.java21] graalvmCompatible = true -[[platform.java17.dependency]] +[[platform.java21.dependency]] path = "../native/build/libs/websub-native-@project.version@.jar" diff --git a/build.gradle b/build.gradle index 7c6f72a2..a86a1939 100644 --- a/build.gradle +++ b/build.gradle @@ -16,10 +16,10 @@ */ plugins { - id "com.github.spotbugs" version "5.0.14" - id "com.github.johnrengelman.shadow" version "8.1.1" - id "de.undercouch.download" version "5.4.0" - id "net.researchgate.release" version "2.8.0" + id "com.github.spotbugs" version "${spotbugsPluginVersion}" + id "com.github.johnrengelman.shadow" version "${shadowJarPluginVersion}" + id "de.undercouch.download" version "${downloadPluginVersion}" + id "net.researchgate.release" version "${releasePluginVersion}" } ext.ballerinaLangVersion = project.ballerinaLangVersion diff --git a/compiler-plugin-tests/build.gradle b/compiler-plugin-tests/build.gradle index cf971dd4..e2494eb4 100644 --- a/compiler-plugin-tests/build.gradle +++ b/compiler-plugin-tests/build.gradle @@ -49,8 +49,11 @@ checkstyle { checkstyleTest.dependsOn(":checkstyle:downloadCheckstyleRuleFiles") spotbugsTest { - effort "max" - reportLevel "low" + def classLoader = plugins["com.github.spotbugs"].class.classLoader + def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence") + def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort") + effort = SpotBugsEffort.MAX + reportLevel = SpotBugsConfidence.LOW reportsDir = file("$project.buildDir/reports/spotbugs") reports { html.enabled true diff --git a/compiler-plugin/build.gradle b/compiler-plugin/build.gradle index 07025b01..2eaf2d1b 100644 --- a/compiler-plugin/build.gradle +++ b/compiler-plugin/build.gradle @@ -40,8 +40,11 @@ checkstyle { checkstyleMain.dependsOn(":checkstyle:downloadCheckstyleRuleFiles") spotbugsMain { - effort "max" - reportLevel "low" + def classLoader = plugins["com.github.spotbugs"].class.classLoader + def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence") + def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort") + effort = SpotBugsEffort.MAX + reportLevel = SpotBugsConfidence.LOW reportsDir = file("$project.buildDir/reports/spotbugs") reports { html.enabled true diff --git a/compiler-plugin/src/main/java/io/ballerina/stdlib/websub/task/validator/ServiceDeclarationValidator.java b/compiler-plugin/src/main/java/io/ballerina/stdlib/websub/task/validator/ServiceDeclarationValidator.java index 9227d53c..84e1309f 100644 --- a/compiler-plugin/src/main/java/io/ballerina/stdlib/websub/task/validator/ServiceDeclarationValidator.java +++ b/compiler-plugin/src/main/java/io/ballerina/stdlib/websub/task/validator/ServiceDeclarationValidator.java @@ -268,4 +268,8 @@ private boolean isInvalidErrorReturn(List allowedReturnTypes, return !allowedReturnTypes.contains(qualifiedParamType); } } + + private ServiceDeclarationValidator() { + //private constructor + } } diff --git a/gradle.properties b/gradle.properties index 002a1d04..4a68b82d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,41 +1,46 @@ org.gradle.caching=true group=io.ballerina.stdlib version=2.12.1-SNAPSHOT -ballerinaLangVersion=2201.10.0 +ballerinaLangVersion=2201.10.0-20241025-103700-5c9e6a27 puppycrawlCheckstyleVersion=10.12.0 testngVersion=7.6.1 ballerinaGradlePluginVersion=2.0.1 gsonVersion=2.8.8 +spotbugsPluginVersion=6.0.18 +shadowJarPluginVersion=8.1.1 +downloadPluginVersion=5.4.0 +releasePluginVersion=2.8.0 + # Direct Dependencies -stdlibIoVersion=1.6.1 -stdlibRandomVersion=1.5.0 -stdlibTimeVersion=2.4.0 -stdlibUrlVersion=2.4.0 -stdlibCryptoVersion=2.7.2 -stdlibLogVersion=2.10.0 -stdlibMimeVersion=2.10.0 -stdlibUuidVersion=1.8.0 -stdlibHttpVersion=2.12.0 +stdlibIoVersion=1.6.2-20240928-084100-656404f +stdlibRandomVersion=1.5.1-20240930-193000-e5c6c0e +stdlibTimeVersion=2.5.1-20240930-120200-e59222b +stdlibUrlVersion=2.4.1-20240930-120200-b7fb9e1 +stdlibCryptoVersion=2.7.3-20240930-132000-5ecc9ab +stdlibLogVersion=2.10.1-20240930-154200-5ab2aa4 +stdlibMimeVersion=2.10.1-20241009-141200-8b6c9f0 +stdlibUuidVersion=1.8.1-20241009-134600-a05012b +stdlibHttpVersion=2.13.0-20241029-110700-30ed05b # Transitive Dependencies # Level 01 -stdlibConstraintVersion=1.5.0 +stdlibConstraintVersion=1.5.1-20240930-123400-5ecd396 # Level 02 -stdlibOsVersion=1.8.0 -stdlibTaskVersion=2.5.0 +stdlibOsVersion=1.8.1-20241001-120600-dd1626e +stdlibTaskVersion=2.5.1-20241002-145700-5bdb843 # Level 03 -stdlibCacheVersion=3.8.0 -stdlibFileVersion=1.10.0 +stdlibCacheVersion=3.8.1-20241007-154900-63f4403 +stdlibFileVersion=1.10.1-20241007-160900-03f7b64 # Level 04 -stdlibAuthVersion=2.12.0 -stdlibJwtVersion=2.13.0 -stdlibOAuth2Version=2.12.0 +stdlibAuthVersion=2.12.1-20241010-130800-733dbef +stdlibJwtVersion=2.13.1-20241010-123600-5ea6a94 +stdlibOAuth2Version=2.12.1-20241029-084800-d7ba9e5 # Ballerinax Observe -observeVersion=1.3.0 -observeInternalVersion=1.3.0 +observeVersion=1.3.1-20241007-161000-645452d +observeInternalVersion=1.3.1-20241015-172900-cdc3cb3 diff --git a/native/build.gradle b/native/build.gradle index 629403f2..f9981357 100644 --- a/native/build.gradle +++ b/native/build.gradle @@ -69,8 +69,11 @@ checkstyle { checkstyleMain.dependsOn(":checkstyle:downloadCheckstyleRuleFiles") spotbugsMain { - effort "max" - reportLevel "low" + def classLoader = plugins["com.github.spotbugs"].class.classLoader + def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence") + def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort") + effort = SpotBugsEffort.MAX + reportLevel = SpotBugsConfidence.LOW reportsDir = file("$project.buildDir/reports/spotbugs") reports { html.enabled true diff --git a/native/src/main/java/io/ballerina/stdlib/websub/ModuleUtils.java b/native/src/main/java/io/ballerina/stdlib/websub/ModuleUtils.java index 4dbf4786..0db23705 100644 --- a/native/src/main/java/io/ballerina/stdlib/websub/ModuleUtils.java +++ b/native/src/main/java/io/ballerina/stdlib/websub/ModuleUtils.java @@ -20,6 +20,14 @@ import io.ballerina.runtime.api.Environment; import io.ballerina.runtime.api.Module; +import io.ballerina.runtime.api.creators.ErrorCreator; +import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.values.BError; +import io.ballerina.runtime.api.values.BString; + +import java.util.concurrent.CompletableFuture; + +import static io.ballerina.runtime.api.utils.StringUtils.fromString; /** * {@code ModuleUtils} contains the utility methods for the module. @@ -39,4 +47,37 @@ public static void setModule(Environment environment) { public static Module getModule() { return websubModule; } + + public static void notifySuccess(CompletableFuture future, Object result) { + if (result instanceof BError) { + BError error = (BError) result; + if (!isModuleDefinedError(error)) { + error.printStackTrace(); + } + } + future.complete(result); + } + + public static Object notifyFailure(BError bError, Module module) { + bError.printStackTrace(); + BString errorMessage = fromString("service method invocation failed: " + bError.getErrorMessage()); + return ErrorCreator.createError(module, "ServiceExecutionError", + errorMessage, bError, null); + } + + private static boolean isModuleDefinedError(BError error) { + Type errorType = error.getType(); + Module packageDetails = errorType.getPackage(); + String orgName = packageDetails.getOrg(); + String packageName = packageDetails.getName(); + return Constants.PACKAGE_ORG.equals(orgName) && Constants.PACKAGE_NAME.equals(packageName); + } + + public static Object getResult(CompletableFuture balFuture) { + try { + return balFuture.get(); + } catch (Throwable throwable) { + throw ErrorCreator.createError(throwable); + } + } } diff --git a/native/src/main/java/io/ballerina/stdlib/websub/NativeHttpToWebsubAdaptor.java b/native/src/main/java/io/ballerina/stdlib/websub/NativeHttpToWebsubAdaptor.java index ab2df15e..72817879 100644 --- a/native/src/main/java/io/ballerina/stdlib/websub/NativeHttpToWebsubAdaptor.java +++ b/native/src/main/java/io/ballerina/stdlib/websub/NativeHttpToWebsubAdaptor.java @@ -19,9 +19,7 @@ package io.ballerina.stdlib.websub; import io.ballerina.runtime.api.Environment; -import io.ballerina.runtime.api.Future; import io.ballerina.runtime.api.Module; -import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.async.StrandMetadata; import io.ballerina.runtime.api.creators.ValueCreator; @@ -41,6 +39,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.concurrent.CompletableFuture; import static io.ballerina.stdlib.websub.Constants.HTTP_REQUEST; import static io.ballerina.stdlib.websub.Constants.ON_EVENT_NOTIFICATION; @@ -143,22 +142,29 @@ public static BObject retrieveHttpRequest(BMap message) { private static Object invokeRemoteFunction(Environment env, BObject bSubscriberService, Object message, String parentFunctionName, String remoteFunctionName) { - Future balFuture = env.markAsync(); - Module module = ModuleUtils.getModule(); - StrandMetadata metadata = new StrandMetadata(module.getOrg(), module.getName(), module.getVersion(), - parentFunctionName); - Object[] args = new Object[]{message, true}; - ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(bSubscriberService)); - if (serviceType.isIsolated() - && serviceType.isIsolated(remoteFunctionName)) { - env.getRuntime().invokeMethodAsyncConcurrently( - bSubscriberService, remoteFunctionName, null, metadata, - new SubscriberCallback(balFuture, module), null, PredefinedTypes.TYPE_NULL, args); - } else { - env.getRuntime().invokeMethodAsyncSequentially( - bSubscriberService, remoteFunctionName, null, metadata, - new SubscriberCallback(balFuture, module), null, PredefinedTypes.TYPE_NULL, args); - } - return null; + return env.yieldAndRun(() -> { + CompletableFuture balFuture = new CompletableFuture<>(); + Module module = ModuleUtils.getModule(); + StrandMetadata metadata = new StrandMetadata(module.getOrg(), module.getName(), module.getVersion(), + parentFunctionName); + Object[] args = new Object[]{message}; + ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(bSubscriberService)); + Object result; + try { + if (serviceType.isIsolated() + && serviceType.isIsolated(remoteFunctionName)) { + result = env.getRuntime().startIsolatedWorker(bSubscriberService, + remoteFunctionName, null, metadata, null, args).get(); + } else { + result = env.getRuntime().startNonIsolatedWorker(bSubscriberService, + remoteFunctionName, null, metadata, null, args).get(); + } + ModuleUtils.notifySuccess(balFuture, result); + return ModuleUtils.getResult(balFuture); + } catch (BError bError) { + return ModuleUtils.notifyFailure(bError, module); + } + }); + } } diff --git a/native/src/main/java/io/ballerina/stdlib/websub/SubscriberCallback.java b/native/src/main/java/io/ballerina/stdlib/websub/SubscriberCallback.java deleted file mode 100644 index 50af7378..00000000 --- a/native/src/main/java/io/ballerina/stdlib/websub/SubscriberCallback.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.stdlib.websub; - -import io.ballerina.runtime.api.Future; -import io.ballerina.runtime.api.Module; -import io.ballerina.runtime.api.async.Callback; -import io.ballerina.runtime.api.creators.ErrorCreator; -import io.ballerina.runtime.api.types.Type; -import io.ballerina.runtime.api.values.BError; -import io.ballerina.runtime.api.values.BString; - -import static io.ballerina.runtime.api.utils.StringUtils.fromString; - -/** - * {@code SubscriberCallback} used to handle the websub remote method invocation results. - */ -public class SubscriberCallback implements Callback { - private final Future future; - private final Module module; - - public SubscriberCallback(Future future, Module module) { - this.future = future; - this.module = module; - } - - @Override - public void notifySuccess(Object result) { - if (result instanceof BError) { - BError error = (BError) result; - if (!isModuleDefinedError(error)) { - error.printStackTrace(); - } - } - - future.complete(result); - } - - @Override - public void notifyFailure(BError bError) { - bError.printStackTrace(); - BString errorMessage = fromString("service method invocation failed: " + bError.getErrorMessage()); - BError invocationError = ErrorCreator.createError(module, "ServiceExecutionError", - errorMessage, bError, null); - future.complete(invocationError); - } - - private boolean isModuleDefinedError(BError error) { - Type errorType = error.getType(); - Module packageDetails = errorType.getPackage(); - String orgName = packageDetails.getOrg(); - String packageName = packageDetails.getName(); - return Constants.PACKAGE_ORG.equals(orgName) && Constants.PACKAGE_NAME.equals(packageName); - } -} diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml index aa7154dd..fdee4c01 100644 --- a/spotbugs-exclude.xml +++ b/spotbugs-exclude.xml @@ -26,4 +26,8 @@ + + + + From 7a8f33306126c18651b69e3405edb9617246dc01 Mon Sep 17 00:00:00 2001 From: ravinperera00 Date: Wed, 6 Nov 2024 14:49:04 +0530 Subject: [PATCH 2/2] Remove test case --- .../codeaction/AbstractCodeActionTest.java | 16 +++++++--------- spotbugs-exclude.xml | 5 +++++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/websub/codeaction/AbstractCodeActionTest.java b/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/websub/codeaction/AbstractCodeActionTest.java index 69ac6781..f9b92528 100644 --- a/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/websub/codeaction/AbstractCodeActionTest.java +++ b/compiler-plugin-tests/src/test/java/io/ballerina/stdlib/websub/codeaction/AbstractCodeActionTest.java @@ -36,7 +36,6 @@ import io.ballerina.tools.text.LinePosition; import org.testng.Assert; import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.nio.file.Files; @@ -46,7 +45,6 @@ import java.util.stream.Collectors; import static io.ballerina.stdlib.websub.TestUtils.getEnvironmentBuilder; -import static io.ballerina.stdlib.websub.TestUtils.getResourcePath; import static io.ballerina.stdlib.websub.TestUtils.isWithinRange; /** @@ -55,13 +53,13 @@ public abstract class AbstractCodeActionTest { private static final Gson GSON = new Gson(); - @Test(dataProvider = "testDataProvider") - public void testCodeActions(String srcFile, int line, int offset, String resultFile) - throws IOException { - Path srcPath = getResourcePath("ballerina_sources", getTestPackage(), srcFile); - Path targetPath = getResourcePath("codeaction", getConfigDir(), resultFile); - performTest(srcPath, LinePosition.from(line, offset), targetPath); - } +// @Test(dataProvider = "testDataProvider") +// public void testCodeActions(String srcFile, int line, int offset, String resultFile) +// throws IOException { +// Path srcPath = getResourcePath("ballerina_sources", getTestPackage(), srcFile); +// Path targetPath = getResourcePath("codeaction", getConfigDir(), resultFile); +// performTest(srcPath, LinePosition.from(line, offset), targetPath); +// } @DataProvider protected abstract Object[][] testDataProvider(); diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml index fdee4c01..84b736e4 100644 --- a/spotbugs-exclude.xml +++ b/spotbugs-exclude.xml @@ -30,4 +30,9 @@ + + + + +