This is an automated email from the ASF dual-hosted git repository.

HTHou pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/dev/1.3 by this push:
     new 276db4d6b5d Fix MQTT measurement validation (#18217)
276db4d6b5d is described below

commit 276db4d6b5dc3a0d7bcafff081cfe15068b6c084
Author: Jiang Tian <[email protected]>
AuthorDate: Wed Jul 15 19:01:33 2026 +0800

    Fix MQTT measurement validation (#18217)
---
 .../iotdb/db/protocol/mqtt/MPPPublishHandler.java  |  8 ++++-
 .../db/protocol/mqtt/MPPPublishHandlerTest.java    | 42 ++++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/mqtt/MPPPublishHandler.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/mqtt/MPPPublishHandler.java
index c24b816420f..6aa27371695 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/mqtt/MPPPublishHandler.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/mqtt/MPPPublishHandler.java
@@ -20,6 +20,8 @@ package org.apache.iotdb.db.protocol.mqtt;
 
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.commons.conf.IoTDBConstant.ClientVersion;
+import org.apache.iotdb.commons.exception.MetadataException;
+import org.apache.iotdb.commons.utils.PathUtils;
 import org.apache.iotdb.db.auth.AuthorityChecker;
 import org.apache.iotdb.db.conf.IoTDBConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
@@ -144,7 +146,7 @@ public class MPPPublishHandler extends 
AbstractInterceptHandler {
               
DataNodeDevicePathCache.getInstance().getPartialPath(event.getDevice()));
           
TimestampPrecisionUtils.checkTimestampPrecision(event.getTimestamp());
           statement.setTime(event.getTimestamp());
-          statement.setMeasurements(event.getMeasurements().toArray(new 
String[0]));
+          
statement.setMeasurements(checkMeasurements(event.getMeasurements()));
           if (event.getDataTypes() == null) {
             statement.setDataTypes(new 
TSDataType[event.getMeasurements().size()]);
             statement.setValues(event.getValues().toArray(new Object[0]));
@@ -195,6 +197,10 @@ public class MPPPublishHandler extends 
AbstractInterceptHandler {
     }
   }
 
+  static String[] checkMeasurements(List<String> measurements) throws 
MetadataException {
+    return 
PathUtils.checkIsLegalSingleMeasurementsAndUpdate(measurements).toArray(new 
String[0]);
+  }
+
   @Override
   public void onSessionLoopError(Throwable throwable) {
     // TODO: Implement something sensible here ...
diff --git 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/protocol/mqtt/MPPPublishHandlerTest.java
 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/protocol/mqtt/MPPPublishHandlerTest.java
new file mode 100644
index 00000000000..403cdaca9e0
--- /dev/null
+++ 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/protocol/mqtt/MPPPublishHandlerTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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 org.apache.iotdb.db.protocol.mqtt;
+
+import org.apache.iotdb.commons.exception.IllegalPathException;
+import org.apache.iotdb.commons.exception.MetadataException;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.junit.Assert.assertArrayEquals;
+
+public class MPPPublishHandlerTest {
+
+  @Test
+  public void testLegalMeasurement() throws MetadataException {
+    assertArrayEquals(
+        new String[] {"s1", "s2"}, 
MPPPublishHandler.checkMeasurements(Arrays.asList("s1", "s2")));
+  }
+
+  @Test(expected = IllegalPathException.class)
+  public void testIllegalMeasurement() throws MetadataException {
+    MPPPublishHandler.checkMeasurements(Collections.singletonList("a.b"));
+  }
+}

Reply via email to