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:32 UTC

[03/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/3734bc8a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3734bc8a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3734bc8a

Branch: refs/heads/master
Commit: 3734bc8add7bef84b0782bdd11c5f8e359984a60
Parents: fdcd05b
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:24: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/3734bc8a/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 1403dae..9468c15 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
@@ -288,7 +288,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);
 
@@ -297,7 +297,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;
@@ -318,7 +318,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();
@@ -326,7 +326,7 @@ public class ScpOperations implements RemoteFileOperations<ScpFile> {
                     os.write(reply, 0, read);
                 }
                 writeAck(os);
-                readAck(is, false);
+                readAck(is);
             } finally {
                 IOHelper.close(buffer);
             }
@@ -338,26 +338,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;
     }