Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cdee83e
[DSIP-23][TaskPlugin] DmsTask resource leak repair
Nov 25, 2025
3394bb2
[Improvement-17723][TaskPlugin] DmsTask resource leak repair
Nov 25, 2025
ed00657
Merge branch 'DSIP-23-DmsTask' of github.com:niumy0701/dolphinschedul…
Nov 25, 2025
451bf9f
[Improvement-17723][TaskPlugin] DmsTask resource leak repair
Nov 26, 2025
80b1ee7
Merge branch 'dev' of github.com:niumy0701/dolphinscheduler into DSIP…
Nov 26, 2025
6de20c9
Merge branch 'dev' into DSIP-23-DmsTask
niumy0701 Nov 27, 2025
cd182de
Merge branch 'dev' into DSIP-23-DmsTask
niumy0701 Nov 27, 2025
a08701a
Merge branch 'dev' into DSIP-23-DmsTask
niumy0701 Nov 28, 2025
2929213
Merge branch 'dev' into DSIP-23-DmsTask
niumy0701 Nov 28, 2025
03c9b3f
Merge branch 'dev' into DSIP-23-DmsTask
niumy0701 Nov 28, 2025
8c3d2d7
Merge branch 'dev' of github.com:niumy0701/dolphinscheduler into DSIP…
Nov 29, 2025
7be50e7
Merge branch 'DSIP-23-DmsTask' of github.com:niumy0701/dolphinschedul…
Nov 29, 2025
56115d3
[Improvement-17723][TaskPlugin] DmsTask resource leak repair
Nov 29, 2025
f61aadc
Merge branch 'dev' into DSIP-23-DmsTask
niumy0701 Dec 1, 2025
4137abb
[Improvement-17723][TaskPlugin] DmsTask resource leak repair
Dec 2, 2025
f905728
[Improvement-17723][TaskPlugin] DmsTask resource leak repair
Dec 2, 2025
f259d12
Merge branch 'dev' into DSIP-23-DmsTask
niumy0701 Dec 3, 2025
1718eb2
Merge branch 'dev' into DSIP-23-DmsTask
niumy0701 Dec 4, 2025
5eac924
Merge branch 'dev' into DSIP-23-DmsTask
niumy0701 Dec 4, 2025
0b04ffe
Merge branch 'dev' into DSIP-23-DmsTask
niumy0701 Dec 5, 2025
ff93f77
[Improvement-17723][TaskPlugin] DmsTask resource leak repair
Dec 8, 2025
e1af574
[Improvement-17723][TaskPlugin] DmsTask resource leak repair
Dec 8, 2025
e8175f5
Merge branch 'dev' into DSIP-23-DmsTask
niumy0701 Dec 8, 2025
9c8b7f0
Revert "[Improvement-17723][TaskPlugin] DmsTask resource leak repair"
Dec 8, 2025
7809aa3
[Improvement-17723][TaskPlugin] DmsTask resource leak repair
Dec 8, 2025
5a12213
Revert "[Improvement-17723][TaskPlugin] DmsTask resource leak repair"
Dec 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public Boolean checkFinishedReplicationTask() {
log.info("checkFinishedReplicationTask ......");
awaitReplicationTaskStatus(STATUS.STOPPED);
String stopReason = describeReplicationTasks().getStopReason();
// shutdown client
client.shutdown();
return stopReason.endsWith(STATUS.FINISH_END_TOKEN);
}

Expand All @@ -145,6 +147,8 @@ public void stopReplicationTask() {
.withReplicationTaskArn(replicationTaskArn);
client.stopReplicationTask(request);
awaitReplicationTaskStatus(STATUS.STOPPED);
// shutdown client
client.shutdown();
}

public Boolean deleteReplicationTask() {
Expand All @@ -158,6 +162,8 @@ public Boolean deleteReplicationTask() {
} catch (ResourceNotFoundException e) {
isDeleteSuccessfully = true;
}
// shutdown client
client.shutdown();
return isDeleteSuccessfully;
}

Expand Down Expand Up @@ -268,8 +274,8 @@ public String replaceFileParameters(String parameter) throws IOException {
}
if (parameter.startsWith("file://")) {
String filePath = parameter.substring(7);
try {
return IOUtils.toString(new FileInputStream(filePath), StandardCharsets.UTF_8);
try (FileInputStream fis = new FileInputStream(filePath)) {
return IOUtils.toString(fis, StandardCharsets.UTF_8);
} catch (IOException e) {
throw new IOException("Error reading file: " + filePath, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Arrays;

Expand Down Expand Up @@ -238,4 +243,63 @@
}
});
}

