Author: hashutosh Date: Fri Dec 20 22:49:56 2013 New Revision: 1552833 URL: http://svn.apache.org/r1552833 Log: HIVE-6066 : Wincompat: describe_comment_nonascii.q failing on windows (Jason Dere via Ashutosh Chauhan)
Modified: hive/trunk/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java Modified: hive/trunk/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java URL: http://svn.apache.org/viewvc/hive/trunk/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java?rev=1552833&r1=1552832&r2=1552833&view=diff ============================================================================== --- hive/trunk/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java (original) +++ hive/trunk/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java Fri Dec 20 22:49:56 2013 @@ -31,6 +31,7 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; +import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.Serializable; import java.io.StringWriter; @@ -47,6 +48,7 @@ import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -1097,17 +1099,12 @@ public class QTestUtil { BufferedReader in; BufferedWriter out; - in = new BufferedReader(new FileReader(fname)); - out = new BufferedWriter(new FileWriter(fname + ".orig")); - while (null != (line = in.readLine())) { - out.write(line); - out.write('\n'); - } - in.close(); - out.close(); + File file = new File(fname); + File fileOrig = new File(fname + ".orig"); + FileUtils.copyFile(file, fileOrig); - in = new BufferedReader(new FileReader(fname + ".orig")); - out = new BufferedWriter(new FileWriter(fname)); + in = new BufferedReader(new InputStreamReader(new FileInputStream(fileOrig), "UTF-8")); + out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); boolean lastWasMasked = false; while (null != (line = in.readLine())) { Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java?rev=1552833&r1=1552832&r2=1552833&view=diff ============================================================================== --- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java (original) +++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java Fri Dec 20 22:49:56 2013 @@ -130,7 +130,7 @@ class TextMetaDataFormatter implements M } else { output = MetaDataFormatUtils.getAllColumnsInformation(cols, isFormatted); } - outStream.write(output.getBytes()); + outStream.write(output.getBytes("UTF-8")); if (tableName.equals(colPath)) { if (isFormatted) { @@ -139,7 +139,7 @@ class TextMetaDataFormatter implements M } else { output = MetaDataFormatUtils.getTableInformation(tbl); } - outStream.write(output.getBytes()); + outStream.write(output.getBytes("UTF-8")); } // if extended desc table then show the complete details of the table @@ -150,7 +150,7 @@ class TextMetaDataFormatter implements M // show partition information outStream.writeBytes("Detailed Partition Information"); outStream.write(separator); - outStream.write(part.getTPartition().toString().getBytes()); + outStream.write(part.getTPartition().toString().getBytes("UTF-8")); outStream.write(separator); // comment column is empty outStream.write(terminator); @@ -158,7 +158,7 @@ class TextMetaDataFormatter implements M // show table information outStream.writeBytes("Detailed Table Information"); outStream.write(separator); - outStream.write(tbl.getTTable().toString().getBytes()); + outStream.write(tbl.getTTable().toString().getBytes("UTF-8")); outStream.write(separator); outStream.write(terminator); } @@ -443,7 +443,7 @@ class TextMetaDataFormatter implements M outStream.writeBytes(database); outStream.write(separator); if (comment != null) { - outStream.write(comment.getBytes()); + outStream.write(comment.getBytes("UTF-8")); } outStream.write(separator); if (location != null) {