Skip to content

Commit

Permalink
Merge pull request #119 from warunalakshitha/syncJava21
Browse files Browse the repository at this point in the history
Migrate to Java 21
  • Loading branch information
warunalakshitha authored Nov 18, 2024
2 parents 95b4664 + d3ae7b7 commit a0afd74
Show file tree
Hide file tree
Showing 17 changed files with 99 additions and 82 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-timestamped-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 17.0.7
java-version: 21
- name: Change to Timestamped Version
run: |
startTime=$(TZ="Asia/Kolkata" date +'%Y%m%d-%H%M00')
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 17.0.7
java-version: 21
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 17.0.7
java-version: 21
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
Expand All @@ -29,11 +29,11 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 17.0.7
java-version: 21
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
Expand All @@ -49,11 +49,11 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 17.0.7
java-version: 21
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/trivy-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 17.0.7
java-version: 21
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This module contains internal configurations and initializations for Ballerina o

### 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/)

Expand Down
4 changes: 2 additions & 2 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ name = "observe"
version = "1.3.0"
distribution = "2201.10.0"

[platform.java17]
[platform.java21]
graalvmCompatible = true

[[platform.java17.dependency]]
[[platform.java21.dependency]]
path = "../native/build/libs/observe-internal-native-1.3.0.jar"
4 changes: 2 additions & 2 deletions build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ name = "observe"
version = "@toml.version@"
distribution = "2201.10.0"

[platform.java17]
[platform.java21]
graalvmCompatible = true

[[platform.java17.dependency]]
[[platform.java21.dependency]]
path = "../native/build/libs/[email protected]@.jar"
2 changes: 1 addition & 1 deletion build-config/resources/testobserve/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ org = "ballerina"
name = "testobserve"
version = "0.0.0"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
path = "../native/build/libs/[email protected]@-all.jar"
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 "${githubSpotbugsVersion}"
id "com.github.johnrengelman.shadow" version "${githubJohnrengelmanShadowVersion}"
id "de.undercouch.download" version "${underCouchDownloadVersion}"
id "net.researchgate.release" version "${researchgateReleaseVersion}"
}

allprojects {
Expand Down
8 changes: 6 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ org.gradle.caching=true
group=io.ballerina
version=1.3.1-SNAPSHOT

ballerinaLangVersion=2201.10.0
ballerinaLangVersion=2201.11.0-20241117-133400-a3054b77
githubSpotbugsVersion=6.0.18
githubJohnrengelmanShadowVersion=8.1.1
underCouchDownloadVersion=5.4.0
researchgateReleaseVersion=2.8.0
ballerinaTomlParserVersion=1.2.2
ballerinaGradlePluginVersion=2.0.1
puppycrawlCheckstyleVersion=10.12.0
openTelemetryVersion=1.7.0
nettyCodecVersion=4.1.100.Final
gsonVersion=2.10.1

observeVersion=1.3.0
observeVersion=1.4.0-20241113-092000-b83ae74

# Test Dependency Versions
testngVersion=7.6.1
Expand Down
7 changes: 5 additions & 2 deletions native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ tasks.withType(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
Expand Down
2 changes: 1 addition & 1 deletion testobserve/ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ org = "ballerina"
name = "testobserve"
version = "0.0.0"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
path = "../native/build/libs/testobserve-native-1.3.0-SNAPSHOT-all.jar"
7 changes: 5 additions & 2 deletions testobserve/native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ tasks.withType(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
Expand Down
16 changes: 15 additions & 1 deletion testobserve/native/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,28 @@
~ under the License.
-->
<FindBugsFilter>
<Match>
<Class name="org.ballerina.testobserve.listenerendpoint.Resource"/>
<Bug pattern="CT_CONSTRUCTOR_THROW"/>
</Match>
<Match>
<Class name="org.ballerina.testobserve.listenerendpoint.Resource"/>
<Field name="serviceObject"/>
<Bug pattern="EI_EXPOSE_REP,EI_EXPOSE_REP2"/>
<Bug pattern="EI_EXPOSE_REP,EI_EXPOSE_REP2, CT_CONSTRUCTOR_THROW"/>
</Match>
<Match>
<Class name="org.ballerina.testobserve.listenerendpoint.WebServer"/>
<Field name="env"/>
<Bug pattern="EI_EXPOSE_REP2"/>
</Match>
<Match>
<Class name="org.ballerina.testobserve.listenerendpoint.WebServer$WebServerInboundHandler"/>
<Field name="resourceMap"/>
<Bug pattern="EI_EXPOSE_REP2"/>
</Match>
<Match>
<Class name="org.ballerina.testobserve.listenerendpoint.WebServer$WebServerInboundHandler"/>
<Field name="env"/>
<Bug pattern="EI_EXPOSE_REP2"/>
</Match>
</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
package org.ballerina.testobserve;

import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.Future;
import io.ballerina.runtime.api.creators.ErrorCreator;
import io.ballerina.runtime.api.utils.StringUtils;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
* Native functions for the utilities in testobserve module.
Expand All @@ -34,7 +34,13 @@ public class NativeUtils {
private static final ScheduledExecutorService executor = Executors.newScheduledThreadPool(CORE_THREAD_POOL_SIZE);

public static void sleep(Environment env, long delayMillis) {
Future balFuture = env.markAsync();
executor.schedule(() -> balFuture.complete(null), delayMillis, TimeUnit.MILLISECONDS);
env.yieldAndRun(() -> {
try {
Thread.sleep(delayMillis);
return null;
} catch (InterruptedException e) {
throw ErrorCreator.createError(StringUtils.fromString("error occurred during sleep"), e);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public class Endpoint {

public static void initEndpoint(Environment env, BObject listenerEndpoint, int port) {
WebServer webServer = new WebServer(port, env.getRuntime());
WebServer webServer = new WebServer(port, env);
listenerEndpoint.addNativeData(WEB_SERVER_NATIVE_DATA_KEY, webServer);
Utils.logInfo("Initialized Web Server with port " + port);
}
Expand Down
Loading

0 comments on commit a0afd74

Please sign in to comment.