-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Base64 to modern Java #43
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,20 +1,22 @@ | ||||||
(defproject org.flatland/useful "0.11.7-SNAPSHOT" | ||||||
:description "A collection of generally-useful Clojure utility functions" | ||||||
:license {:name "Eclipse Public License - v 1.0" | ||||||
:url "http://www.eclipse.org/legal/epl-v10.html" | ||||||
:license {:name "Eclipse Public License - v 1.0" | ||||||
:url "http://www.eclipse.org/legal/epl-v10.html" | ||||||
:distribution :repo} | ||||||
:url "https://github.com/amalloy/useful" | ||||||
:dependencies [[org.clojure/clojure "1.9.0"] | ||||||
[org.clojure/tools.macro "0.1.1"] | ||||||
[org.clojure/tools.reader "0.7.2"]] | ||||||
:aliases {"testall" ["with-profile" "1.6:1.7:1.8:1.9:1.10" "test"]} | ||||||
:profiles {:1.10 {:dependencies [[org.clojure/clojure "1.10.0-RC3"]]} | ||||||
:1.9 {} | ||||||
:1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]} | ||||||
:1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]} | ||||||
:1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}} | ||||||
:dependencies [[org.clojure/clojure "1.8.0" :scope "provided"] | ||||||
[org.clojure/tools.macro "0.1.5"] | ||||||
[org.clojure/tools.reader "1.3.2"]] | ||||||
:aliases {"testall" ["with-profile" ":1.8:1.9:1.10" "test"]} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The |
||||||
|
||||||
:profiles {:dev {:dependencies [[org.clojure/clojure "1.10.1"]]} | ||||||
:1.10 {:dependencies [[org.clojure/clojure "1.10.1"]]} | ||||||
:1.9 {:dependencies [[org.clojure/clojure "1.9.0"]]} | ||||||
:1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]}} | ||||||
:deploy-repositories [["releases" :clojars] | ||||||
["snapshots" :clojars]] | ||||||
:plugins [[codox "0.8.0"]] | ||||||
:codox {:src-dir-uri "http://github.com/flatland/useful/blob/develop/" | ||||||
:plugins [[codox "0.8.0"] | ||||||
[lein-ancient "0.6.15"]] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if we need this in the plugins here? |
||||||
|
||||||
:codox {:src-dir-uri "http://github.com/flatland/useful/blob/develop/" | ||||||
:src-linenum-anchor-prefix "L"}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
(ns flatland.useful.compress | ||
(:import [java.util.zip DeflaterOutputStream InflaterInputStream] | ||
[java.io ByteArrayOutputStream ByteArrayInputStream] | ||
[sun.misc BASE64Decoder BASE64Encoder])) | ||
(:import | ||
[java.io ByteArrayOutputStream ByteArrayInputStream] | ||
[java.util Base64] | ||
[java.util.zip DeflaterOutputStream InflaterInputStream] )) | ||
|
||
(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] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add the type hint back in? There will be reflection without it. |
||
(let [bytes (-> (BASE64Decoder.) (.decodeBuffer str)) | ||
(defn unsmash [str] | ||
(let [bytes (-> (Base64/getDecoder) (.decode str)) | ||
in (ByteArrayInputStream. bytes)] | ||
(slurp (InflaterInputStream. in)))) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(ns flatland._bootstrap | ||
(:require | ||
[clojure.test :refer :all] | ||
[clojure.string :as str] )) | ||
|
||
(defn print-versions [] | ||
(let [version-str (format " Clojure %s Java %s" | ||
(clojure-version) (System/getProperty "java.version")) | ||
num-hyphen (+ 6 (count version-str)) | ||
hyphens (str/join (repeat num-hyphen \-)) ] | ||
(newline) | ||
(println hyphens) | ||
(println version-str) | ||
(println hyphens))) | ||
|
||
(deftest t-bootstrap-16 | ||
(print-versions)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to only make the changes to the dependencies here without the reformatting?