hadoop-hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r999126 - in /hadoop/hive/trunk: CHANGES.txt contrib/src/java/org/apache/hadoop/hive/contrib/fileformat/base64/Base64TextInputFormat.java contrib/src/java/org/apache/hadoop/hive/contrib/fileformat/base64/Base64TextOutputFormat.java
Date Mon, 20 Sep 2010 21:39:49 GMT
Author: jvs
Date: Mon Sep 20 21:39:48 2010
New Revision: 999126

URL: http://svn.apache.org/viewvc?rev=999126&view=rev
Log:
HIVE-1628. Fix Base64TextInputFormat to be compatible with commons
codec 1.4
(Todd Lipcon via jvs)


Modified:
    hadoop/hive/trunk/CHANGES.txt
    hadoop/hive/trunk/contrib/src/java/org/apache/hadoop/hive/contrib/fileformat/base64/Base64TextInputFormat.java
    hadoop/hive/trunk/contrib/src/java/org/apache/hadoop/hive/contrib/fileformat/base64/Base64TextOutputFormat.java

Modified: hadoop/hive/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/CHANGES.txt?rev=999126&r1=999125&r2=999126&view=diff
==============================================================================
--- hadoop/hive/trunk/CHANGES.txt (original)
+++ hadoop/hive/trunk/CHANGES.txt Mon Sep 20 21:39:48 2010
@@ -141,6 +141,10 @@ Trunk -  Unreleased
     HIVE-558. Make describe output better
     (Thiruvel Thirumoolan via namit)
 
+    HIVE-1628. Fix Base64TextInputFormat to be compatible with commons
+    codec 1.4
+    (Todd Lipcon via jvs)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/hive/trunk/contrib/src/java/org/apache/hadoop/hive/contrib/fileformat/base64/Base64TextInputFormat.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/contrib/src/java/org/apache/hadoop/hive/contrib/fileformat/base64/Base64TextInputFormat.java?rev=999126&r1=999125&r2=999126&view=diff
==============================================================================
--- hadoop/hive/trunk/contrib/src/java/org/apache/hadoop/hive/contrib/fileformat/base64/Base64TextInputFormat.java
(original)
+++ hadoop/hive/trunk/contrib/src/java/org/apache/hadoop/hive/contrib/fileformat/base64/Base64TextInputFormat.java
Mon Sep 20 21:39:48 2010
@@ -21,6 +21,8 @@ package org.apache.hadoop.hive.contrib.f
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.Arrays;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 
 import org.apache.commons.codec.binary.Base64;
 import org.apache.hadoop.hive.shims.ShimLoader;
@@ -125,7 +127,7 @@ public class Base64TextInputFormat imple
     }
 
     private byte[] signature;
-    private final Base64 base64 = new Base64();
+    private final Base64 base64 = createBase64();
 
     @Override
     public void configure(JobConf job) {
@@ -140,6 +142,7 @@ public class Base64TextInputFormat imple
         e.printStackTrace();
       }
     }
+
   }
 
   TextInputFormat format;
@@ -174,4 +177,28 @@ public class Base64TextInputFormat imple
     ShimLoader.getHadoopShims().inputFormatValidateInput(format, job);
   }
 
+  /**
+   * Workaround an incompatible change from commons-codec 1.3 to 1.4.
+   * Since Hadoop has this jar on its classpath, we have no way of knowing
+   * which version we are running against.
+   */
+  static Base64 createBase64() {
+    try {
+      // This constructor appeared in 1.4 and specifies that we do not want to
+      // line-wrap or use any newline separator
+      Constructor<Base64> ctor = Base64.class.getConstructor(int.class, byte[].class);
+      return ctor.newInstance(0, null);
+    } catch (NoSuchMethodException e) { // ie we are running 1.3
+      // In 1.3, this constructor has the same behavior, but in 1.4 the default
+      // was changed to add wrapping and newlines.
+      return new Base64();
+    } catch (InstantiationException e) {
+      throw new RuntimeException(e);
+    } catch (IllegalAccessException e) {
+      throw new RuntimeException(e);
+    } catch (InvocationTargetException e) {
+      throw new RuntimeException(e.getCause());
+    }
+  }
+
 }

Modified: hadoop/hive/trunk/contrib/src/java/org/apache/hadoop/hive/contrib/fileformat/base64/Base64TextOutputFormat.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/contrib/src/java/org/apache/hadoop/hive/contrib/fileformat/base64/Base64TextOutputFormat.java?rev=999126&r1=999125&r2=999126&view=diff
==============================================================================
--- hadoop/hive/trunk/contrib/src/java/org/apache/hadoop/hive/contrib/fileformat/base64/Base64TextOutputFormat.java
(original)
+++ hadoop/hive/trunk/contrib/src/java/org/apache/hadoop/hive/contrib/fileformat/base64/Base64TextOutputFormat.java
Mon Sep 20 21:39:48 2010
@@ -101,7 +101,7 @@ public class Base64TextOutputFormat<K ex
     }
 
     private byte[] signature;
-    private final Base64 base64 = new Base64();
+    private final Base64 base64 = Base64TextInputFormat.createBase64();
 
     @Override
     public void configure(JobConf job) {



Mime
View raw message