github-actions[bot] commented on code in PR #69948:
URL: https://github.com/apache/doris/pull/69948#discussion_r4476292136


##########
fs_brokers/cdc_client/src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/TableMapEventMetadataDeserializer.java:
##########
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.
+ */
+
+package com.github.shyiko.mysql.binlog.event.deserialization;
+
+import com.github.shyiko.mysql.binlog.event.TableMapEventMetadata;
+import 
com.github.shyiko.mysql.binlog.event.TableMapEventMetadata.DefaultCharset;
+import com.github.shyiko.mysql.binlog.io.ByteArrayInputStream;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Copied from Flink CDC 3.6.0-1.20 (flink-connector-mysql-cdc).
+ *
+ * <p>Lines 109-111 and 204: decode VECTOR_DIMENSIONALITY (field 13) as packed 
integers and
+ * store the dimensions in TableMapEventMetadata; retain the signedness block 
boundary handling.
+ */
+public class TableMapEventMetadataDeserializer {
+
+    private final Logger logger = Logger.getLogger(getClass().getName());
+
+    public TableMapEventMetadata deserialize(
+            ByteArrayInputStream inputStream, int nColumns, int 
nNumericColumns)
+            throws IOException {
+        int remainingBytes = inputStream.available();
+        if (remainingBytes <= 0) {
+            return null;
+        }
+
+        TableMapEventMetadata result = new TableMapEventMetadata();
+
+        for (; remainingBytes > 0; inputStream.enterBlock(remainingBytes)) {
+            int code = inputStream.readInteger(1);
+
+            MetadataFieldType fieldType = MetadataFieldType.byCode(code);
+            if (fieldType == null) {
+                throw new IOException("Unsupported table metadata field type " 
+ code);
+            }
+            if 
(MetadataFieldType.UNKNOWN_METADATA_FIELD_TYPE.equals(fieldType)) {

Review Comment:
   [P1] Skip the complete unknown metadata TLV before continuing. 
`UNKNOWN_METADATA_FIELD_TYPE` is recognized at this line, but the branch 
returns to the outer loop without reading the packed field length or its value. 
For a valid `binlog_row_metadata=FULL` TABLE_MAP containing type 128 followed 
by visibility or VECTOR_DIMENSIONALITY, the next iteration consumes the length 
byte as a new field type and can throw `Unsupported table metadata field type` 
or desynchronize all later metadata, stopping binlog ingestion. Read the length 
and skip exactly that block while updating `remainingBytes`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to