This is an automated email from the ASF dual-hosted git repository.
jackietien 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 8f78e26799 Fix IoTDBConfigNodeSnapshotIT.testCreateUDF
8f78e26799 is described below
commit 8f78e26799987bc52c6b24a4520e7f9678891061
Author: Liao Lanyu <[email protected]>
AuthorDate: Mon Oct 31 15:07:02 2022 +0800
Fix IoTDBConfigNodeSnapshotIT.testCreateUDF
---
.../iotdb/commons/executable/ExecutableManager.java | 12 +++++++-----
.../commons/udf/service/UDFManagementService.java | 19 ++++++++++++++-----
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git
a/node-commons/src/main/java/org/apache/iotdb/commons/executable/ExecutableManager.java
b/node-commons/src/main/java/org/apache/iotdb/commons/executable/ExecutableManager.java
index 058a370ce7..0f19508623 100644
---
a/node-commons/src/main/java/org/apache/iotdb/commons/executable/ExecutableManager.java
+++
b/node-commons/src/main/java/org/apache/iotdb/commons/executable/ExecutableManager.java
@@ -224,11 +224,13 @@ public class ExecutableManager {
}
protected void saveToDir(ByteBuffer byteBuffer, String destination) throws
IOException {
- Path path = Paths.get(destination);
- Files.deleteIfExists(path);
- Files.createFile(path);
- try (FileOutputStream outputStream = new FileOutputStream(destination)) {
- outputStream.getChannel().write(byteBuffer);
+ try {
+ Path path = Paths.get(destination);
+ Files.deleteIfExists(path);
+ Files.createFile(path);
+ try (FileOutputStream outputStream = new FileOutputStream(destination)) {
+ outputStream.getChannel().write(byteBuffer);
+ }
} catch (IOException e) {
LOGGER.warn(
"Error occurred during writing bytebuffer to {} , the cause is {}",
destination, e);
diff --git
a/node-commons/src/main/java/org/apache/iotdb/commons/udf/service/UDFManagementService.java
b/node-commons/src/main/java/org/apache/iotdb/commons/udf/service/UDFManagementService.java
index 3e03f2d604..f98be3ecf1 100644
---
a/node-commons/src/main/java/org/apache/iotdb/commons/udf/service/UDFManagementService.java
+++
b/node-commons/src/main/java/org/apache/iotdb/commons/udf/service/UDFManagementService.java
@@ -197,9 +197,8 @@ public class UDFManagementService {
public void doRegister(UDFInformation udfInformation) throws
UDFManagementException {
String functionName = udfInformation.getFunctionName();
String className = udfInformation.getClassName();
- try {
- UDFClassLoader currentActiveClassLoader =
- UDFClassLoaderManager.getInstance().updateAndGetActiveClassLoader();
+ try (UDFClassLoader currentActiveClassLoader =
+ UDFClassLoaderManager.getInstance().updateAndGetActiveClassLoader()) {
updateAllRegisteredClasses(currentActiveClassLoader);
Class<?> functionClass = Class.forName(className, true,
currentActiveClassLoader);
@@ -268,8 +267,18 @@ public class UDFManagementService {
}
if (!information.isBuiltin()) {
- Thread.currentThread()
-
.setContextClassLoader(UDFClassLoaderManager.getInstance().getActiveClassLoader());
+ try {
+ Thread.currentThread()
+ .setContextClassLoader(
+
UDFClassLoaderManager.getInstance().updateAndGetActiveClassLoader());
+ } catch (IOException e) {
+ String errorMessage =
+ String.format(
+ "Failed to set UDFClassLoader for UDF %s(%s) , because %s",
+ functionName, information.getClassName(), e);
+ LOGGER.warn(errorMessage, e);
+ throw new RuntimeException(e);
+ }
}
try {