diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/HiveFileFormatUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/io/HiveFileFormatUtils.java index 93e284e..2ac60c0 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/io/HiveFileFormatUtils.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/io/HiveFileFormatUtils.java @@ -74,7 +74,12 @@ SequenceFileOutputFormat.class, HiveSequenceFileOutputFormat.class); } - static String realoutputFormat; + private static ThreadLocal tRealOutputFormat = new ThreadLocal() { + @Override + protected String initialValue() { + return null; + } + }; @SuppressWarnings("unchecked") private static Map, Class> @@ -105,11 +110,9 @@ public static synchronized void registerOutputFormatSubstitute( } Class result = outputFormatSubstituteMap .get(origin); - //register this output format into the map for the first time - if ((storagehandlerflag == true) && (result == null)) { + if ((storagehandlerflag == true) && (result == null || result == HivePassThroughOutputFormat.class)) { HiveFileFormatUtils.setRealOutputFormatClassName(origin.getName()); result = HivePassThroughOutputFormat.class; - HiveFileFormatUtils.registerOutputFormatSubstitute((Class) origin,HivePassThroughOutputFormat.class); } return result; } @@ -120,7 +123,7 @@ public static synchronized void registerOutputFormatSubstitute( @SuppressWarnings("unchecked") public static String getRealOutputFormatClassName() { - return realoutputFormat; + return tRealOutputFormat.get(); } /** @@ -129,7 +132,7 @@ public static String getRealOutputFormatClassName() public static void setRealOutputFormatClassName( String destination) { if (destination != null){ - realoutputFormat = destination; + tRealOutputFormat.set(destination); } else { return;