From c3776a2ebb22ae2b81282a752ad1832ff337a9da Mon Sep 17 00:00:00 2001 From: vil02 Date: Sat, 14 Oct 2023 17:17:51 +0200 Subject: [PATCH 1/3] [Automated] Update the native jar versions --- ballerina/Ballerina.toml | 8 ++++---- ballerina/CompilerPlugin.toml | 2 +- ballerina/Dependencies.toml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 8d1871e1..4f7885a3 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerina" name = "udp" -version = "1.9.1" +version = "1.9.2" authors = ["Ballerina"] keywords = ["UDP", "datagram", "transport"] repository = "https://github.com/ballerina-platform/module-ballerina-udp" @@ -15,11 +15,11 @@ graalvmCompatible = true [[platform.java17.dependency]] groupId = "io.ballerina.stdlib" artifactId = "udp-native" -version = "1.9.1" -path = "../native/build/libs/udp-native-1.9.1.jar" +version = "1.9.2" +path = "../native/build/libs/udp-native-1.9.2-SNAPSHOT.jar" [[platform.java17.dependency]] -path = "../test-utils/build/libs/udp-test-utils-1.9.1.jar" +path = "../test-utils/build/libs/udp-test-utils-1.9.2-SNAPSHOT.jar" scope = "testOnly" [[platform.java17.dependency]] diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index 5c407ad4..8573e2a7 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -3,4 +3,4 @@ id = "udp-plugin" class = "io.ballerina.stdlib.udp.compiler.UdpCompilerPlugin" [[dependency]] -path = "../compiler-plugin/build/libs/udp-compiler-plugin-1.9.1.jar" +path = "../compiler-plugin/build/libs/udp-compiler-plugin-1.9.2-SNAPSHOT.jar" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 923d8c0e..36d629fd 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -86,7 +86,7 @@ modules = [ [[package]] org = "ballerina" name = "udp" -version = "1.9.1" +version = "1.9.2" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, From 4105e477fe5270319250bdf1cf7ced1fa3c89a8e Mon Sep 17 00:00:00 2001 From: vil02 Date: Sat, 14 Oct 2023 17:20:12 +0200 Subject: [PATCH 2/3] Make some Java classes proper utilities Made the design cleaner by marking Java classes as `final` and explicitly declaring their default constructors as `private`. This change makes the code coverage reports more accurate. Closes #4926. --- changelog.md | 3 +++ .../src/main/java/io/ballerina/stdlib/udp/compiler/Utils.java | 4 +++- native/src/main/java/io/ballerina/stdlib/udp/Constants.java | 4 +++- native/src/main/java/io/ballerina/stdlib/udp/Dispatcher.java | 4 +++- native/src/main/java/io/ballerina/stdlib/udp/Utils.java | 4 +++- .../java/io/ballerina/stdlib/udp/nativeclient/Client.java | 4 +++- .../io/ballerina/stdlib/udp/nativeclient/ConnectClient.java | 4 +++- .../java/io/ballerina/stdlib/udp/nativelistener/Caller.java | 4 +++- .../java/io/ballerina/stdlib/udp/nativelistener/Listener.java | 4 +++- .../io/ballerina/stdlib/udp/testutils/MockServerUtils.java | 4 +++- 10 files changed, 30 insertions(+), 9 deletions(-) diff --git a/changelog.md b/changelog.md index 3769df80..9f8aeaaa 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Changed +- [Make some of the Java classes proper utility classes](https://github.com/ballerina-platform/ballerina-standard-library/issues/4926) + ## [1.9.1] - 2023-10-12 ### Fixed diff --git a/compiler-plugin/src/main/java/io/ballerina/stdlib/udp/compiler/Utils.java b/compiler-plugin/src/main/java/io/ballerina/stdlib/udp/compiler/Utils.java index daff0a88..67f42fad 100644 --- a/compiler-plugin/src/main/java/io/ballerina/stdlib/udp/compiler/Utils.java +++ b/compiler-plugin/src/main/java/io/ballerina/stdlib/udp/compiler/Utils.java @@ -39,7 +39,9 @@ /** * Compiler-plugin utility class. */ -public class Utils { +public final class Utils { + + private Utils() {} public static final String NODE_LOCATION = "node.location"; public static final String LS = System.lineSeparator(); diff --git a/native/src/main/java/io/ballerina/stdlib/udp/Constants.java b/native/src/main/java/io/ballerina/stdlib/udp/Constants.java index 343b423a..1ecc20f8 100644 --- a/native/src/main/java/io/ballerina/stdlib/udp/Constants.java +++ b/native/src/main/java/io/ballerina/stdlib/udp/Constants.java @@ -21,7 +21,9 @@ /** * Constant variable for udp related operations. */ -public class Constants { +public final class Constants { + + private Constants() {} // Constant related to ballerina Datagram record public static final String DATAGRAM_RECORD = "Datagram"; diff --git a/native/src/main/java/io/ballerina/stdlib/udp/Dispatcher.java b/native/src/main/java/io/ballerina/stdlib/udp/Dispatcher.java index 41182301..d1efe5ae 100644 --- a/native/src/main/java/io/ballerina/stdlib/udp/Dispatcher.java +++ b/native/src/main/java/io/ballerina/stdlib/udp/Dispatcher.java @@ -39,7 +39,9 @@ /** * Dispatch async methods. */ -public class Dispatcher { +public final class Dispatcher { + + private Dispatcher() {} private static final Logger log = LoggerFactory.getLogger(Dispatcher.class); diff --git a/native/src/main/java/io/ballerina/stdlib/udp/Utils.java b/native/src/main/java/io/ballerina/stdlib/udp/Utils.java index 41422627..f82d04ec 100644 --- a/native/src/main/java/io/ballerina/stdlib/udp/Utils.java +++ b/native/src/main/java/io/ballerina/stdlib/udp/Utils.java @@ -39,7 +39,9 @@ * * @since 0.985.0 */ -public class Utils { +public final class Utils { + + private Utils() {} /** * udp standard library package ID. diff --git a/native/src/main/java/io/ballerina/stdlib/udp/nativeclient/Client.java b/native/src/main/java/io/ballerina/stdlib/udp/nativeclient/Client.java index bd1e1167..495ad41a 100644 --- a/native/src/main/java/io/ballerina/stdlib/udp/nativeclient/Client.java +++ b/native/src/main/java/io/ballerina/stdlib/udp/nativeclient/Client.java @@ -39,7 +39,9 @@ * * @since 1.1.0 */ -public class Client { +public final class Client { + + private Client() {} public static Object init(Environment env, BObject client, BMap config) { final Future balFuture = env.markAsync(); diff --git a/native/src/main/java/io/ballerina/stdlib/udp/nativeclient/ConnectClient.java b/native/src/main/java/io/ballerina/stdlib/udp/nativeclient/ConnectClient.java index 06440711..db69d392 100644 --- a/native/src/main/java/io/ballerina/stdlib/udp/nativeclient/ConnectClient.java +++ b/native/src/main/java/io/ballerina/stdlib/udp/nativeclient/ConnectClient.java @@ -39,7 +39,9 @@ * * @since 1.1.0 */ -public class ConnectClient { +public final class ConnectClient { + + private ConnectClient() {} public static Object init(Environment env, BObject client, BString remoteHost, int remotePort, BMap config) { diff --git a/native/src/main/java/io/ballerina/stdlib/udp/nativelistener/Caller.java b/native/src/main/java/io/ballerina/stdlib/udp/nativelistener/Caller.java index 89deb8f7..83f475de 100644 --- a/native/src/main/java/io/ballerina/stdlib/udp/nativelistener/Caller.java +++ b/native/src/main/java/io/ballerina/stdlib/udp/nativelistener/Caller.java @@ -36,7 +36,9 @@ /** * Native function implementations of the UDP Caller. */ -public class Caller { +public final class Caller { + + private Caller() {} public static Object sendBytes(Environment env, BObject caller, BArray data) { final Future callback = env.markAsync(); diff --git a/native/src/main/java/io/ballerina/stdlib/udp/nativelistener/Listener.java b/native/src/main/java/io/ballerina/stdlib/udp/nativelistener/Listener.java index 844ee3ab..4cc6d88e 100644 --- a/native/src/main/java/io/ballerina/stdlib/udp/nativelistener/Listener.java +++ b/native/src/main/java/io/ballerina/stdlib/udp/nativelistener/Listener.java @@ -38,7 +38,9 @@ /** * Native function implementations of the UDP Listener. */ -public class Listener { +public final class Listener { + private Listener() {} + private static final Logger log = LoggerFactory.getLogger(Client.class); public static Object init(BObject listener, int localPort, BMap config) { diff --git a/test-utils/src/main/java/io/ballerina/stdlib/udp/testutils/MockServerUtils.java b/test-utils/src/main/java/io/ballerina/stdlib/udp/testutils/MockServerUtils.java index 54245bd3..f1877649 100644 --- a/test-utils/src/main/java/io/ballerina/stdlib/udp/testutils/MockServerUtils.java +++ b/test-utils/src/main/java/io/ballerina/stdlib/udp/testutils/MockServerUtils.java @@ -32,7 +32,9 @@ /** * This UDP server udp will use to mock the backend server. */ -public class MockServerUtils { +public final class MockServerUtils { + + private MockServerUtils() {} private static MockUdpServer mockUdpServer; From 441b8da9946a9505fbbcfdb7d578278e2f0eb103 Mon Sep 17 00:00:00 2001 From: Piotr Idzik <65706193+vil02@users.noreply.github.com> Date: Tue, 17 Oct 2023 08:17:42 +0200 Subject: [PATCH 3/3] style: add blank line Co-authored-by: MohamedSabthar --- .../java/io/ballerina/stdlib/udp/nativelistener/Listener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/native/src/main/java/io/ballerina/stdlib/udp/nativelistener/Listener.java b/native/src/main/java/io/ballerina/stdlib/udp/nativelistener/Listener.java index 4cc6d88e..2fa0dcbe 100644 --- a/native/src/main/java/io/ballerina/stdlib/udp/nativelistener/Listener.java +++ b/native/src/main/java/io/ballerina/stdlib/udp/nativelistener/Listener.java @@ -39,6 +39,7 @@ * Native function implementations of the UDP Listener. */ public final class Listener { + private Listener() {} private static final Logger log = LoggerFactory.getLogger(Client.class);