Skip to content

Commit 70a5429

Browse files
committed
Remove obsolete callNonInterruptible() method
1 parent 4ae6231 commit 70a5429

File tree

2 files changed

+18
-29
lines changed

2 files changed

+18
-29
lines changed
Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package org.embulk.output.sftp.utils;
22

33
import com.google.common.annotations.VisibleForTesting;
4+
import com.google.common.base.Throwables;
45

56
import java.io.Closeable;
7+
import java.util.concurrent.ExecutionException;
68
import java.util.concurrent.TimeUnit;
9+
import java.util.concurrent.TimeoutException;
710

811
public class TimeoutCloser implements Closeable
912
{
1013
@VisibleForTesting
11-
int timeout = 120;
14+
int timeout = 300; // 5 minutes
1215
private Closeable wrapped;
1316

1417
public TimeoutCloser(Closeable wrapped)
@@ -19,16 +22,21 @@ public TimeoutCloser(Closeable wrapped)
1922
@Override
2023
public void close()
2124
{
22-
new TimedCallable<Void>()
23-
{
24-
@Override
25-
public Void call() throws Exception
25+
try {
26+
new TimedCallable<Void>()
2627
{
27-
if (wrapped != null) {
28-
wrapped.close();
28+
@Override
29+
public Void call() throws Exception
30+
{
31+
if (wrapped != null) {
32+
wrapped.close();
33+
}
34+
return null;
2935
}
30-
return null;
31-
}
32-
}.callNonInterruptible(timeout, TimeUnit.SECONDS);
36+
}.call(timeout, TimeUnit.SECONDS);
37+
}
38+
catch (InterruptedException | ExecutionException | TimeoutException e) {
39+
throw Throwables.propagate(e);
40+
}
3341
}
3442
}

src/test/java/org/embulk/output/sftp/utils/TestTimedCallable.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.util.concurrent.TimeUnit;
88
import java.util.concurrent.TimeoutException;
99

10-
import static junit.framework.TestCase.fail;
1110
import static org.hamcrest.CoreMatchers.instanceOf;
1211
import static org.hamcrest.MatcherAssert.assertThat;
1312

@@ -16,24 +15,6 @@ public class TestTimedCallable
1615
@Rule
1716
public EmbulkTestRuntime runtime = new EmbulkTestRuntime();
1817

19-
@Test
20-
public void testCallNonInterruptible()
21-
{
22-
try {
23-
new TimedCallable<Void>()
24-
{
25-
@Override
26-
public Void call() throws Exception
27-
{
28-
throw new Exception("Fake error");
29-
}
30-
}.callNonInterruptible(1, TimeUnit.SECONDS);
31-
}
32-
catch (Exception e) {
33-
fail("Should not throw exception");
34-
}
35-
}
36-
3718
@Test
3819
public void testCallTimeout()
3920
{

0 commit comments

Comments
 (0)