You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2026/02/25 00:52:40 UTC
(iotdb) branch rc/2.0.7 updated (05ef7220388 -> 15b8d2acb88)
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a change to branch rc/2.0.7
in repository https://gitbox.apache.org/repos/asf/iotdb.git
from 05ef7220388 [Bug fix] The partition table is cleaned incorrectly when set only device TTL for tree mode (#17123)
new 3fdfe2e6ca9 Pipe: Added parameter check to handshake of legacy receiver (#16596)
new 920ced735fe Pipe: Banned the illegal names in pipe and pipe plugins (#17145)
new 14f264ccdce Fixed the NPE when validating legacy sink (#17153)
new 71c5d7ef011 Pipe: Changed the separator check semantic for pipes / pipe plugins (#17175)
new b069b88ff97 add-windows-os-utils
new 15b8d2acb88 comp-fix
The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../treemodel/auto/basic/IoTDBPipeDataSinkIT.java | 33 ++++-------
.../treemodel/auto/basic/IoTDBPipeSyntaxIT.java | 65 ++++++++++++++++++++++
.../legacy/IoTDBLegacyPipeReceiverAgent.java | 12 ++++
.../sink/protocol/legacy/IoTDBLegacyPipeSink.java | 11 ++--
.../config/executor/ClusterConfigTaskExecutor.java | 30 ++++++++--
.../org/apache/iotdb/commons/utils/FileUtils.java | 12 ++++
.../apache/iotdb/commons/utils/WindowsOSUtils.java | 64 +++++++++++++++++++++
7 files changed, 196 insertions(+), 31 deletions(-)
create mode 100644 iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/WindowsOSUtils.java
(iotdb) 01/06: Pipe: Added parameter check to handshake of legacy receiver (#16596)
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch rc/2.0.7
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 3fdfe2e6ca99e3b65b3455c5aeb45cdb2302efab
Author: Caideyipi <87...@users.noreply.github.com>
AuthorDate: Thu Oct 16 14:09:51 2025 +0800
Pipe: Added parameter check to handshake of legacy receiver (#16596)
---
.../receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java
index d0217b6e3f8..5bc4a8ce151 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java
@@ -102,6 +102,11 @@ public class IoTDBLegacyPipeReceiverAgent {
final String remoteAddress,
final IPartitionFetcher partitionFetcher,
final ISchemaFetcher schemaFetcher) {
+ if (!validatePipeName(syncIdentityInfo)) {
+ return new TSStatus(TSStatusCode.ILLEGAL_PARAMETER.getStatusCode())
+ .setMessage("Invalid pipeName");
+ }
+
final SyncIdentityInfo identityInfo = new SyncIdentityInfo(syncIdentityInfo, remoteAddress);
LOGGER.info("Invoke handshake method from client ip = {}", identityInfo.getRemoteAddress());
@@ -118,6 +123,10 @@ public class IoTDBLegacyPipeReceiverAgent {
return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS, "");
}
+ private boolean validatePipeName(final TSyncIdentityInfo info) {
+ return info.isSetPipeName() && !info.getPipeName().contains(File.separator);
+ }
+
private void createConnection(final SyncIdentityInfo identityInfo) {
final long connectionId = connectionIdGenerator.incrementAndGet();
currentConnectionId.set(connectionId);
(iotdb) 06/06: comp-fix
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch rc/2.0.7
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 15b8d2acb8865facd2ad7a9325b05e273c1315c1
Author: Caideyipi <87...@users.noreply.github.com>
AuthorDate: Tue Feb 24 14:37:18 2026 +0800
comp-fix
---
.../iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java
index 97b35ff1df7..e5439a038ea 100644
--- a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java
@@ -30,13 +30,14 @@ import org.apache.iotdb.itbase.category.MultiClusterIT2DualTreeAutoBasic;
import org.apache.iotdb.pipe.it.dual.treemodel.auto.AbstractPipeDualTreeModelAutoIT;
import org.apache.iotdb.rpc.TSStatusCode;
-import org.apache.tsfile.external.commons.lang3.SystemUtils;
+import org.apache.commons.lang3.SystemUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
+import java.io.File;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
(iotdb) 02/06: Pipe: Banned the illegal names in pipe and pipe plugins (#17145)
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch rc/2.0.7
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 920ced735fe964b46940c5cb940ae61cb31a56dc
Author: Caideyipi <87...@users.noreply.github.com>
AuthorDate: Wed Feb 4 09:38:44 2026 +0800
Pipe: Banned the illegal names in pipe and pipe plugins (#17145)
* fix
* fix
* fix
* sp-linux
---
.../treemodel/auto/basic/IoTDBPipeSyntaxIT.java | 64 ++++++++++++++++++++++
.../legacy/IoTDBLegacyPipeReceiverAgent.java | 5 +-
.../config/executor/ClusterConfigTaskExecutor.java | 30 ++++++++--
.../org/apache/iotdb/commons/utils/FileUtils.java | 12 ++++
4 files changed, 105 insertions(+), 6 deletions(-)
diff --git a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java
index 37b4ad5c73e..eaa0300d6ef 100644
--- a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java
@@ -30,6 +30,7 @@ import org.apache.iotdb.itbase.category.MultiClusterIT2DualTreeAutoBasic;
import org.apache.iotdb.pipe.it.dual.treemodel.auto.AbstractPipeDualTreeModelAutoIT;
import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.tsfile.external.commons.lang3.SystemUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -39,6 +40,7 @@ import org.junit.runner.RunWith;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -329,6 +331,68 @@ public class IoTDBPipeSyntaxIT extends AbstractPipeDualTreeModelAutoIT {
}
}
+ @Test
+ public void testDirectoryErrors() throws SQLException {
+ try (final Connection connection = senderEnv.getConnection();
+ final Statement statement = connection.createStatement()) {
+ List<String> wrongDirs = Arrays.asList(".", "..", "./hackYou", ".\\hackYouTwice");
+ if (SystemUtils.IS_OS_WINDOWS) {
+ wrongDirs = new ArrayList<>(wrongDirs);
+ wrongDirs.add("BombWindows/:*?");
+ wrongDirs.add("AUX");
+ }
+ for (final String name : wrongDirs) {
+ testDirectoryError(name, statement);
+ }
+ }
+ }
+
+ private void testDirectoryError(final String wrongDir, final Statement statement) {
+ final DataNodeWrapper receiverDataNode = receiverEnv.getDataNodeWrapper(0);
+
+ final String receiverIp = receiverDataNode.getIp();
+ final int receiverPort = receiverDataNode.getPort();
+
+ try {
+ statement.execute(
+ String.format(
+ "create pipe `"
+ + wrongDir
+ + "` with source ()"
+ + " with processor ()"
+ + " with sink ("
+ + "'sink'='invalid-param',"
+ + "'sink.ip'='%s',"
+ + "'sink.port'='%s',"
+ + "'sink.batch.enable'='false')",
+ receiverIp,
+ receiverPort));
+ fail();
+ } catch (final Exception ignore) {
+ // Expected
+ }
+
+ try {
+ statement.execute(
+ String.format(
+ "create pipePlugin `"
+ + wrongDir
+ + "` as 'org.apache.iotdb.db.pipe.example.TestProcessor' USING URI '%s'",
+ new File(
+ System.getProperty("user.dir")
+ + File.separator
+ + "target"
+ + File.separator
+ + "test-classes"
+ + File.separator)
+ .toURI()
+ + "PipePlugin.jar"));
+ fail();
+ } catch (final SQLException e) {
+ Assert.assertTrue(e.getMessage().contains("1600: Failed to create pipe plugin"));
+ }
+ }
+
@Test
public void testBrackets() throws Exception {
final DataNodeWrapper receiverDataNode = receiverEnv.getDataNodeWrapper(0);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java
index 5bc4a8ce151..1aef0ce608d 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java
@@ -24,6 +24,7 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus;
import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.exception.IllegalPathException;
import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.commons.utils.FileUtils;
import org.apache.iotdb.db.auth.AuthorityChecker;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.pipe.sink.payload.legacy.PipeData;
@@ -52,6 +53,7 @@ import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.time.ZoneId;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
@@ -124,7 +126,8 @@ public class IoTDBLegacyPipeReceiverAgent {
}
private boolean validatePipeName(final TSyncIdentityInfo info) {
- return info.isSetPipeName() && !info.getPipeName().contains(File.separator);
+ return info.isSetPipeName()
+ && Objects.isNull(FileUtils.getIllegalError4Directory(info.getPipeName()));
}
private void createConnection(final SyncIdentityInfo identityInfo) {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
index 1d9072f9401..f9e501db6b1 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
@@ -80,6 +80,7 @@ import org.apache.iotdb.commons.trigger.service.TriggerExecutableManager;
import org.apache.iotdb.commons.udf.service.UDFClassLoader;
import org.apache.iotdb.commons.udf.service.UDFExecutableManager;
import org.apache.iotdb.commons.utils.CommonDateTimeUtils;
+import org.apache.iotdb.commons.utils.FileUtils;
import org.apache.iotdb.commons.utils.PathUtils;
import org.apache.iotdb.commons.utils.SerializeUtils;
import org.apache.iotdb.commons.utils.TimePartitionUtils;
@@ -939,6 +940,15 @@ public class ClusterConfigTaskExecutor implements IConfigTaskExecutor {
final String className = createPipePluginStatement.getClassName();
final String uriString = createPipePluginStatement.getUriString();
+ final String pathError = FileUtils.getIllegalError4Directory(pluginName);
+ if (Objects.nonNull(pathError)) {
+ future.setException(
+ new IoTDBException(
+ String.format("Failed to create pipe plugin %s. " + pathError, pluginName),
+ TSStatusCode.CREATE_PIPE_PLUGIN_ERROR.getStatusCode()));
+ return future;
+ }
+
if (uriString == null || uriString.isEmpty()) {
future.setException(
new IoTDBException(
@@ -1979,6 +1989,7 @@ public class ClusterConfigTaskExecutor implements IConfigTaskExecutor {
final SettableFuture<ConfigTaskResult> future = SettableFuture.create();
// Verify that Pipe is disabled if TSFile encryption is enabled
+ final String pipeName = createPipeStatement.getPipeName();
if (!Objects.equals(TSFileDescriptor.getInstance().getConfig().getEncryptType(), "UNENCRYPTED")
&& !Objects.equals(
TSFileDescriptor.getInstance().getConfig().getEncryptType(),
@@ -1987,18 +1998,27 @@ public class ClusterConfigTaskExecutor implements IConfigTaskExecutor {
new IoTDBException(
String.format(
"Failed to create Pipe %s because TSFile is configured with encryption, which prohibits the use of Pipe",
- createPipeStatement.getPipeName()),
+ pipeName),
TSStatusCode.PIPE_ERROR.getStatusCode()));
return future;
}
// Validate pipe name
- if (createPipeStatement.getPipeName().startsWith(PipeStaticMeta.SYSTEM_PIPE_PREFIX)) {
+ if (pipeName.startsWith(PipeStaticMeta.SYSTEM_PIPE_PREFIX)) {
future.setException(
new IoTDBException(
String.format(
"Failed to create pipe %s, pipe name starting with \"%s\" are not allowed to be created.",
- createPipeStatement.getPipeName(), PipeStaticMeta.SYSTEM_PIPE_PREFIX),
+ pipeName, PipeStaticMeta.SYSTEM_PIPE_PREFIX),
+ TSStatusCode.PIPE_ERROR.getStatusCode()));
+ return future;
+ }
+
+ final String pathError = FileUtils.getIllegalError4Directory(pipeName);
+ if (Objects.nonNull(pathError)) {
+ future.setException(
+ new IoTDBException(
+ String.format("Failed to create pipe %s, " + pathError, pipeName),
TSStatusCode.PIPE_ERROR.getStatusCode()));
return future;
}
@@ -2007,7 +2027,7 @@ public class ClusterConfigTaskExecutor implements IConfigTaskExecutor {
try {
PipeDataNodeAgent.plugin()
.validate(
- createPipeStatement.getPipeName(),
+ pipeName,
createPipeStatement.getExtractorAttributes(),
createPipeStatement.getProcessorAttributes(),
createPipeStatement.getConnectorAttributes());
@@ -2021,7 +2041,7 @@ public class ClusterConfigTaskExecutor implements IConfigTaskExecutor {
CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
final TCreatePipeReq req =
new TCreatePipeReq()
- .setPipeName(createPipeStatement.getPipeName())
+ .setPipeName(pipeName)
.setIfNotExistsCondition(createPipeStatement.hasIfNotExistsCondition())
.setExtractorAttributes(createPipeStatement.getExtractorAttributes())
.setProcessorAttributes(createPipeStatement.getProcessorAttributes())
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java
index f1c0410dd56..044375fb2bd 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java
@@ -57,6 +57,8 @@ public class FileUtils {
"Renamed file {} to {} because it already exists in the target directory: {}";
private static final String COPY_FILE_MESSAGE =
"Copy file {} to {} because it already exists in the target directory: {}";
+ private static final String ILLEGAL_PATH_MESSAGE =
+ "The path cannot be '.', '..', './' or '.\\'. ";
private FileUtils() {}
@@ -567,4 +569,14 @@ public class FileUtils {
return targetFileName;
}
}
+
+ public static String getIllegalError4Directory(final String path) {
+ if (path.equals(".") || path.equals("..") || path.contains("./") || path.contains(".\\")) {
+ return ILLEGAL_PATH_MESSAGE;
+ }
+ if (!WindowsOSUtils.isLegalPathSegment4Windows(path)) {
+ return WindowsOSUtils.OS_SEGMENT_ERROR;
+ }
+ return null;
+ }
}
(iotdb) 05/06: add-windows-os-utils
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch rc/2.0.7
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit b069b88ff97110924b3b615135403c50cee00420
Author: Caideyipi <87...@users.noreply.github.com>
AuthorDate: Tue Feb 24 14:26:39 2026 +0800
add-windows-os-utils
---
.../apache/iotdb/commons/utils/WindowsOSUtils.java | 64 ++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/WindowsOSUtils.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/WindowsOSUtils.java
new file mode 100644
index 00000000000..3019c47cf0e
--- /dev/null
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/WindowsOSUtils.java
@@ -0,0 +1,64 @@
+/*
+ * 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.commons.utils;
+
+import org.apache.commons.lang3.SystemUtils;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+public class WindowsOSUtils {
+ private static final String ILLEGAL_WINDOWS_CHARS = "\\/:*?\"<>|";
+ private static final Set<String> ILLEGAL_WINDOWS_NAMES =
+ new HashSet<>(Arrays.asList("CON", "PRN", "AUX", "NUL", "COM1-COM9, LPT1-LPT9"));
+
+ static {
+ for (int i = 0; i < 10; ++i) {
+ ILLEGAL_WINDOWS_NAMES.add("COM" + i);
+ ILLEGAL_WINDOWS_NAMES.add("LPT" + i);
+ }
+ }
+
+ public static final String OS_SEGMENT_ERROR =
+ String.format(
+ "In Windows System, the path shall not contains %s, equals one of %s, or ends with '.' or ' '.",
+ ILLEGAL_WINDOWS_CHARS, ILLEGAL_WINDOWS_NAMES);
+
+ public static boolean isLegalPathSegment4Windows(final String pathSegment) {
+ if (!SystemUtils.IS_OS_WINDOWS) {
+ return true;
+ }
+ for (final char illegalChar : ILLEGAL_WINDOWS_CHARS.toCharArray()) {
+ if (pathSegment.indexOf(illegalChar) != -1) {
+ return false;
+ }
+ }
+ if (pathSegment.endsWith(".") || pathSegment.endsWith(" ")) {
+ return false;
+ }
+ for (final String illegalName : ILLEGAL_WINDOWS_NAMES) {
+ if (pathSegment.equalsIgnoreCase(illegalName)) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
(iotdb) 04/06: Pipe: Changed the separator check semantic for pipes / pipe plugins (#17175)
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch rc/2.0.7
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 71c5d7ef01110984f898e0315d112f7a2830502e
Author: Caideyipi <87...@users.noreply.github.com>
AuthorDate: Fri Feb 6 14:48:29 2026 +0800
Pipe: Changed the separator check semantic for pipes / pipe plugins (#17175)
* fix
* sep
---
.../iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java | 2 +-
.../src/main/java/org/apache/iotdb/commons/utils/FileUtils.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java
index eaa0300d6ef..97b35ff1df7 100644
--- a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java
@@ -335,7 +335,7 @@ public class IoTDBPipeSyntaxIT extends AbstractPipeDualTreeModelAutoIT {
public void testDirectoryErrors() throws SQLException {
try (final Connection connection = senderEnv.getConnection();
final Statement statement = connection.createStatement()) {
- List<String> wrongDirs = Arrays.asList(".", "..", "./hackYou", ".\\hackYouTwice");
+ List<String> wrongDirs = Arrays.asList(".", "..", "/hackYou", "..\\hackYouTwice");
if (SystemUtils.IS_OS_WINDOWS) {
wrongDirs = new ArrayList<>(wrongDirs);
wrongDirs.add("BombWindows/:*?");
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java
index 044375fb2bd..a79d48662f8 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java
@@ -571,7 +571,7 @@ public class FileUtils {
}
public static String getIllegalError4Directory(final String path) {
- if (path.equals(".") || path.equals("..") || path.contains("./") || path.contains(".\\")) {
+ if (path.equals(".") || path.equals("..") || path.contains("/") || path.contains("\\")) {
return ILLEGAL_PATH_MESSAGE;
}
if (!WindowsOSUtils.isLegalPathSegment4Windows(path)) {
(iotdb) 03/06: Fixed the NPE when validating legacy sink (#17153)
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch rc/2.0.7
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 14f264ccdceebf88e2474b0a7b044feb862fbcce
Author: Caideyipi <87...@users.noreply.github.com>
AuthorDate: Wed Feb 4 14:14:58 2026 +0800
Fixed the NPE when validating legacy sink (#17153)
* npe-fix
* unb
---
.../treemodel/auto/basic/IoTDBPipeDataSinkIT.java | 33 ++++++++--------------
.../sink/protocol/legacy/IoTDBLegacyPipeSink.java | 11 +++++---
2 files changed, 18 insertions(+), 26 deletions(-)
diff --git a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeDataSinkIT.java b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeDataSinkIT.java
index 06d21c85d67..68323105281 100644
--- a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeDataSinkIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeDataSinkIT.java
@@ -23,6 +23,7 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus;
import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
import org.apache.iotdb.confignode.rpc.thrift.TCreatePipeReq;
import org.apache.iotdb.db.it.utils.TestUtils;
+import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.MultiClusterIT2DualTreeAutoBasic;
@@ -35,6 +36,8 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
+import java.sql.Connection;
+import java.sql.Statement;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -218,30 +221,16 @@ public class IoTDBPipeDataSinkIT extends AbstractPipeDualTreeModelAutoIT {
final String receiverIp = receiverDataNode.getIp();
final int receiverPort = receiverDataNode.getPort();
+ try (final Connection connection = EnvFactory.getEnv().getConnection();
+ final Statement statement = connection.createStatement()) {
+ statement.execute(
+ String.format(
+ "create pipe testPipe ('sink'='iotdb-legacy-pipe-sink', 'ip'='%s', 'port'='%s', 'version'='1.3')",
+ receiverIp, receiverPort));
+ }
+
try (final SyncConfigNodeIServiceClient client =
(SyncConfigNodeIServiceClient) senderEnv.getLeaderConfigNodeConnection()) {
- final Map<String, String> extractorAttributes = new HashMap<>();
- final Map<String, String> processorAttributes = new HashMap<>();
- final Map<String, String> connectorAttributes = new HashMap<>();
-
- extractorAttributes.put("source.realtime.mode", "log");
-
- connectorAttributes.put("sink", "iotdb-legacy-pipe-sink");
- connectorAttributes.put("sink.batch.enable", "false");
- connectorAttributes.put("sink.ip", receiverIp);
- connectorAttributes.put("sink.port", Integer.toString(receiverPort));
-
- // This version does not matter since it's no longer checked by the legacy receiver
- connectorAttributes.put("sink.version", "1.3");
-
- final TSStatus status =
- client.createPipe(
- new TCreatePipeReq("testPipe", connectorAttributes)
- .setExtractorAttributes(extractorAttributes)
- .setProcessorAttributes(processorAttributes));
-
- Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
Assert.assertEquals(
TSStatusCode.SUCCESS_STATUS.getStatusCode(), client.startPipe("testPipe").getCode());
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/legacy/IoTDBLegacyPipeSink.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/legacy/IoTDBLegacyPipeSink.java
index b3792bc9320..5030738cc82 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/legacy/IoTDBLegacyPipeSink.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/legacy/IoTDBLegacyPipeSink.java
@@ -37,6 +37,7 @@ import org.apache.iotdb.db.pipe.event.common.terminate.PipeTerminateEvent;
import org.apache.iotdb.db.pipe.event.common.tsfile.PipeTsFileInsertionEvent;
import org.apache.iotdb.db.pipe.sink.payload.legacy.TsFilePipeData;
import org.apache.iotdb.db.storageengine.StorageEngine;
+import org.apache.iotdb.db.storageengine.dataregion.DataRegion;
import org.apache.iotdb.pipe.api.PipeConnector;
import org.apache.iotdb.pipe.api.annotation.TreeModel;
import org.apache.iotdb.pipe.api.customizer.configuration.PipeConnectorRuntimeConfiguration;
@@ -109,7 +110,7 @@ public class IoTDBLegacyPipeSink implements PipeConnector {
private String syncConnectorVersion;
private String pipeName;
- private String databaseName;
+ private String databaseName = "";
private IoTDBSyncClient client;
@@ -202,10 +203,12 @@ public class IoTDBLegacyPipeSink implements PipeConnector {
trustStore = parameters.getString(SINK_IOTDB_SSL_TRUST_STORE_PATH_KEY);
trustStorePwd = parameters.getString(SINK_IOTDB_SSL_TRUST_STORE_PWD_KEY);
- databaseName =
+ final DataRegion dataRegion =
StorageEngine.getInstance()
- .getDataRegion(new DataRegionId(configuration.getRuntimeEnvironment().getRegionId()))
- .getDatabaseName();
+ .getDataRegion(new DataRegionId(configuration.getRuntimeEnvironment().getRegionId()));
+ if (Objects.nonNull(dataRegion)) {
+ databaseName = dataRegion.getDatabaseName();
+ }
}
@Override