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

StringIndexOutOfBoundsException thrown while handling UTF-8 characters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • 1.6.0.CR1
    • 1.5.2.Final, 1.6.0.Beta2
    • vitess-connector
    • None

      When resolveColumn method invoked with row data including korean or other utf-8 characters, it returns StringIndexOutOfBoundsException like below.

      2021-06-09 17:07:11.761 [debezium-vitessconnector-vitess-change-event-source-coordinator] ERROR i.d.c.v.VitessStreamingChangeEventSource:execute:74 - Error during streaming
      io.grpc.StatusRuntimeException: CANCELLED: Failed to read message.
              at io.grpc.Status.asRuntimeException(Status.java:533)
              at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:478)
              at io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:463)
              at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:427)
              at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:460)
              at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:616)
              at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:69)
              at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:802)
              at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:781)
              at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
              at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
              at java.lang.Thread.run(Thread.java:748)
      Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 14
              at java.lang.String.substring(String.java:1963)
              at io.debezium.connector.vitess.connection.VStreamOutputMessageDecoder.resolveColumns(VStreamOutputMessageDecoder.java:299)
              at io.debezium.connector.vitess.connection.VStreamOutputMessageDecoder.decodeUpdate(VStreamOutputMessageDecoder.java:219)
              at io.debezium.connector.vitess.connection.VStreamOutputMessageDecoder.decodeRows(VStreamOutputMessageDecoder.java:148)
              at io.debezium.connector.vitess.connection.VStreamOutputMessageDecoder.processMessage(VStreamOutputMessageDecoder.java:62)
              at io.debezium.connector.vitess.connection.VitessReplicationConnection$1.onNext(VitessReplicationConnection.java:101)
              at io.debezium.connector.vitess.connection.VitessReplicationConnection$1.onNext(VitessReplicationConnection.java:79)
              at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onMessage(ClientCalls.java:465)
              at io.grpc.internal.DelayedClientCall$DelayedListener.onMessage(DelayedClientCall.java:447)
              at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInternal(ClientCallImpl.java:715)
              at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:700)
              ... 5 common frames omittedio.debezium.connector.vitess.connection.VStreamOutputMessageDecoder.resolveColumns(VStreamOutputMessageDecoder.java:299)
      

      It can be reproduced by modifying the test case VitessReplicationConnectionIT as below.

      public class VitessReplicationConnectionIT {
          private static final Logger LOGGER = LoggerFactory.getLogger(VitessReplicationConnectionIT.class);
      
          private static final String INSERT_STMT = "INSERT INTO t1 (ko, ja, emoji, en)"
                  + " VALUES ('상품 명1', 'リンゴ', '\uD83D\uDE00', 'prod_name');";
          private static final List<String> SETUP_TABLES_STMT = Arrays.asList(
                  "DROP TABLE IF EXISTS t1;",
                  "CREATE TABLE t1 (id BIGINT NOT NULL AUTO_INCREMENT, "
                          + "ko VARCHAR(20), ja VARCHAR(20), emoji VARCHAR(20), en VARCHAR(20), PRIMARY KEY (id));");
      

              Unassigned Unassigned
              piee9818@hotmail.com Bob Oh (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: