This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-06-14
Channels
- # announcements (2)
- # aws (12)
- # aws-lambda (5)
- # beginners (42)
- # calva (56)
- # cider (16)
- # clj-kondo (1)
- # cljs-dev (45)
- # cljsjs (1)
- # cljsrn (25)
- # clojure (171)
- # clojure-europe (3)
- # clojure-italy (16)
- # clojure-losangeles (2)
- # clojure-nl (49)
- # clojure-spec (2)
- # clojure-sweden (3)
- # clojure-uk (11)
- # clojurescript (84)
- # component (11)
- # core-async (12)
- # core-logic (2)
- # cursive (8)
- # datomic (41)
- # events (2)
- # fulcro (48)
- # graalvm (1)
- # graphql (1)
- # hoplon (12)
- # jackdaw (1)
- # jobs (1)
- # jobs-discuss (45)
- # joker (5)
- # keechma (10)
- # nyc (3)
- # off-topic (14)
- # pathom (16)
- # qa (1)
- # re-frame (22)
- # reagent (12)
- # reitit (4)
- # remote-jobs (1)
- # shadow-cljs (40)
- # spacemacs (3)
- # timbre (3)
- # tools-deps (29)
I just want to say that I so appreciate this kind of documentation:
(aws/doc secretsmanager :DescribeSecret) ; => nil
-------------------------
Request
{:SecretId string}
Required
[:SecretId]
-------------------------
Response
{:LastRotatedDate timestamp,
:Tags [:seq-of {:Key string, :Value string}],
:RotationEnabled boolean,
:VersionIdsToStages [:map-of string [:seq-of string]],
:DeletedDate timestamp,
:KmsKeyId string,
:ARN string,
:Name string,
:Description string,
:LastChangedDate timestamp,
:RotationLambdaARN string,
:RotationRules {:AutomaticallyAfterDays long},
:LastAccessedDate timestamp}
I wish more libraries would adopt this kind of pattern, it's phenomenal
or even this:
(s/describe (aws/request-spec-key secretsmanager :DescribeSecret))
; =>
(keys :req-un [:cognitect.aws.secretsmanager.DescribeSecretRequest/SecretId])
the DX (developer experience) is just so high with this capability!
what does this warning mean?
# clojure -A:aot
2019-06-13 23:35:59.486:INFO::main: Logging initialized @5114ms
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.eclipse.jetty.util.BufferUtil (file:/root/.m2/repository/org/eclipse/jetty/jetty-util/9.3.7.v20160115/jetty-util-9.3.7.v20160115.jar) to field java.nio.MappedByteBuffer.fd
WARNING: Please consider reporting this to the maintainers of org.eclipse.jetty.util.BufferUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
clj.core
must be a big deal, because when I run my application, I see this splat out:
2019-06-14 03:37:43.337:INFO:oejc.ResponseNotifier:qtp617928649-19: Exception while notifying listener org.eclipse.jetty.client.HttpRequest$10@3f8ecb1d
java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;
at cognitect.http_client$empty_bbuf.invokeStatic(http_client.clj:37)
at cognitect.http_client$empty_bbuf.invoke(http_client.clj:34)
at cognitect.http_client$on_headers.invokeStatic(http_client.clj:128)
at cognitect.http_client$on_headers.invoke(http_client.clj:108)
at clojure.lang.Atom.swap(Atom.java:51)
at clojure.core$swap_BANG_.invokeStatic(core.clj:2353)
at clojure.core$swap_BANG_.invoke(core.clj:2345)
at cognitect.http_client.Client$fn$reify__8183.onHeaders(http_client.clj:228)
at org.eclipse.jetty.client.HttpRequest$10.onHeaders(HttpRequest.java:487)
at org.eclipse.jetty.client.ResponseNotifier.notifyHeaders(ResponseNotifier.java:103)
at org.eclipse.jetty.client.ResponseNotifier.notifyHeaders(ResponseNotifier.java:95)
at org.eclipse.jetty.client.HttpReceiver.responseHeaders(HttpReceiver.java:257)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.headerComplete(HttpReceiverOverHTTP.java:230)
at org.eclipse.jetty.http.HttpParser.parseHeaders(HttpParser.java:962)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1188)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.parse(HttpReceiverOverHTTP.java:158)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:119)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:69)
at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:90)
at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:113)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:197)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
at java.lang.Thread.run(Thread.java:748)
and
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at clojure.lang.RT.classForName(RT.java:2207)
at clojure.lang.RT.classForName(RT.java:2216)
at clojure.lang.RT.loadClassForName(RT.java:2235)
at clojure.lang.RT.load(RT.java:453)
at clojure.lang.RT.load(RT.java:428)
at clojure.core$load$fn__6824.invoke(core.clj:6126)
at clojure.core$load.invokeStatic(core.clj:6125)
at clojure.core$load.doInvoke(core.clj:6109)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5908)
at clojure.core$load_one.invoke(core.clj:5903)
at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
at clojure.core$load_lib.invokeStatic(core.clj:5947)
at clojure.core$load_lib.doInvoke(core.clj:5928)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$load_libs.invokeStatic(core.clj:5985)
at clojure.core$load_libs.doInvoke(core.clj:5969)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$require.invokeStatic(core.clj:6007)
at clojure.core$require.doInvoke(core.clj:6007)
at clojure.lang.RestFn.invoke(RestFn.java:512)
at clj.core$loading__6706__auto____3.invoke(core.clj:1)
at clj.core__init.load(Unknown Source)
at clj.core__init.<clinit>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at clojure.lang.RT.classForName(RT.java:2207)
at clojure.lang.RT.classForName(RT.java:2216)
at clojure.lang.RT.loadClassForName(RT.java:2235)
at clojure.lang.RT.load(RT.java:453)
at clojure.lang.RT.load(RT.java:428)
at clojure.core$load$fn__6824.invoke(core.clj:6126)
at clojure.core$load.invokeStatic(core.clj:6125)
at clojure.core$load.doInvoke(core.clj:6109)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:384)
at clojure.lang.Util.loadWithClass(Util.java:250)
at clj.core.<clinit>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
Caused by: java.lang.NullPointerException
at java.io.StringReader.<init>(StringReader.java:50)
at clojure.data.json$read_str.invokeStatic(json.clj:278)
at clojure.data.json$read_str.doInvoke(json.clj:274)
at clojure.lang.RestFn.invoke(RestFn.java:439)
at clj.util$json__GT_map.invokeStatic(util.clj:15)
at clj.util$json__GT_map.invoke(util.clj:13)
at clj.dal$get_secret_from_aws.invokeStatic(dal.clj:29)
at clj.dal$get_secret_from_aws.invoke(dal.clj:20)
at clj.dal$get_secret_from_aws.invokeStatic(dal.clj:23)
at clj.dal$get_secret_from_aws.invoke(dal.clj:20)
at clj.dal__init.load(Unknown Source)
at clj.dal__init.<clinit>(Unknown Source)
... 44 more
works fine in the repl though
any idea how to get some more details on what's causing this NullPointerException
?
here's the function in question:
(defn get-secret-from-aws
"Fetch secret from AWS SecretsManager"
([secret-id]
(get-secret-from-aws secret-id "AWSCURRENT"))
([secret-id stage]
(-> (aws/invoke secretsmanager {:op :GetSecretValue
:request {:SecretId secret-id
:VersionStage stage}})
(get :SecretString)
(util/json->map))))
it appears to me that maybe there's an error that I'm not catching that gets discarded in the REPL
I saw same warnings with JVM 11. But there is no issues with JVM 8.
Oh, is it possible that I'm having issues because I'm building in JVM 11, but running my jar in JVM 8?
From my observation - yes. I had similar error when built uberjar
locally with JVM 11 and was trying to run it under AWS Lambda (they provides JVM 8 only). I'd fixed the issue by downgrading my local JVM to latest JVM 8.
That's precisely my situation!
I'm seeing, in some libraries, two shapes of defining a function returned from a function, this way (defn foo [a] (fn ([b] (+ a b))))
and this way (defn foo [a] (fn [b] (+ a b)))
both work, but in shape A, there is an extra set of parens surrounding the inner function parameters. Is this just a matter of style?
Extra parens are needed if you have multiple arities
user> (defn foo [a]
(fn
([b] (+ a b))
([b c] (+ a b c))))
If you have just one arity it’s maybe more clear to not put the extra parens. This is my personal opinion.@UGC0NEP4Y Sometimes you don’t want lazy behavior. butlast
guarantees linear time and eager behavior. drop-last
is lazy and uses map
and drop
internally so it’ll be subject to the usual caveats of chunking, and producing intermediate sequences etc.
understood about extra arity (just like normal functions), but in this case, there is only one arity
Yeah, both are acceptable syntax. From defn
docstring:
>>> Same as (def name (fn [params* ] exprs*)) or (def
name (fn ([params* ] exprs*)+))
Is there a way to get a "doc" for an entire namespace? Like, all defs and their docstrings or something similar-ish?
it's a one-liner I bet
(ins)user=> (->> 'clojure.core ns-publics (take 3) (run! (fn [[s v]] (println s \newline (-> v meta :doc)))))
primitives-classnames
nil
+'
Returns the sum of nums. (+') returns 0. Supports arbitrary precision.
See also: +
decimal?
Returns true if n is a BigDecimal
nil
you can leave out the (take 3)
part of course
throwing sort in the pipeline too is probably better than using the randomized hash-order you'd get otherwise
i'm not sure i understand the full functionality of some of these macro characters. For example, consider:
(def z 1)
``~z
;; => joy.core/z
`'~z
;; => (quote 1)
In the form:
`'`~z
;; => 1
`1
;; => 1
come of think of it, im not sure if and `' are 3 separate macro characters each or if some combination of them make a new function.
it seems there all separate characters https://clojure.org/guides/weird_characters
both clojure.data.json and cheshire are "correct". Neither comes with clojure.core. I have found cheshire performs better but clojure.data.json is less likely to cause jackson version conflicts with other libs
it's really up to you which to use, but those are definitely the popular options
with a big enough project it's not unheard of to end up with both via transitive deps :/