This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new b4419bb1720 fix compaction path util npe (#15653)
b4419bb1720 is described below
commit b4419bb17203fa9d5a27981601af08d94431708e
Author: shuwenwei <[email protected]>
AuthorDate: Fri Jun 6 09:56:07 2025 +0800
fix compaction path util npe (#15653)
---
.../execute/utils/CompactionPathUtils.java | 3 +-
.../compaction/utils/CompactionUtilsTest.java | 57 ++++++++++++++++++++++
2 files changed, 59 insertions(+), 1 deletion(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/CompactionPathUtils.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/CompactionPathUtils.java
index c2ddabfc4d6..8b7a29fbf3b 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/CompactionPathUtils.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/CompactionPathUtils.java
@@ -38,7 +38,8 @@ public class CompactionPathUtils {
String[] nodes = new String[device.segmentNum() +
tableNameSegments.length];
System.arraycopy(tableNameSegments, 0, nodes, 0,
tableNameSegments.length);
for (int i = 0; i < device.segmentNum() - 1; i++) {
- nodes[i + tableNameSegments.length] = device.segment(i + 1).toString();
+ nodes[i + tableNameSegments.length] =
+ device.segment(i + 1) == null ? null : device.segment(i +
1).toString();
}
nodes[device.segmentNum() + tableNameSegments.length - 1] = measurement;
MeasurementPath path = new MeasurementPath(nodes);
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/utils/CompactionUtilsTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/utils/CompactionUtilsTest.java
new file mode 100644
index 00000000000..1fa1c733944
--- /dev/null
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/utils/CompactionUtilsTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.storageengine.dataregion.compaction.utils;
+
+import org.apache.iotdb.commons.exception.MetadataException;
+import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.db.exception.StorageEngineException;
+import
org.apache.iotdb.db.storageengine.dataregion.compaction.AbstractCompactionTest;
+import
org.apache.iotdb.db.storageengine.dataregion.compaction.execute.utils.CompactionPathUtils;
+
+import org.apache.tsfile.exception.write.WriteProcessException;
+import org.apache.tsfile.file.metadata.IDeviceID;
+import org.apache.tsfile.file.metadata.StringArrayDeviceID;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+
+public class CompactionUtilsTest extends AbstractCompactionTest {
+ @Override
+ public void setUp()
+ throws IOException, WriteProcessException, MetadataException,
InterruptedException {
+ super.setUp();
+ }
+
+ @Override
+ public void tearDown() throws IOException, StorageEngineException {
+ super.tearDown();
+ }
+
+ @Test
+ public void testCompactionPathUtils() {
+ try {
+ IDeviceID deviceID = new StringArrayDeviceID(new String[] {"db.table1",
null, "tag1"});
+ PartialPath path = CompactionPathUtils.getPath(deviceID, "s1");
+ } catch (Exception e) {
+ Assert.fail();
+ }
+ }
+}