Skip to content

Commit 7598172

Browse files
Merge pull request #61 from ravinperera00/java21
Migrate to Java 21
2 parents 70ae7f8 + cb667c3 commit 7598172

File tree

11 files changed

+72
-166
lines changed

11 files changed

+72
-166
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import ballerinax/ibm.ibmmq;
6161
Add `com.ibm.mq.allclient` as a platform dependency to the `Ballerina.toml`.
6262

6363
```toml
64-
[[platform.java17.dependency]]
64+
[[platform.java21.dependency]]
6565
groupId = "com.ibm.mq"
6666
artifactId = "com.ibm.mq.allclient"
6767
version = "9.3.4.0"
@@ -169,7 +169,7 @@ This repository only contains the source code for the library.
169169

170170
### Set up the prerequisites
171171

172-
1. Download and install Java SE Development Kit (JDK) version 17 (from one of the following locations).
172+
1. Download and install Java SE Development Kit (JDK) version 21 (from one of the following locations).
173173

174174
* [Oracle](https://www.oracle.com/java/technologies/downloads/)
175175
* [OpenJDK](https://adoptium.net/)

ballerina/Ballerina.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
[package]
22
org = "ballerinax"
33
name = "ibm.ibmmq"
4-
version = "1.2.0"
4+
version = "1.3.0"
55
authors = ["Ballerina"]
66
keywords = ["ibm.ibmmq", "client", "messaging", "network", "pubsub"]
77
repository = "https://github.com/ballerina-platform/module-ballerinax-ibm.ibmmq"
88
icon = "icon.png"
99
license = ["Apache-2.0"]
10-
distribution = "2201.9.0"
10+
distribution = "2201.11.0-20241117-133400-a3054b77"
1111

12-
[[platform.java17.dependency]]
12+
[[platform.java21.dependency]]
1313
groupId = "io.ballerina.stdlib"
1414
artifactId = "ibm.ibmmq-native"
15-
version = "1.2.0"
16-
path = "../native/build/libs/ibm.ibmmq-native-1.2.0.jar"
15+
version = "1.3.0"
16+
path = "../native/build/libs/ibm.ibmmq-native-1.3.0.jar"
1717

18-
[[platform.java17.dependency]]
18+
[[platform.java21.dependency]]
1919
groupId = "org.json"
2020
artifactId = "json"
2121
version = "20231013"
2222
path = "./lib/json-20231013.jar"
2323

24-
[[platform.java17.dependency]]
24+
[[platform.java21.dependency]]
2525
groupId = "com.ibm.mq"
2626
artifactId = "com.ibm.mq.allclient"
2727
version = "9.3.4.0"
2828
path = "./lib/com.ibm.mq.allclient-9.3.4.0.jar"
2929
scope = "provided"
3030

31-
[[platform.java17.dependency]]
31+
[[platform.java21.dependency]]
3232
groupId = "com.fasterxml.jackson.core"
3333
artifactId = "jackson-annotations"
3434
version = "2.15.3"
3535
path = "./lib/jackson-annotations-2.15.3.jar"
3636

37-
[[platform.java17.dependency]]
37+
[[platform.java21.dependency]]
3838
groupId = "com.fasterxml.jackson.core"
3939
artifactId = "jackson-core"
4040
version = "2.15.3"
4141
path = "./lib/jackson-core-2.15.3.jar"
4242

43-
[[platform.java17.dependency]]
43+
[[platform.java21.dependency]]
4444
groupId = "com.fasterxml.jackson.core"
4545
artifactId = "jackson-databind"
4646
version = "2.15.3"

ballerina/Dependencies.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
[ballerina]
77
dependencies-toml-version = "2"
8-
distribution-version = "2201.9.0"
8+
distribution-version = "2201.11.0-20241117-133400-a3054b77"
99

1010
[[package]]
1111
org = "ballerina"
@@ -90,7 +90,7 @@ modules = [
9090
[[package]]
9191
org = "ballerinax"
9292
name = "ibm.ibmmq"
93-
version = "1.2.0"
93+
version = "1.3.0"
9494
dependencies = [
9595
{org = "ballerina", name = "crypto"},
9696
{org = "ballerina", name = "jballerina.java"},

build-config/resources/Ballerina.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,40 @@ keywords = ["ibm.ibmmq", "client", "messaging", "network", "pubsub"]
77
repository = "https://github.com/ballerina-platform/module-ballerinax-ibm.ibmmq"
88
icon = "icon.png"
99
license = ["Apache-2.0"]
10-
distribution = "2201.9.0"
10+
distribution = "2201.11.0-20241117-133400-a3054b77"
1111

12-
[[platform.java17.dependency]]
12+
[[platform.java21.dependency]]
1313
groupId = "io.ballerina.stdlib"
1414
artifactId = "ibm.ibmmq-native"
1515
version = "@toml.version@"
1616
path = "../native/build/libs/ibm.ibmmq-native-@project.version@.jar"
1717

18-
[[platform.java17.dependency]]
18+
[[platform.java21.dependency]]
1919
groupId = "org.json"
2020
artifactId = "json"
2121
version = "@json.version@"
2222
path = "./lib/json-@json.version@.jar"
2323

24-
[[platform.java17.dependency]]
24+
[[platform.java21.dependency]]
2525
groupId = "com.ibm.mq"
2626
artifactId = "com.ibm.mq.allclient"
2727
version = "@ibmmq.version@"
2828
path = "./lib/com.ibm.mq.allclient-@ibmmq.version@.jar"
2929
scope = "provided"
3030

31-
[[platform.java17.dependency]]
31+
[[platform.java21.dependency]]
3232
groupId = "com.fasterxml.jackson.core"
3333
artifactId = "jackson-annotations"
3434
version = "@jackson.version@"
3535
path = "./lib/jackson-annotations-@jackson.version@.jar"
3636

37-
[[platform.java17.dependency]]
37+
[[platform.java21.dependency]]
3838
groupId = "com.fasterxml.jackson.core"
3939
artifactId = "jackson-core"
4040
version = "@jackson.version@"
4141
path = "./lib/jackson-core-@jackson.version@.jar"
4242

43-
[[platform.java17.dependency]]
43+
[[platform.java21.dependency]]
4444
groupId = "com.fasterxml.jackson.core"
4545
artifactId = "jackson-databind"
4646
version = "@jackson.version@"

gradle.properties

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
org.gradle.caching=true
22
group=io.ballerina.lib
3-
version=1.2.1-SNAPSHOT
3+
version=1.3.0-SNAPSHOT
44

5-
ballerinaLangVersion=2201.9.0
5+
ballerinaLangVersion=2201.11.0-20241117-133400-a3054b77
66
checkstylePluginVersion=10.12.1
7-
spotbugsPluginVersion=5.0.14
7+
spotbugsPluginVersion=6.0.18
88
shadowJarPluginVersion=8.1.1
99
downloadPluginVersion=5.4.0
1010
releasePluginVersion=2.8.0
1111
ballerinaGradlePluginVersion=2.0.1
1212

1313
# IBM MQ dependencies
14-
ibmMQVersion=9.3.4.0
14+
ibmMQVersion=9.4.1.0
1515
jsonVersion=20231013
1616
jacksonVersion=2.15.3
1717

1818
#stdlib dependencies
1919

2020
# Level 01
21-
stdlibTimeVersion=2.4.0
22-
stdlibIoVersion=1.6.0
21+
stdlibTimeVersion=2.6.0-20241113-073800-201b904
22+
stdlibIoVersion=1.6.2-20241112-233100-995cf5f
2323

2424
# Level 02
25-
stdlibLogVersion=2.9.0
26-
stdlibCryptoVersion=2.7.2
25+
stdlibLogVersion=2.10.1-20241113-120000-4577868
26+
stdlibCryptoVersion=2.7.3-20241113-081400-d015a39
2727

2828
# Level 03
29-
stdlibUuidVersion=1.7.0
29+
stdlibUuidVersion=1.8.1-20241113-154400-443c67b
3030

31-
observeVersion=1.2.0
32-
observeInternalVersion=1.2.0
31+
observeVersion=1.4.0-20241113-092000-b83ae74
32+
observeInternalVersion=1.3.1-20241113-101700-265054d

native/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ checkstyle {
4545
checkstyleMain.dependsOn(":checkstyle:downloadCheckstyleRuleFiles")
4646

4747
spotbugsMain {
48-
effort "max"
49-
reportLevel "low"
48+
def classLoader = plugins["com.github.spotbugs"].class.classLoader
49+
def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence")
50+
def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort")
51+
effort = SpotBugsEffort.MAX
52+
reportLevel = SpotBugsConfidence.LOW
5053
reportsDir = file("$project.buildDir/reports/spotbugs")
5154
reports {
5255
html.enabled true

native/src/main/java/io/ballerina/lib/ibm.ibmmq/CommonUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
import io.ballerina.lib.ibm.ibmmq.config.GetMessageOptions;
2828
import io.ballerina.lib.ibm.ibmmq.config.MatchOptions;
2929
import io.ballerina.lib.ibm.ibmmq.headers.MQRFH2Header;
30-
import io.ballerina.runtime.api.PredefinedTypes;
3130
import io.ballerina.runtime.api.Runtime;
3231
import io.ballerina.runtime.api.creators.ErrorCreator;
3332
import io.ballerina.runtime.api.creators.TypeCreator;
3433
import io.ballerina.runtime.api.creators.ValueCreator;
3534
import io.ballerina.runtime.api.flags.SymbolFlags;
3635
import io.ballerina.runtime.api.types.ArrayType;
36+
import io.ballerina.runtime.api.types.PredefinedTypes;
3737
import io.ballerina.runtime.api.utils.StringUtils;
3838
import io.ballerina.runtime.api.values.BArray;
3939
import io.ballerina.runtime.api.values.BError;

native/src/main/java/io/ballerina/lib/ibm.ibmmq/HeaderFieldValuesCallback.java

Lines changed: 0 additions & 66 deletions
This file was deleted.

native/src/main/java/io/ballerina/lib/ibm.ibmmq/Queue.java

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,82 +26,65 @@
2626
import com.ibm.mq.constants.CMQC;
2727
import io.ballerina.lib.ibm.ibmmq.config.GetMessageOptions;
2828
import io.ballerina.runtime.api.Environment;
29-
import io.ballerina.runtime.api.Future;
30-
import io.ballerina.runtime.api.values.BError;
3129
import io.ballerina.runtime.api.values.BMap;
3230
import io.ballerina.runtime.api.values.BObject;
3331
import io.ballerina.runtime.api.values.BString;
3432

35-
import java.util.concurrent.ExecutorService;
36-
import java.util.concurrent.Executors;
37-
3833
import static io.ballerina.lib.ibm.ibmmq.CommonUtils.createError;
3934
import static io.ballerina.lib.ibm.ibmmq.Constants.IBMMQ_ERROR;
4035

4136
/**
4237
* Representation of {@link com.ibm.mq.MQQueue} with utility methods to invoke as inter-op functions.
4338
*/
4439
public class Queue {
45-
private static final ExecutorService QUEUE_EXECUTOR_SERVICE = Executors.newCachedThreadPool(
46-
new MQThreadFactory("balx-ibmmq-queue-client-network-thread"));
47-
4840
public static Object put(Environment environment, BObject queueObject, BMap<BString, Object> message,
4941
long options) {
5042
MQQueue queue = (MQQueue) queueObject.getNativeData(Constants.NATIVE_QUEUE);
5143
MQMessage mqMessage = CommonUtils.getMqMessageFromBMessage(message);
52-
Future future = environment.markAsync();
53-
QUEUE_EXECUTOR_SERVICE.execute(() -> {
44+
return environment.yieldAndRun(() -> {
5445
try {
5546
MQPutMessageOptions pmo = new MQPutMessageOptions();
5647
pmo.options = (int) options;
5748
queue.put(mqMessage, pmo);
58-
future.complete(null);
49+
return null;
5950
} catch (MQException e) {
60-
BError bError = createError(IBMMQ_ERROR,
51+
return createError(IBMMQ_ERROR,
6152
String.format("Error occurred while putting a message to the queue: %s", e.getMessage()), e);
62-
future.complete(bError);
6353
}
6454
});
65-
return null;
6655
}
6756

6857
public static Object get(Environment environment, BObject queueObject, BMap<BString, Object> bGetMsgOptions) {
6958
MQQueue queue = (MQQueue) queueObject.getNativeData(Constants.NATIVE_QUEUE);
7059
GetMessageOptions getMsgOptions = new GetMessageOptions(bGetMsgOptions);
7160
MQMessage mqMessage = CommonUtils.getMqMessage(getMsgOptions.matchOptions());
7261
MQGetMessageOptions mqGetMsgOptions = CommonUtils.getMqGetMsgOptions(getMsgOptions);
73-
Future future = environment.markAsync();
74-
QUEUE_EXECUTOR_SERVICE.execute(() -> {
62+
return environment.yieldAndRun(() -> {
7563
try {
7664
queue.get(mqMessage, mqGetMsgOptions);
77-
future.complete(CommonUtils.getBMessageFromMQMessage(environment.getRuntime(), mqMessage));
65+
return CommonUtils.getBMessageFromMQMessage(environment.getRuntime(), mqMessage);
7866
} catch (MQException e) {
7967
if (e.reasonCode == CMQC.MQRC_NO_MSG_AVAILABLE) {
80-
future.complete(null);
68+
return null;
8169
} else {
82-
BError bError = createError(IBMMQ_ERROR,
70+
return createError(IBMMQ_ERROR,
8371
String.format("Error occurred while getting a message from the queue: %s",
8472
e.getMessage()), e);
85-
future.complete(bError);
8673
}
8774
}
8875
});
89-
return null;
9076
}
9177

9278
public static Object close(Environment env, BObject queueObject) {
9379
MQQueue queue = (MQQueue) queueObject.getNativeData(Constants.NATIVE_QUEUE);
94-
Future future = env.markAsync();
95-
QUEUE_EXECUTOR_SERVICE.execute(() -> {
80+
return env.yieldAndRun(() -> {
9681
try {
9782
queue.close();
98-
future.complete(null);
83+
return null;
9984
} catch (MQException e) {
100-
BError bError = createError(IBMMQ_ERROR,
85+
return createError(IBMMQ_ERROR,
10186
String.format("Error occurred while closing the queue: %s", e.getMessage()), e);
102-
future.complete(bError);
10387
}
10488
});
105-
return null;
10689
}
10790
}

0 commit comments

Comments
 (0)