Skip to content

Commit b447f02

Browse files
committed
Merge pull request #9 from sakama/fix-error-handling
Fix error handling
2 parents 74a62b5 + 9141fc2 commit b447f02

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main/java/org/embulk/output/sftp/SftpFileOutput.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.apache.commons.vfs2.impl.StandardFileSystemManager;
99
import org.apache.commons.vfs2.provider.sftp.IdentityInfo;
1010
import org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder;
11+
import org.embulk.config.ConfigException;
1112
import org.embulk.config.TaskReport;
1213
import org.embulk.spi.Buffer;
1314
import org.embulk.spi.Exec;
@@ -58,7 +59,7 @@ private StandardFileSystemManager initializeStandardFileSystemManager()
5859
}
5960
catch (FileSystemException e) {
6061
logger.error(e.getMessage());
61-
throw new RuntimeException(e);
62+
throw new ConfigException(e);
6263
}
6364

6465
return manager;
@@ -92,7 +93,7 @@ private FileSystemOptions initializeFsOptions(PluginTask task)
9293
}
9394
catch (FileSystemException e) {
9495
logger.error(e.getMessage());
95-
throw new RuntimeException(e);
96+
throw new ConfigException(e);
9697
}
9798

9899
return fsOptions;
@@ -142,7 +143,9 @@ public void add(Buffer buffer)
142143
logger.error(e.getMessage());
143144
Throwables.propagate(e);
144145
}
145-
buffer.release();
146+
finally {
147+
buffer.release();
148+
}
146149
}
147150

148151
@Override
@@ -166,7 +169,7 @@ public void abort()
166169
@Override
167170
public TaskReport commit()
168171
{
169-
return null;
172+
return Exec.newTaskReport();
170173
}
171174

172175

@@ -199,7 +202,7 @@ private URI getSftpFileUri(String remoteFilePath)
199202
}
200203
catch (URISyntaxException e) {
201204
logger.error(e.getMessage());
202-
throw new RuntimeException(e);
205+
throw new ConfigException(e);
203206
}
204207
}
205208

0 commit comments

Comments
 (0)