Skip to content

Commit

Permalink
Merge pull request #254 from HindujaB/java21
Browse files Browse the repository at this point in the history
Migrate to Java 21
  • Loading branch information
warunalakshitha authored Nov 19, 2024
2 parents a5e3f00 + 5a6c58d commit 88246aa
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 170 deletions.
18 changes: 9 additions & 9 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
[package]
org = "ballerina"
name = "mqtt"
version = "1.2.0"
version = "1.2.1"
authors = ["ballerina"]
keywords = ["mqtt", "client", "messaging", "network", "pubsub", "iot"]
repository = "https://github.com/ballerina-platform/module-ballerina-mqtt"
distribution = "2201.10.0"
distribution = "2201.11.0-20241112-214900-6b80ab87"

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

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "mqtt-native"
version = "1.2.0"
path = "../native/build/libs/mqtt-native-1.2.0.jar"
version = "1.2.1"
path = "../native/build/libs/mqtt-native-1.2.1-SNAPSHOT.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.eclipse.paho"
artifactId = "org.eclipse.paho.mqttv5.client"
version = "1.2.5"
path = "./lib/org.eclipse.paho.mqttv5.client-1.2.5.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.bouncycastle"
artifactId = "bcpkix-jdk18on"
version = "1.78"
path = "./lib/bcpkix-jdk18on-1.78.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.bouncycastle"
artifactId = "bcutil-jdk18on"
version = "1.78"
Expand Down
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ id = "mqtt-compiler-plugin"
class = "io.ballerina.stdlib.mqtt.compiler.MqttCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/mqtt-compiler-plugin-1.2.0.jar"
path = "../compiler-plugin/build/libs/mqtt-compiler-plugin-1.2.1-SNAPSHOT.jar"
16 changes: 8 additions & 8 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.10.0"
distribution-version = "2201.11.0-20241112-214900-6b80ab87"

