Skip to content

Commit

Permalink
AVRO-2331: Use JDK Base64
Browse files Browse the repository at this point in the history
  • Loading branch information
belugabehr authored and dkulp committed Mar 7, 2019
1 parent f715c97 commit e16f30a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
5 changes: 0 additions & 5 deletions lang/java/mapred/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
*/
package org.apache.avro.mapred;

import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.apache.avro.Schema;
import org.apache.avro.SchemaParseException;
import org.apache.commons.codec.binary.Base64;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapred.JobConf;

Expand Down Expand Up @@ -206,13 +207,15 @@ static Map<Path, Schema> getInputSchemaMap(JobConf conf) {
}

private static String toBase64(String rawString) {
Base64 base64decoder = new Base64();
return new String(base64decoder.encode(rawString.getBytes()));
final byte[] buf = rawString.getBytes(StandardCharsets.UTF_8);
return new String(Base64.getMimeEncoder().encode(buf),
StandardCharsets.UTF_8);
}

private static String fromBase64(String base64String) {
Base64 base64decoder = new Base64();
return new String(base64decoder.decode(base64String.getBytes()));
final byte[] buf = base64String.getBytes(StandardCharsets.UTF_8);
return new String(Base64.getMimeDecoder().decode(buf),
StandardCharsets.UTF_8);
}

}
1 change: 0 additions & 1 deletion lang/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
<maven.version>2.0.11</maven.version>
<ant.version>1.10.5</ant.version>
<commons-cli.version>1.4</commons-cli.version>
<commons-codec.version>1.12</commons-codec.version>
<commons-compress.version>1.18</commons-compress.version>
<commons-lang.version>3.8.1</commons-lang.version>
<tukaani.version>1.8</tukaani.version>
Expand Down

0 comments on commit e16f30a

Please sign in to comment.