You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2015/11/10 18:30:48 UTC

ambari git commit: AMBARI-13786. Ambari HDFS files (View) appends several "non-printable" characters at the end of the file. (DIPAYAN BHOWMICK via srimanth)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 d3219265a -> 44191d5ce


AMBARI-13786. Ambari HDFS files (View) appends several "non-printable" characters at the end of the file. (DIPAYAN BHOWMICK via srimanth)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/44191d5c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/44191d5c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/44191d5c

Branch: refs/heads/branch-2.1
Commit: 44191d5ce525d170e504f9e791b909a9e2788a6a
Parents: d321926
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Tue Nov 10 09:30:27 2015 -0800
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Tue Nov 10 09:30:27 2015 -0800

----------------------------------------------------------------------
 .../ambari/view/filebrowser/UploadService.java       | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/44191d5c/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/UploadService.java
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/UploadService.java b/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/UploadService.java
index 0324796..eb5c0c7 100644
--- a/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/UploadService.java
+++ b/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/UploadService.java
@@ -50,12 +50,19 @@ public class UploadService extends HdfsService {
 
   private void uploadFile(final String filePath, InputStream uploadedInputStream)
       throws IOException, InterruptedException {
+    int read;
     byte[] chunk = new byte[1024];
-    FSDataOutputStream out = getApi(context).create(filePath, false);
-    while (uploadedInputStream.read(chunk) != -1) {
-      out.write(chunk);
+    FSDataOutputStream out = null;
+    try {
+      out = getApi(context).create(filePath, false);
+      while ((read = uploadedInputStream.read(chunk)) != -1) {
+        out.write(chunk, 0, read);
+      }
+    } finally {
+      if (out != null) {
+        out.close();
+      }
     }
-    out.close();
   }
 
   /**