Skip to content

Commit

Permalink
[HOTFIX] Fix Base64 not existed in jdk7 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryshao committed Jun 13, 2018
1 parent 2196302 commit 551dd5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
</dependencies>

</project>
7 changes: 5 additions & 2 deletions core/src/main/scala/org/apache/livy/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ import java.io.{Closeable, File, InputStreamReader}
import java.net.URL
import java.nio.charset.StandardCharsets.UTF_8
import java.security.SecureRandom
import java.util.{Base64, Properties}
import java.util.Properties

import scala.annotation.tailrec
import scala.collection.JavaConverters._
import scala.concurrent.TimeoutException
import scala.concurrent.duration.Duration

import org.apache.commons.codec.binary.Base64

object Utils {
def getPropertiesFromFile(file: File): Map[String, String] = {
loadProperties(file.toURI().toURL())
Expand Down Expand Up @@ -111,6 +113,7 @@ object Utils {
val rnd = new SecureRandom()
val secretBytes = new Array[Byte](secretBitLength / java.lang.Byte.SIZE)
rnd.nextBytes(secretBytes)
Base64.getEncoder.encodeToString(secretBytes)

Base64.encodeBase64String(secretBytes)
}
}

0 comments on commit 551dd5c

Please sign in to comment.