camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [05/10] camel git commit: CAMEL-10713 SCP not handling errors for failed transfers correctly
Date Wed, 18 Jan 2017 08:42:34 GMT
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/045aa57b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/045aa57b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/045aa57b

Branch: refs/heads/camel-2.18.x
Commit: 045aa57b9f519f86292b53efe7c3e8beb347385c
Parents: 489d21f
Author: Patrick McGloin <patrickmcgloin@Patricks-MacBook-Air.local>
Authored: Tue Jan 17 22:24:48 2017 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Jan 18 09:41:20 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/045aa57b/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 fb5e34f..243316b 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
@@ -283,7 +283,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);
 
@@ -292,7 +292,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;
@@ -313,7 +313,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();
@@ -321,7 +321,7 @@ public class ScpOperations implements RemoteFileOperations<ScpFile>
{
                     os.write(reply, 0, read);
                 }
                 writeAck(os);
-                readAck(is, false);
+                readAck(is);
             } finally {
                 IOHelper.close(buffer);
             }
@@ -333,26 +333,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;
     }


Mime
View raw message