File: 0002_Replace_Sun_Base64_By_Java.patch

package info (click to toggle)
useful-clojure 0.11.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 428 kB
  • sloc: sh: 71; makefile: 19
file content (32 lines) | stat: -rw-r--r-- 1,276 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
From: Alan Thompson <cloojure@gmail.com>
Description: Move away from sun.misc.Base64decoder
Origin: upstream, https://github.com/clj-commons/useful/pull/43
Bug: https://github.com/clj-commons/useful/issues/40
Index: useful-clojure/src/flatland/useful/compress.clj
===================================================================
--- useful-clojure.orig/src/flatland/useful/compress.clj
+++ useful-clojure/src/flatland/useful/compress.clj
@@ -1,17 +1,17 @@
 (ns flatland.useful.compress
   (:import [java.util.zip DeflaterOutputStream InflaterInputStream]
            [java.io ByteArrayOutputStream ByteArrayInputStream]
-           [sun.misc BASE64Decoder BASE64Encoder]))
+           [java.util Base64]))
 
-(defn smash [^String str]
+(defn smash [str]
   (let [out (ByteArrayOutputStream.)]
     (doto (DeflaterOutputStream. out)
       (.write (.getBytes str))
       (.finish))
-    (-> (BASE64Encoder.)
-        (.encodeBuffer (.toByteArray out)))))
+    (-> (Base64/getEncoder)
+      (.encode (.toByteArray out)))))
 
-(defn unsmash [^String str]
-  (let [bytes (-> (BASE64Decoder.) (.decodeBuffer str))
+(defn unsmash [str]
+  (let [bytes (-> (Base64/getDecoder) (.decode str))
         in    (ByteArrayInputStream. bytes)]
     (slurp (InflaterInputStream. in))))