[[package]]
org = "ballerina"
name = "crypto"
version = "2.7.2"
version = "2.7.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "time"}
Expand All @@ -22,7 +22,7 @@ modules = [
[[package]]
org = "ballerina"
name = "io"
version = "1.6.1"
version = "1.6.2"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -107,7 +107,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "log"
version = "2.10.0"
version = "2.10.1"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "io"},
Expand All @@ -122,7 +122,7 @@ modules = [
[[package]]
org = "ballerina"
name = "mqtt"
version = "1.2.0"
version = "1.2.1"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -138,7 +138,7 @@ modules = [
[[package]]
org = "ballerina"
name = "observe"
version = "1.3.0"
version = "1.4.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
Expand All @@ -161,15 +161,15 @@ modules = [
[[package]]
org = "ballerina"
name = "time"
version = "2.4.0"
version = "2.6.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "uuid"
version = "1.8.0"
version = "1.8.1"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "crypto"},
Expand Down
12 changes: 6 additions & 6 deletions build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ version = "@toml.version@"
authors = ["ballerina"]
keywords = ["mqtt", "client", "messaging", "network", "pubsub", "iot"]
repository = "https://github.com/ballerina-platform/module-ballerina-mqtt"
distribution = "2201.10.0"
distribution = "2201.11.0-20241112-214900-6b80ab87"

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

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "mqtt-native"
version = "@toml.version@"
path = "../native/build/libs/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.eclipse.paho"
artifactId = "org.eclipse.paho.mqttv5.client"
version = "@paho.mqtt.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.bouncycastle"
artifactId = "bcpkix-jdk18on"
version = "@bouncy.castle.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.bouncycastle"
artifactId = "bcutil-jdk18on"
version = "@bouncy.castle.version@"
Expand Down
7 changes: 5 additions & 2 deletions compiler-plugin-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,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
Expand Down
7 changes: 5 additions & 2 deletions compiler-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,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
Expand Down
20 changes: 10 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
org.gradle.caching=true
group=io.ballerina.stdlib
version=1.2.1-SNAPSHOT
ballerinaLangVersion=2201.10.0
ballerinaLangVersion=2201.11.0-20241112-214900-6b80ab87

checkstylePluginVersion=10.12.1
spotbugsPluginVersion=5.0.14
spotbugsPluginVersion=6.0.18
shadowJarPluginVersion=8.1.1
downloadPluginVersion=5.4.0
releasePluginVersion=2.8.0
Expand All @@ -20,16 +20,16 @@ pahoMqtt5Version=1.2.5
#stdlib dependencies

# Level 01
stdlibTimeVersion=2.4.0
stdlibIoVersion=1.6.0
stdlibTimeVersion=2.6.0-20241113-073800-201b904
stdlibIoVersion=1.6.2-20241112-233100-995cf5f

# Level 02
stdlibLogVersion=2.10.0
stdlibCryptoVersion=2.7.2
stdlibRandomVersion=1.5.0
stdlibLogVersion=2.10.1-20241113-120000-4577868
stdlibCryptoVersion=2.7.3-20241113-081400-d015a39
stdlibRandomVersion=1.5.1-20241113-122300-1bc770e

# Level 03
stdlibUuidVersion=1.8.0
stdlibUuidVersion=1.8.1-20241113-154400-443c67b

observeVersion=1.3.0
observeInternalVersion=1.3.0
observeVersion=1.4.0-20241113-092000-b83ae74
observeInternalVersion=1.3.1-20241113-101700-265054d
7 changes: 5 additions & 2 deletions native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package io.ballerina.stdlib.mqtt.caller;

import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.Future;
import io.ballerina.runtime.api.values.BMap;
import io.ballerina.runtime.api.values.BObject;
import io.ballerina.stdlib.mqtt.utils.MqttConstants;
Expand Down Expand Up @@ -47,16 +46,16 @@ public static Object complete(Environment env, BObject callerObject) {
MqttClient subscriber = (MqttClient) callerObject.getNativeData(MqttConstants.SUBSCRIBER);
int messageId = (int) callerObject.getNativeData(MqttConstants.MESSAGE_ID);
int qos = (int) callerObject.getNativeData(MqttConstants.QOS);
Future future = env.markAsync();
executorService.execute(() -> {
try {
subscriber.messageArrivedComplete(messageId, qos);
future.complete(null);
} catch (MqttException e) {
future.complete(MqttUtils.createMqttError(e));
}
return env.yieldAndRun(() -> {
executorService.execute(() -> {
try {
subscriber.messageArrivedComplete(messageId, qos);
} catch (MqttException e) {
throw MqttUtils.createMqttError(e);
}
});
return null;
});
return null;
}

public static Object respond(Environment env, BObject callerObject, BMap message) {
Expand All @@ -70,16 +69,15 @@ public static Object respond(Environment env, BObject callerObject, BMap message
if (Objects.nonNull(correlationData)) {
mqttMessage.getProperties().setCorrelationData(correlationData);
}
Future future = env.markAsync();
executorService.execute(() -> {
try {
subscriber.publish(responseTopic, mqttMessage);
future.complete(null);
} catch (MqttException e) {
future.complete(MqttUtils.createMqttError(e));
}
return env.yieldAndRun(() -> {
executorService.execute(() -> {
try {
subscriber.publish(responseTopic, mqttMessage);
} catch (MqttException e) {
throw MqttUtils.createMqttError(e);
}
});
return null;
});
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package io.ballerina.stdlib.mqtt.client;

import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.Future;
import io.ballerina.runtime.api.creators.TypeCreator;
import io.ballerina.runtime.api.creators.ValueCreator;
import io.ballerina.runtime.api.types.StreamType;
Expand Down Expand Up @@ -107,24 +106,20 @@ public static Object externSubscribe(BObject clientObject, BArray subscriptions)
public static Object externPublish(Environment env, BObject clientObject, BString topic, BMap message) {
MqttClient publisher = (MqttClient) clientObject.getNativeData(MqttConstants.MQTT_CLIENT);
MqttMessage mqttMessage = generateMqttMessage(message);
try {
Future future = env.markAsync();
publisher.publish(topic.getValue(), mqttMessage);
LinkedBlockingQueue deliveryTokenQueue = (LinkedBlockingQueue) clientObject
.getNativeData(DELIVERY_TOKEN_QUEUE);
publishExecutorService.execute(() -> {
try {
future.complete(deliveryTokenQueue.take());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
future.complete(MqttUtils.createMqttError(e));
}
});
} catch (MqttException e) {
return env.yieldAndRun(() -> {
try {
publisher.publish(topic.getValue(), mqttMessage);
LinkedBlockingQueue deliveryTokenQueue = (LinkedBlockingQueue) clientObject
.getNativeData(DELIVERY_TOKEN_QUEUE);
return deliveryTokenQueue.take();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return MqttUtils.createMqttError(e);
} catch (MqttException e) {
return MqttUtils.createMqttError(e);
}
return null;
}
});
}

public static Object externReceive(BObject clientObject, BTypedesc bTypedesc) {
LinkedBlockingQueue blockingQueue = (LinkedBlockingQueue) clientObject.getNativeData(RESPONSE_QUEUE);
Expand Down Expand Up @@ -179,18 +174,15 @@ public static Object externReconnect(BObject clientObject) {

public static Object nextResult(Environment env, BObject streamIterator) {
BlockingQueue<?> messageQueue = (BlockingQueue<?>) streamIterator.getNativeData(RESPONSE_QUEUE);
ExecutorService executor = (ExecutorService) streamIterator.getNativeData(RESPONSE_EXECUTOR_SERVICE);
Future future = env.markAsync();
executor.execute(() -> {
return env.yieldAndRun(() -> {
try {
BMap message = (BMap) messageQueue.take();
future.complete(message);
return message;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
future.complete(MqttUtils.createMqttError(e));
return MqttUtils.createMqttError(e);
}
});
return null;
}

public static void closeStream(BObject streamIterator) {
Expand Down
Loading

0 comments on commit 88246aa

Please sign in to comment.