Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-2443

Optimize AbstractSourceInfo and AbstractSourceInfoStructMaker regarding NULL checks/safety

    Details

    • Type: Enhancement
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core-library
    • Labels:
      None

      Description

      RFC

      Currently `AbstractSourceInfoStructMaker#commonStruct(T sourceInfo)` and other places handle `io.debezium.connector.AbstractSourceInfo` returned null values from the outside.
      (e.g. `final Instant timestamp = sourceInfo.timestamp() == null ? Instant.now() : sourceInfo.timestamp();`)

      Instead we could move that null checks into `AbstractSourceInfo`.
      For that we can make the current abstract methods having a default implementation on that interface that handles null safety, and let the implementations of the interface implement "internal" getters that don't require null-safety.

      Furthermore AbstractSourceInfoStructMaker#commonStruct(T sourceInfo) gets `T extends AbstractSourceInfo` as method parameter. The method only reads the timestamp(), database() and snapshot() info from the passed `sourceInfo` variable. Passing it that way was causing NPE sometimes because of the fore-mentioned not being null-safe.

      Instead of passing `T extends AbstractSourceInfo` here, we could change the signature  to only accept the three variable parameters (timestamp, database, snapshot) which might bring more null safety.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                rkerner René Kerner
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: