Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerinax"
name = "mysql"
version = "1.16.1"
version = "1.16.2"
authors = ["Ballerina"]
keywords = ["database", "client", "network", "SQL", "RDBMS", "MySQL"]
repository = "https://github.com/ballerina-platform/module-ballerinax-mysql"
Expand All @@ -15,8 +15,8 @@ graalvmCompatible = true
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "mysql-native"
version = "1.16.1"
path = "../native/build/libs/mysql-native-1.16.1.jar"
version = "1.16.2"
path = "../native/build/libs/mysql-native-1.16.2-SNAPSHOT.jar"

[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
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 = "mysql-compiler-plugin"
class = "io.ballerina.stdlib.mysql.compiler.MySQLCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/mysql-compiler-plugin-1.16.1.jar"
path = "../compiler-plugin/build/libs/mysql-compiler-plugin-1.16.2-SNAPSHOT.jar"
74 changes: 57 additions & 17 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ dependencies = [
{org = "ballerina", name = "log"}
]

[[package]]
org = "ballerina"
name = "avro"
version = "1.2.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "cache"
Expand All @@ -44,7 +52,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "crypto"
version = "2.9.0"
version = "2.10.1"
dependencies = [
Comment on lines 52 to 56
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Compare stdlib versions between gradle.properties and Dependencies.toml.
echo "=== Searching for stdlib versions in gradle.properties ==="
rg -n 'stdlib(Crypto|DataJsonData|Http|Jwt|Mime|OAuth2|Observe|Os|Time|Url)Version' gradle.properties

echo ""
echo "=== Searching for stdlib module names and versions in Dependencies.toml ==="
rg -n -C1 'name = "(crypto|data.jsondata|http|jwt|mime|oauth2|observe|os|time|url)"' ballerina/Dependencies.toml

echo ""
echo "=== Checking mysql module version alignment ==="
rg -n 'name = "mysql"|version = "1\.16\.2"' ballerina/Dependencies.toml ballerina/Ballerina.toml

Repository: ballerina-platform/module-ballerinax-mysql

Length of output: 4933


Version misalignments detected between gradle.properties and Dependencies.toml.

All stdlib module versions in Dependencies.toml exceed those specified in gradle.properties:

  • crypto: 2.10.1 vs 2.9.0
  • data.jsondata: 1.1.3 vs 1.1.0
  • http: 2.14.9 vs 2.14.0
  • jwt: 2.15.1 vs 2.15.0
  • mime: 2.12.1 vs 2.12.0
  • oauth2: 2.14.1 vs 2.14.0
  • os: 1.10.1 vs 1.10.0
  • time: 2.8.0 vs 2.7.0
  • url: 2.6.1 vs 2.6.0

Additionally, observe (1.5.1) appears in Dependencies.toml but has no corresponding entry in gradle.properties. The mysql module is correctly aligned at 1.16.2 in both files. Update gradle.properties to match Dependencies.toml versions to prevent build conflicts.

🤖 Prompt for AI Agents
In `@ballerina/Dependencies.toml` around lines 52 - 56, Update gradle.properties
so its stdlib module versions exactly match Dependencies.toml: set
crypto=2.10.1, data.jsondata=1.1.3, http=2.14.9, jwt=2.15.1, mime=2.12.1,
oauth2=2.14.1, os=1.10.1, time=2.8.0, and url=2.6.1; also add the missing module
entry present in Dependencies.toml that uses version 1.5.1 (the module listed
with 1.5.1 in Dependencies.toml) so every module/version pair in
Dependencies.toml has a corresponding entry in gradle.properties (mysql can be
left as-is at 1.16.2).

{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "time"}
Expand All @@ -56,7 +64,7 @@ modules = [
[[package]]
org = "ballerina"
name = "data.jsondata"
version = "1.1.0"
version = "1.1.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
Expand All @@ -80,7 +88,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http"
version = "2.14.0"
version = "2.14.9"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -130,7 +138,7 @@ modules = [
[[package]]
org = "ballerina"
name = "jwt"
version = "2.15.0"
version = "2.15.1"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "cache"},
Expand All @@ -147,7 +155,6 @@ dependencies = [
org = "ballerina"
name = "lang.__internal"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
Expand Down Expand Up @@ -185,7 +192,6 @@ dependencies = [
org = "ballerina"
name = "lang.int"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.__internal"},
Expand Down Expand Up @@ -255,7 +261,6 @@ dependencies = [
org = "ballerina"
name = "log"
version = "2.12.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -266,7 +271,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "mime"
version = "2.12.0"
version = "2.12.1"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "io"},
Expand All @@ -278,7 +283,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "oauth2"
version = "2.14.0"
version = "2.14.1"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "cache"},
Expand All @@ -292,15 +297,15 @@ dependencies = [
[[package]]
org = "ballerina"
name = "observe"
version = "1.5.0"
version = "1.5.1"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "os"
version = "1.10.0"
version = "1.10.1"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "io"},
Expand Down Expand Up @@ -360,7 +365,7 @@ modules = [
[[package]]
org = "ballerina"
name = "time"
version = "2.7.0"
version = "2.8.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand All @@ -371,7 +376,7 @@ modules = [
[[package]]
org = "ballerina"
name = "url"
version = "2.6.0"
version = "2.6.1"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
Expand All @@ -381,7 +386,6 @@ dependencies = [
org = "ballerina"
name = "uuid"
version = "1.10.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -423,21 +427,57 @@ modules = [
[[package]]
org = "ballerinax"
name = "cdc"
version = "1.0.1"
version = "1.2.0"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "data.jsondata"},
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerinai", name = "observe"}
{org = "ballerina", name = "log"},
{org = "ballerinai", name = "observe"},
{org = "ballerinax", name = "kafka"}
]
modules = [
{org = "ballerinax", packageName = "cdc", moduleName = "cdc"}
]

[[package]]
org = "ballerinax"
name = "confluent.cavroserdes"
version = "1.0.2"
dependencies = [
{org = "ballerina", name = "avro"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerinai", name = "observe"},
{org = "ballerinax", name = "confluent.cregistry"}
]

[[package]]
org = "ballerinax"
name = "confluent.cregistry"
version = "0.4.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerinax"
name = "kafka"
version = "4.6.3"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "time"},
{org = "ballerina", name = "uuid"},
{org = "ballerinai", name = "observe"},
{org = "ballerinax", name = "confluent.cavroserdes"},
{org = "ballerinax", name = "confluent.cregistry"}
]

[[package]]
org = "ballerinax"
name = "mysql"
version = "1.16.1"
version = "1.16.2"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "file"},
Expand Down
16 changes: 10 additions & 6 deletions ballerina/cdc_listener.bal
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ import ballerinax/cdc;
public isolated class CdcListener {
*cdc:Listener;

private final map<string> & readonly config;
private final map<anydata> & readonly config;
private boolean isStarted = false;
private boolean hasAttachedService = false;
Comment on lines +22 to 24
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for usages of isStarted and hasAttachedService in .bal files
rg -n 'isStarted|hasAttachedService' --type-add 'bal:*.bal' --type bal

Repository: ballerina-platform/module-ballerinax-mysql

Length of output: 232


Remove unused fields isStarted and hasAttachedService.

These fields are declared at lines 23-24 but never used anywhere in the codebase. No assignments or references to these fields exist outside of their initial declarations, indicating they are dead code and should be removed.

🤖 Prompt for AI Agents
In `@ballerina/cdc_listener.bal` around lines 22 - 24, The fields isStarted and
hasAttachedService in the cdc listener object are declared but never referenced;
remove the unused boolean fields isStarted and hasAttachedService from the
object/record declaration in cdc_listener.bal (the declarations "private boolean
isStarted = false;" and "private boolean hasAttachedService = false;") so the
type no longer contains dead fields, and run tests/compile to confirm no
remaining references; no other code changes are required if there are truly no
usages.


# Initializes the MySQL listener with the given configuration.
#
# + config - The configuration for the MySQL connector
public isolated function init(*MySqlListenerConfiguration config) {
map<string> configMap = {};
map<string> debeziumConfigs = {};
cdc:populateDebeziumProperties({
engineName: config.engineName,
offsetStorage: config.offsetStorage,
internalSchemaStorage: config.internalSchemaStorage,
options: config.options
}, configMap);
}, debeziumConfigs);
cdc:populateDatabaseConfigurations({
connectorClass: config.database.connectorClass,
hostname: config.database.hostname,
Expand All @@ -47,9 +47,13 @@ public isolated class CdcListener {
excludedTables: config.database.excludedTables,
includedColumns: config.database.includedColumns,
excludedColumns: config.database.excludedColumns
}, configMap);
populateMySqlConfigurations(config.database, configMap);
self.config = configMap.cloneReadOnly();
}, debeziumConfigs);
populateMySqlConfigurations(config.database, debeziumConfigs);
map<anydata> listenerConfigs = {
...debeziumConfigs
};
listenerConfigs["livenessInterval"] = config.livenessInterval;
self.config = listenerConfigs.cloneReadOnly();
}

# Attaches a CDC service to the MySQL listener.
Expand Down
103 changes: 103 additions & 0 deletions ballerina/tests/listener_liveness_test.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/lang.runtime;
import ballerina/test;
import ballerinax/cdc;

@test:Config {
groups: ["liveness"]
}
function testLivenessBeforeListenerStart() returns error? {
CdcListener mysqlListener = new ({
database: {
username: cdcUsername,
password: cdcPassword,
port
},
options: {
snapshotMode: cdc:NO_DATA
}
});
check mysqlListener.attach(testService);
boolean liveness = check cdc:isLive(mysqlListener);
test:assertFalse(liveness, "Liveness check passes even before listener starts");
}

@test:Config {
groups: ["liveness"]
}
function testLivenessWithStartedListener() returns error? {
CdcListener mysqlListener = new ({
database: {
username: cdcUsername,
password: cdcPassword,
port
},
options: {
snapshotMode: cdc:NO_DATA
}
});
check mysqlListener.attach(testService);
check mysqlListener.'start();
boolean liveness = check cdc:isLive(mysqlListener);
test:assertTrue(liveness, "Liveness fails for a started listener");
check mysqlListener.gracefulStop();
}

@test:Config {
groups: ["liveness"]
}
function testLivenessAfterListenerStop() returns error? {
CdcListener mysqlListener = new ({
database: {
username: cdcUsername,
password: cdcPassword,
port
},
options: {
snapshotMode: cdc:NO_DATA
}
});
check mysqlListener.attach(testService);
check mysqlListener.'start();
check mysqlListener.gracefulStop();
boolean liveness = check cdc:isLive(mysqlListener);
test:assertFalse(liveness, "Liveness check passes after the listener has stopped");
}

@test:Config {
groups: ["liveness"]
}
function testLivenessWithoutReceivingEvents() returns error? {
CdcListener mysqlListener = new ({
database: {
username: cdcUsername,
password: cdcPassword,
port
},
options: {
snapshotMode: cdc:NO_DATA
},
livenessInterval: 5.0
});
check mysqlListener.attach(testService);
check mysqlListener.'start();
runtime:sleep(10);
boolean liveness = check cdc:isLive(mysqlListener);
test:assertFalse(liveness, "Liveness check passes even after not receiving events within the liveness interval");
check mysqlListener.gracefulStop();
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ stdlibTransactionVersion=1.12.0

# Ballerina library
stdlibMysqlDriverVersion=1.8.0
stdlibCdcVersion=1.0.1
stdlibCdcVersion=1.2.0-20260213-180200-2268a4d
stdlibMySQLCdcDriverVersion=1.0.1

jacocoVersion=0.8.10
Expand Down
Loading