You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/01/18 08:42:37 UTC
[08/10] camel git commit: CAMEL-10713 SCP not handling errors for
failed transfers correctly
CAMEL-10713 SCP not handling errors for failed transfers correctly
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/603c3f37
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/603c3f37
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/603c3f37
Branch: refs/heads/camel-2.17.x
Commit: 603c3f3789bce23d03180535908184f4a18b6070
Parents: 7777d3ad
Author: Patrick McGloin <pa...@Patricks-MacBook-Air.local>
Authored: Tue Jan 17 22:24:48 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jan 18 09:42:03 2017 +0100
----------------------------------------------------------------------
.../camel/component/scp/ScpOperations.java | 31 +++++++-------------
1 file changed, 10 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/603c3f37/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java
----------------------------------------------------------------------
diff --git a/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java b/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java
index 32afcbb..39dabc3 100644
--- a/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java
+++ b/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java
@@ -284,7 +284,7 @@ public class ScpOperations implements RemoteFileOperations<ScpFile> {
os.write(bytes.getBytes());
os.write(lineFeed);
os.flush();
- readAck(is, false);
+ readAck(is);
writeFile(filename.substring(pos + 1), data, os, is, cfg);
@@ -293,7 +293,7 @@ public class ScpOperations implements RemoteFileOperations<ScpFile> {
os.write(bytes.getBytes());
os.write(lineFeed);
os.flush();
- readAck(is, false);
+ readAck(is);
} else {
int count = 0;
int read;
@@ -314,7 +314,7 @@ public class ScpOperations implements RemoteFileOperations<ScpFile> {
os.write(bytes.getBytes());
os.write(lineFeed);
os.flush();
- readAck(is, false);
+ readAck(is);
// now send the stream
buffer.reset();
@@ -322,7 +322,7 @@ public class ScpOperations implements RemoteFileOperations<ScpFile> {
os.write(reply, 0, read);
}
writeAck(os);
- readAck(is, false);
+ readAck(is);
} finally {
IOHelper.close(buffer);
}
@@ -334,26 +334,15 @@ public class ScpOperations implements RemoteFileOperations<ScpFile> {
os.flush();
}
- private int readAck(InputStream is, boolean failOnEof) throws IOException {
+ private int readAck(InputStream is) throws IOException {
String message;
int answer = is.read();
switch (answer) {
- case -1:
- if (failOnEof) {
- message = "[scp] Unexpected end of stream";
- throw new EOFException(message);
- }
- break;
- case 1:
- message = "[scp] WARN " + readLine(is);
- LOG.warn(message);
- break;
- case 2:
- message = "[scp] NACK " + readLine(is);
- throw new IOException(message);
- default:
- // case 0:
- break;
+ case 0:
+ break;
+ default:
+ message = "[scp] Return Code [" + answer + "]" + readLine(is);
+ throw new IOException(message);
}
return answer;
}