Skip to content

Commit 8574240

Browse files
Merge pull request #1328 from ravinperera00/java21_sync
Migrate to Java 21
2 parents 662f258 + 8705de3 commit 8574240

File tree

8 files changed

+58
-48
lines changed

8 files changed

+58
-48
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ This repository only contains the source code for the module.
3333

3434
### Set up the prerequisites
3535

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

3838
* [Oracle](https://www.oracle.com/java/technologies/downloads/)
3939

ballerina/Ballerina.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ keywords = ["security", "authorization", "introspection"]
77
repository = "https://github.com/ballerina-platform/module-ballerina-oauth2"
88
icon = "icon.png"
99
license = ["Apache-2.0"]
10-
distribution = "2201.10.0"
10+
distribution = "2201.10.0-20241007-143200-6b69ca80"
1111

12-
[platform.java17]
12+
[platform.java21]
1313
graalvmCompatible = true
1414

15-
[[platform.java17.dependency]]
15+
[[platform.java21.dependency]]
1616
groupId = "io.ballerina.stdlib"
1717
artifactId = "oauth2-native"
1818
version = "2.12.1"

ballerina/Dependencies.toml

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

66
[ballerina]
77
dependencies-toml-version = "2"
8-
distribution-version = "2201.10.0"
8+
distribution-version = "2201.11.0-20241112-214900-6b80ab87"
99

1010
[[package]]
1111
org = "ballerina"
1212
name = "cache"
13-
version = "3.8.0"
13+
version = "3.8.1"
1414
dependencies = [
1515
{org = "ballerina", name = "constraint"},
1616
{org = "ballerina", name = "jballerina.java"},
@@ -24,15 +24,15 @@ modules = [
2424
[[package]]
2525
org = "ballerina"
2626
name = "constraint"
27-
version = "1.5.0"
27+
version = "1.6.0"
2828
dependencies = [
2929
{org = "ballerina", name = "jballerina.java"}
3030
]
3131

3232
[[package]]
3333
org = "ballerina"
3434
name = "crypto"
35-
version = "2.7.2"
35+
version = "2.7.3"
3636
dependencies = [
3737
{org = "ballerina", name = "jballerina.java"},
3838
{org = "ballerina", name = "time"}
@@ -44,7 +44,7 @@ modules = [
4444
[[package]]
4545
org = "ballerina"
4646
name = "io"
47-
version = "1.6.0"
47+
version = "1.6.2"
4848
dependencies = [
4949
{org = "ballerina", name = "jballerina.java"},
5050
{org = "ballerina", name = "lang.value"}
@@ -116,7 +116,7 @@ dependencies = [
116116
[[package]]
117117
org = "ballerina"
118118
name = "log"
119-
version = "2.10.0"
119+
version = "2.10.1"
120120
dependencies = [
121121
{org = "ballerina", name = "io"},
122122
{org = "ballerina", name = "jballerina.java"},
@@ -148,15 +148,15 @@ modules = [
148148
[[package]]
149149
org = "ballerina"
150150
name = "observe"
151-
version = "1.3.0"
151+
version = "1.4.0"
152152
dependencies = [
153153
{org = "ballerina", name = "jballerina.java"}
154154
]
155155

156156
[[package]]
157157
org = "ballerina"
158158
name = "task"
159-
version = "2.5.0"
159+
version = "2.5.1"
160160
dependencies = [
161161
{org = "ballerina", name = "jballerina.java"},
162162
{org = "ballerina", name = "time"}
@@ -179,7 +179,7 @@ modules = [
179179
[[package]]
180180
org = "ballerina"
181181
name = "time"
182-
version = "2.4.0"
182+
version = "2.6.0"
183183
dependencies = [
184184
{org = "ballerina", name = "jballerina.java"}
185185
]
@@ -190,7 +190,7 @@ modules = [
190190
[[package]]
191191
org = "ballerina"
192192
name = "url"
193-
version = "2.4.0"
193+
version = "2.4.1"
194194
dependencies = [
195195
{org = "ballerina", name = "jballerina.java"}
196196
]

build-config/resources/Ballerina.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ keywords = ["security", "authorization", "introspection"]
77
repository = "https://github.com/ballerina-platform/module-ballerina-oauth2"
88
icon = "icon.png"
99
license = ["Apache-2.0"]
10-
distribution = "2201.10.0"
10+
distribution = "2201.10.0-20241007-143200-6b69ca80"
1111

12-
[platform.java17]
12+
[platform.java21]
1313
graalvmCompatible = true
1414

15-
[[platform.java17.dependency]]
15+
[[platform.java21.dependency]]
1616
groupId = "io.ballerina.stdlib"
1717
artifactId = "oauth2-native"
1818
version = "@toml.version@"

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
*/
1818

1919
plugins {
20-
id "com.github.spotbugs" version "5.0.14"
21-
id "com.github.johnrengelman.shadow" version "8.1.1"
22-
id "de.undercouch.download" version "5.4.0"
23-
id "net.researchgate.release" version "2.8.0"
20+
id "com.github.spotbugs" version "${githubSpotbugsVersion}"
21+
id "com.github.johnrengelman.shadow" version "${githubJohnrengelmanShadowVersion}"
22+
id "de.undercouch.download" version "${underCouchDownloadVersion}"
23+
id "net.researchgate.release" version "${researchgateReleaseVersion}"
2424
}
2525

2626
allprojects {

gradle.properties

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@ group=io.ballerina.stdlib
33
version=2.12.1-SNAPSHOT
44
puppycrawlCheckstyleVersion=10.12.0
55
ballerinaGradlePluginVersion=2.0.1
6-
ballerinaLangVersion=2201.10.0
6+
ballerinaLangVersion=2201.11.0-20241112-214900-6b80ab87
7+
githubJohnrengelmanShadowVersion=8.1.1
8+
underCouchDownloadVersion=5.4.0
9+
researchgateReleaseVersion=2.8.0
10+
githubSpotbugsVersion=6.0.18
711

812
# Dependencies
9-
stdlibCacheVersion=3.8.0
10-
stdlibCryptoVersion=2.7.2
11-
stdlibLogVersion=2.10.0
12-
stdlibTimeVersion=2.4.0
13-
stdlibUrlVersion=2.4.0
13+
stdlibCacheVersion=3.8.1-20241113-125700-b75a1bf
14+
stdlibCryptoVersion=2.7.3-20241113-081400-d015a39
15+
stdlibLogVersion=2.10.1-20241113-120000-4577868
16+
stdlibTimeVersion=2.6.0-20241113-073800-201b904
17+
stdlibUrlVersion=2.4.1-20241113-073900-335ff51
1418

1519
# Transitive dependencies
16-
stdlibTaskVersion=2.5.0
17-
stdlibConstraintVersion=1.5.0
18-
stdlibIoVersion=1.6.0
19-
observeVersion=1.3.0
20-
observeInternalVersion=1.3.0
20+
stdlibTaskVersion=2.5.1-20241113-123500-f905281
21+
stdlibConstraintVersion=1.6.0-20241113-090900-d276ad5
22+
stdlibIoVersion=1.6.2-20241112-233100-995cf5f
23+
observeVersion=1.4.0-20241113-092000-b83ae74
24+
observeInternalVersion=1.3.1-20241113-101700-265054d

native/build.gradle

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

4242
spotbugsMain {
43-
effort "max"
44-
reportLevel "low"
43+
def classLoader = plugins["com.github.spotbugs"].class.classLoader
44+
def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence")
45+
def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort")
46+
effort = SpotBugsEffort.MAX
47+
reportLevel = SpotBugsConfidence.LOW
4548
reportsDir = file("$project.buildDir/reports/spotbugs")
4649
reports {
4750
html.enabled true

native/src/main/java/io/ballerina/stdlib/oauth2/OAuth2Client.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package io.ballerina.stdlib.oauth2;
2020

21+
import io.ballerina.runtime.api.Environment;
2122
import io.ballerina.runtime.api.creators.ErrorCreator;
2223
import io.ballerina.runtime.api.utils.StringUtils;
2324
import io.ballerina.runtime.api.values.BError;
@@ -56,8 +57,8 @@ public class OAuth2Client {
5657

5758
private OAuth2Client() {}
5859

59-
public static Object doHttpRequest(BString url, BMap<BString, Object> clientConfig, BMap<BString, BString> headers,
60-
BString payload) {
60+
public static Object doHttpRequest(Environment env, BString url, BMap<BString, Object> clientConfig,
61+
BMap<BString, BString> headers, BString payload) {
6162
BString customPayload = getBStringValueIfPresent(clientConfig, OAuth2Constants.CUSTOM_PAYLOAD);
6263
String textPayload = payload.getValue();
6364
if (customPayload != null) {
@@ -100,13 +101,13 @@ public static Object doHttpRequest(BString url, BMap<BString, Object> clientConf
100101
try {
101102
SSLContext sslContext = getSslContext(secureSocket);
102103
HttpClient client = buildHttpClient(httpVersion, sslContext);
103-
return callEndpoint(client, request);
104+
return callEndpoint(env, client, request);
104105
} catch (Exception e) {
105106
return createError("Failed to init SSL context. " + e.getMessage());
106107
}
107108
}
108109
HttpClient client = buildHttpClient(httpVersion);
109-
return callEndpoint(client, request);
110+
return callEndpoint(env, client, request);
110111
}
111112

112113
private static URI buildUri(String url, BMap<BString, ?> secureSocket) throws IllegalArgumentException {
@@ -300,17 +301,19 @@ private static HttpRequest buildHttpRequest(URI uri, String[] headers, String pa
300301
.build();
301302
}
302303

303-
private static Object callEndpoint(HttpClient client, HttpRequest request) {
304-
try {
305-
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
306-
if (response.statusCode() >= 200 && response.statusCode() < 300) {
307-
return StringUtils.fromString(response.body());
304+
private static Object callEndpoint(Environment env, HttpClient client, HttpRequest request) {
305+
return env.yieldAndRun(() -> {
306+
try {
307+
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
308+
if (response.statusCode() >= 200 && response.statusCode() < 300) {
309+
return StringUtils.fromString(response.body());
310+
}
311+
return createError("Failed to get a success response from the endpoint. Response code: '" +
312+
response.statusCode() + "'. Response body: '" + response.body() + "'");
313+
} catch (IOException | InterruptedException e) {
314+
return createError("Failed to send the request to the endpoint. " + e.getMessage());
308315
}
309-
return createError("Failed to get a success response from the endpoint. Response code: '" +
310-
response.statusCode() + "'. Response body: '" + response.body() + "'");
311-
} catch (IOException | InterruptedException e) {
312-
return createError("Failed to send the request to the endpoint. " + e.getMessage());
313-
}
316+
});
314317
}
315318

316319
private static BMap<BString, ?> getBMapValueIfPresent(BMap<BString, ?> config, BString key) {

0 commit comments

Comments
 (0)