AMBARI-20990 : writing query properly to hdfs file for handling unicode characters. (nitirajrathore)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fffd07c7 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fffd07c7 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fffd07c7 Branch: refs/heads/branch-feature-AMBARI-14714 Commit: fffd07c75ba1af09b0ba3fec347bd7a6fff87807 Parents: 461209a Author: Nitiraj Singh Rathore <[email protected]> Authored: Fri May 12 08:52:02 2017 +0530 Committer: Nitiraj Singh Rathore <[email protected]> Committed: Fri May 12 08:53:38 2017 +0530 ---------------------------------------------------------------------- .../ambari/view/hive2/resources/files/FileService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/fffd07c7/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/files/FileService.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/files/FileService.java b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/files/FileService.java index 64880bb..88f8df1 100644 --- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/files/FileService.java +++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/resources/files/FileService.java @@ -185,9 +185,9 @@ public class FileService extends BaseService { try { filePath = sanitizeFilePath(filePath); LOG.debug("Rewriting file " + filePath); - FSDataOutputStream output = getSharedObjectsFactory().getHdfsApi().create(filePath, true); - output.writeBytes(request.file.getFileContent()); - output.close(); + HdfsApi hdfsApi = getSharedObjectsFactory().getHdfsApi(); + HdfsUtil.putStringToFile(hdfsApi, filePath, + request.file.getFileContent()); return Response.status(204).build(); } catch (WebApplicationException ex) { throw ex; @@ -209,7 +209,7 @@ public class FileService extends BaseService { try { FSDataOutputStream output = getSharedObjectsFactory().getHdfsApi().create(request.file.getFilePath(), false); if (request.file.getFileContent() != null) { - output.writeBytes(request.file.getFileContent()); + output.write(request.file.getFileContent().getBytes()); } output.close(); } catch (FileAlreadyExistsException ex) {
