Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 4cb2ba5d1 -> bace3bf89


AMBARI-17194. File browser : File preview show first character only when ssl is 
enabled. (Gaurav Nagar via dipayanb)


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

Branch: refs/heads/branch-2.4
Commit: bace3bf89fd9192aa9668dae63c3c44bbc82f13a
Parents: 4cb2ba5
Author: Dipayan Bhowmick <[email protected]>
Authored: Tue Jun 14 15:49:41 2016 +0530
Committer: Dipayan Bhowmick <[email protected]>
Committed: Tue Jun 14 15:49:41 2016 +0530

----------------------------------------------------------------------
 .../apache/ambari/view/filebrowser/FilePreviewService.java    | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/bace3bf8/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/FilePreviewService.java
----------------------------------------------------------------------
diff --git 
a/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/FilePreviewService.java
 
b/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/FilePreviewService.java
index 3585516..9d0e514 100644
--- 
a/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/FilePreviewService.java
+++ 
b/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/FilePreviewService.java
@@ -23,6 +23,7 @@ import 
org.apache.ambari.view.commons.exceptions.NotFoundFormattedException;
 import org.apache.ambari.view.commons.exceptions.ServiceFormattedException;
 import org.apache.ambari.view.commons.hdfs.HdfsService;
 import org.apache.ambari.view.utils.hdfs.HdfsApi;
+import org.apache.commons.io.IOUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.io.compress.CompressionCodec;
@@ -69,9 +70,9 @@ public class FilePreviewService extends HdfsService {
 
       int length = end - start;
       byte[] bytes = new byte[length];
-     // ((Seekable)stream).seek(start); //seek(start);
-      stream.skip(start);
-      int readBytes = stream.read(bytes, 0, length);
+
+      if (start != 0) IOUtils.skip(stream, start);
+      int readBytes = IOUtils.read(stream, bytes);
       boolean isFileEnd = false;
 
       if (readBytes < length) isFileEnd = true;

Reply via email to