You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flink.apache.org by "ericzeng (Jira)" <ji...@apache.org> on 2026/03/23 14:24:00 UTC

[jira] [Created] (FLINK-39300) [flink-cdc] Reuse ObjectMapper as static constant to avoid repeated instantiation

ericzeng created FLINK-39300:
--------------------------------

             Summary:   [flink-cdc] Reuse ObjectMapper as static constant to avoid repeated instantiation
                 Key: FLINK-39300
                 URL: https://issues.apache.org/jira/browse/FLINK-39300
             Project: Flink
          Issue Type: Improvement
          Components: Flink CDC
    Affects Versions: cdc-3.5.0
            Reporter: ericzeng


 *Motivation*

  `ObjectMapper` (Jackson) is expensive to construct — it triggers reflection-based
  module discovery, codec registry initialization, and other setup work on every
  instantiation. It is also fully thread-safe once configured, making it an ideal
  candidate for a shared static constant.

  Currently, two classes in the mysql-cdc connector create a new `ObjectMapper`
  instance on every method call:

  - `BinlogOffsetSerializer`: both `serialize()` and `deserialize()` instantiate a
    new `ObjectMapper` each time. Since this class is used as a singleton (`INSTANCE`),
    these methods can be called at high frequency during snapshot and binlog reading,
    making the repeated allocation particularly wasteful.

  - `OnlineSchemaChangeUtils`: both `isOnLineSchemaChangeEvent()` and
    `parseOnLineSchemaRenameEvent()` instantiate a new `ObjectMapper` each time they
    are invoked to parse DDL statements.
 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)