@Test
public void testReplaceFileParametersWithNull() throws IOException {

Check warning on line 248 in dolphinscheduler-task-plugin/dolphinscheduler-task-dms/src/test/java/org/apache/dolphinscheduler/plugin/task/dms/DmsHookTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AZrKKltSezW41uxIrh9R&open=AZrKKltSezW41uxIrh9R&pullRequest=17718

Check warning on line 248 in dolphinscheduler-task-plugin/dolphinscheduler-task-dms/src/test/java/org/apache/dolphinscheduler/plugin/task/dms/DmsHookTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the declaration of thrown exception 'java.io.IOException', as it cannot be thrown from method's body.

See more on https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AZrKKltSezW41uxIrh9V&open=AZrKKltSezW41uxIrh9V&pullRequest=17718
Assertions.assertTimeout(Duration.ofMillis(60000), () -> {
try (MockedStatic<DmsHook> mockHook = Mockito.mockStatic(DmsHook.class)) {
mockHook.when(DmsHook::createClient).thenReturn(client);
DmsHook dmsHook = spy(new DmsHook());
String parameter = null;
String result = dmsHook.replaceFileParameters(parameter);
Assertions.assertNull(result);
}
});
}

@Test
public void testReplaceFileParametersWithNormalString() throws IOException {

Check warning on line 261 in dolphinscheduler-task-plugin/dolphinscheduler-task-dms/src/test/java/org/apache/dolphinscheduler/plugin/task/dms/DmsHookTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AZrKKltSezW41uxIrh9S&open=AZrKKltSezW41uxIrh9S&pullRequest=17718

Check warning on line 261 in dolphinscheduler-task-plugin/dolphinscheduler-task-dms/src/test/java/org/apache/dolphinscheduler/plugin/task/dms/DmsHookTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the declaration of thrown exception 'java.io.IOException', as it cannot be thrown from method's body.

See more on https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AZrKKltSezW41uxIrh9W&open=AZrKKltSezW41uxIrh9W&pullRequest=17718
Assertions.assertTimeout(Duration.ofMillis(60000), () -> {
try (MockedStatic<DmsHook> mockHook = Mockito.mockStatic(DmsHook.class)) {
mockHook.when(DmsHook::createClient).thenReturn(client);
DmsHook dmsHook = spy(new DmsHook());
String parameter = "normal string";
String result = dmsHook.replaceFileParameters(parameter);
Assertions.assertEquals(parameter, result);
}
});
}

@Test
public void testReplaceFileParametersWithExistingFile() throws IOException {

Check warning on line 274 in dolphinscheduler-task-plugin/dolphinscheduler-task-dms/src/test/java/org/apache/dolphinscheduler/plugin/task/dms/DmsHookTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AZrKKltSezW41uxIrh9T&open=AZrKKltSezW41uxIrh9T&pullRequest=17718

Check warning on line 274 in dolphinscheduler-task-plugin/dolphinscheduler-task-dms/src/test/java/org/apache/dolphinscheduler/plugin/task/dms/DmsHookTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the declaration of thrown exception 'java.io.IOException', as it cannot be thrown from method's body.

See more on https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AZrKKltSezW41uxIrh9X&open=AZrKKltSezW41uxIrh9X&pullRequest=17718
Assertions.assertTimeout(Duration.ofMillis(60000), () -> {
File tempFile = new File("tempFile.txt");
try (MockedStatic<DmsHook> mockHook = Mockito.mockStatic(DmsHook.class)) {
mockHook.when(DmsHook::createClient).thenReturn(client);
DmsHook dmsHook = spy(new DmsHook());
String fileContent = "content of the file";
FileUtils.writeStringToFile(tempFile, fileContent, StandardCharsets.UTF_8);
String parameter = "file://" + tempFile.getAbsolutePath();
String result = dmsHook.replaceFileParameters(parameter);
Assertions.assertEquals(fileContent, result);
} finally {
tempFile.delete();
}
});
}

@Test
public void testReplaceFileParametersWithNonexistentFile() {

Check warning on line 292 in dolphinscheduler-task-plugin/dolphinscheduler-task-dms/src/test/java/org/apache/dolphinscheduler/plugin/task/dms/DmsHookTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AZrKKltSezW41uxIrh9U&open=AZrKKltSezW41uxIrh9U&pullRequest=17718
Assertions.assertTimeout(Duration.ofMillis(60000), () -> {
try (MockedStatic<DmsHook> mockHook = Mockito.mockStatic(DmsHook.class)) {
mockHook.when(DmsHook::createClient).thenReturn(client);
DmsHook dmsHook = spy(new DmsHook());
String parameter = "file://nonexistentfile.txt";
Assertions.assertThrows(IOException.class, () -> {
dmsHook.replaceFileParameters(parameter);
});
}
});
}

}
Loading