Skip to content

NullPointerException in requestBinaryLogStreamMaria when GTID set is empty/null #174

Description

@KMohnishM

Summary

BinaryLogClient.requestBinaryLogStreamMaria() throws a NullPointerException when the GTID set is empty or not initialized.


Description

When the client is initialized with an empty GTID string (setGtidSet("")), the value is ignored internally and gtidSet remains null.

However, in the MariaDB-specific streaming path (requestBinaryLogStreamMaria()), the code assumes that gtidSet is always non-null and directly invokes gtidSet.toString(). This results in a NullPointerException during startup.


Root Cause

  • Empty GTID string passed via setGtidSet("")
  • Empty string is ignored internally
  • gtidSet remains null
  • MariaDB streaming path assumes non-null and calls toString()

Expected Behavior

If the GTID set is empty or not available, the client should not attempt to use it.

Instead, it should:

  • Skip execution of SET @slave_connect_state = ...
  • Continue with binlog streaming without GTID initialization

Proposed Fix

Add a null/empty check before using gtidSet in requestBinaryLogStreamMaria().

For example:

if (gtidSet != null && !gtidSet.toString().isEmpty()) {
// execute SET @slave_connect_state
}

This ensures the client behaves correctly when GTID is not available and avoids the NPE.


Additional Context

This issue was encountered while using Debezium with MariaDB, where the connector may start without a valid GTID state.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions