This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-28
Channels
- # announcements (11)
- # aws (1)
- # babashka (12)
- # babashka-sci-dev (6)
- # beginners (46)
- # biff (15)
- # calva (57)
- # clerk (6)
- # clj-kondo (50)
- # clj-together (1)
- # cljs-dev (14)
- # clojure (89)
- # clojure-doc (1)
- # clojure-europe (36)
- # clojure-nl (1)
- # clojure-norway (50)
- # clojure-spec (4)
- # clojure-uk (1)
- # clojurescript (56)
- # conjure (10)
- # cursive (1)
- # datalevin (2)
- # datomic (3)
- # fulcro (15)
- # honeysql (36)
- # hyperfiddle (74)
- # malli (19)
- # membrane (16)
- # off-topic (33)
- # pathom (6)
- # polylith (2)
- # reagent (14)
- # releases (2)
- # rum (5)
- # shadow-cljs (51)
- # sql (6)
- # tools-build (10)
- # xtdb (6)
How come this works:
(Integer/MAX_INT)
=> 2147483647
when this doesn't:
(42)
class java.lang.Long cannot be cast to class clojure.lang.IFn
The MAX_INT
constant is defined like this:
@Native public static final int MAX_VALUE = 0x7fffffff;
@U052XLL3A (Integer/MAX_INT)
expands into (. Integer MAX_INT)
and clojure supports both reading fields are calling 0-arity methods with this syntax
user=> (macroexpand '(Integer/MAX_INT))
(. Integer MAX_INT)
it's not really a macro, more like a built-in syntax thing, but macroexpand also desugars this stuff
Well, for better or for worse, I think it could be argued that field access should not be surrounded with ()
;)
Totally agree - somehow I ended up writing it, and then when I found out, I was puzzled that it worked
interesting thread
btw in babashka it doesn't translate to that mentioned (. Integer MAX_INT)
form..
ā ~ clojure -e "(macroexpand '(Integer/MAX_INT))" 2>/dev/null
(. Integer MAX_INT)
ā ~ bb -e "(macroexpand '(Integer/MAX_INT))" 2>/dev/null
(Integer/MAX_INT)
Is this expected?It does work though, if the class/field is supported in bb:
user=> Long/MAX_VALUE
9223372036854775807
user=> (Long/MAX_VALUE)
9223372036854775807
the analyzer in bb handles the Long/MAX_VALUE
form directly, it doesn't happen in macroexpand in bb, kind of a detail imo
I'm trying to use cognitect/aws with localstack and facing this surprising behaviour:
(sh "aws" "--endpoint-url=" "sqs" "list-queues")
;; => {:exit 0, :out "", :err ""}
(aws/invoke local-sqs {:op :CreateQueue :request {:QueueName "test_queue"}})
;;=> {:QueueUrl ""}
(aws/invoke local-sqs {:op :ListQueues :request {}})
;;=> {:QueueUrls [""]}
(sh "aws" "--endpoint-url=" "sqs" "list-queues")
;;=> {:exit 0, :out "{\n \"QueueUrls\": [\n \"\"\n ]\n}\n", :err ""}
Shelling out to aws CLI includes the port number in the queue URL when listing the queues but aws-api doesn't.
Is this intentional or should I file a bug?
edit: I just discovered #aws :face_palm:, should I move this there?How did you create local-sqs
?
Also, a bit unrelated but I would suggest using something other than LocalStack if you need only S3. Had a lot of problems with it, always with something hard to debug. And recently they removed persistence in their free plan.
So far, very happy with MinIO. It's also much, much faster to start.
Ah, didn't realize that SQS is not S3, heh.
> How did you create local-sqs?
(def local-sqs (aws/client {:api :sqs
:region "us-east-1"
:credentials-provider (aws/default-http-client)
:endpoint-override {:protocol :http
:hostname "localhost"
:port 4566}}))
Ah yeah, I use the same thing for the S3 client, and it works properly there. Interesting.
It seems that the AWS CLI picks up the correct queue URL, so the queue is probably created as expected, but for some reason the port doesn't show when you print the url via aws-api :thinking_face: . It doesn't seem to cause any issues though (I think), so it's ok, just a bit of a surprise... By the way I need localstack (wish I didn't) because I want to develop against the AWS API, without requiring any actual AWS infrastructure when working in the REPL.
> I want to develop against the AWS API, without requiring any actual AWS infrastructure when working in the REPL Yeah, of course - that's why I mentioned MinIO, but unfortunately they only provide an object storage AFAIK.
> the port doesn't show when you print the url via aws-api
Oh, right. Although I imagine that it might be LocalStack to blame. Maybe it checks for some optional headers that AWS CLI sends out, or maybe AWS CLI alters the URLs so that they include the port.
Of course, it can still be aws-api
that's to blame. But it's a really thin wrapper for the HTTP API, so that would surprise me.
Iām having a bugger of a time trying to understand this error Iām getting. Iām desctructuring a channel out of a map and then trying to pass it to my mulog publisher.
(defmethod ig/init-key :sys/env
[_ module-config]
(let [{:sys/keys [app loc stage]} module-config
{:module/keys [bb]} module-config
{:module/keys [bb]} bb
{:<bus/keys [eb]} bb
module-config (assoc module-config :kill-publisher
(select-publisher!
#{:pretty-console
{:type :custom
:fqn-function
"net.drilling.util.event.publishers.event-bus/event-bus-publisher"
:transform #(event-bus-transform %)
:eb eb
:pretty-print true}}))
module-config (assoc module-config :sys/bb bb :sys/eb eb :sys/<eb <eb :sys/>eb >eb)]
(log/log :sys/bb-facts :eb eb :eb-type (type eb))
module-config))
The error Iām getting is a class cast exception. The interesting part is;
Exception in thread "async-dispatch-10" Exception in thread "async-dispatch-32" java.lang.ClassCastException: class clojure.core.async.impl.channels.ManyToManyChannel cannot be cast to class clojure.lang.IFn (clojure.core.async.impl.channels.ManyToManyChannel is in unnamed module of loader clojure.lang.DynamicClassLoader @20b2d351; clojure.lang.IFn is in unnamed module of loader 'app')
Thing is everything works except my repl is spitting bloody murder about the class cast to IFn. For the life of me I canāt find where Iām not passing something that looks like
:eb
#object[clojure.core.async.impl.channels.ManyToManyChannel 0x7beff931 "clojure.core.async.impl.channels.ManyToManyChannel@7beff931"],
:eb-type clojure.core.async.impl.channels.ManyToManyChannel,
This is what mulog is printing to the console. Based on my log statement at the end of the first code snippet. Can anyone elucidate where Iām going wrong? Or how I should try to troubleshoot this if my mistake further upstream? CHEERS and CLJ!
somewhere you are invoking a channel
what is that you are passing to select-publisher!
? looks like it suppose to be a map but because there is #
in front it tun out to be a set
It is a set, the first item in the set is :pretty-console, the second is the map
there is no "first" item in a set
sets and maps are unordered and seq to arbitrary order
Correct again, the first item in the code.
The set has two unordered items, itās not a map.
eb is a channel - do you invoke that somewhere?
so there is a kw and a map. Can I ask you about this Ifn? What would my wrong code look like, because all Iām seeing is a put parking
Clojure will try to cast the first thing in an invocation to an IFn, so somewhere you are doing the equivalent of (<a-channel> ...)
(deftype EventBusPublisher [config buffer transform]
com.brunobonacci.mulog.publisher.PPublisher
(agent-buffer [_]
buffer)
(publish-delay [_]
500)
(publish [_ buffer]
(let [eb (:eb config)]
(doseq [item (transform (map second (rb/items buffer)))]
(a/>!! eb item)))
(rb/clear buffer)))
Correction, put blocking
(surround with ` for code blocks btw)
that code looks fine in the a/>!! call
so I assume the problem is elsewhere :)
can you see a stacktrace of ClassCastException? with core.async it is not always points to the right place but maybe it has something usefull now
The reason I thought it was a destructuring thing is because when I just bind eb to a fresh call to (a/chan) in the let statement the error disappears.
Exception in thread "async-dispatch-10" Exception in thread "async-dispatch-32" java.lang.ClassCastException: class clojure.core.async.impl.channels.ManyToManyChannel cannot be cast to class clojure.lang.IFn (clojure.core.async.impl.channels.ManyToManyChannel is in unnamed module of loader clojure.lang.DynamicClassLoader @20b2d351; clojure.lang.IFn is in unnamed module of loader 'app')
at clojure.core.async$pub$fn__20980$state_machine__19381__auto____20993$fn__20995.invoke(async.clj:966)
at clojure.core.async$pub$fn__20980$state_machine__19381__auto____20993.invoke(async.clj:966)
at clojure.core.async.impl.runtime$run_state_machine.invokeStatic(runtime.clj:62)
at clojure.core.async.impl.runtime$run_state_machine.invoke(runtime.clj:61)
at clojure.core.async.impl.runtime$run_state_machine_wrapped.invokeStatic(runtime.clj:66)
at clojure.core.async.impl.runtime$run_state_machine_wrapped.invoke(runtime.clj:64)
at clojure.core.async.impl.runtime$take_BANG_$fn__14117.invoke(runtime.clj:75)
at clojure.core.async.impl.channels.ManyToManyChannel$fn__13927.invoke(channels.clj:140)
at clojure.lang.AFn.run(AFn.java:22)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at clojure.core.async.impl.concurrent$counted_thread_factory$reify__13780$fn__13781.invoke(concurrent.clj:29)
at clojure.lang.AFn.run(AFn.java:22)
at java.base/java.lang.Thread.run(Thread.java:833)
java.lang.ClassCastException: class clojure.core.async.impl.channels.ManyToManyChannel cannot be cast to class clojure.lang.IFn (clojure.core.async.impl.channels.ManyToManyChannel is in unnamed module of loader clojure.lang.DynamicClassLoader @20b2d351; clojure.lang.IFn is in unnamed module of loader 'app')
at clojure.core.async$pub$fn__20980$state_machine__19381__auto____20993$fn__20995.invoke(async.clj:966)
at clojure.core.async$pub$fn__20980$state_machine__19381__auto____20993.invoke(async.clj:966)
at clojure.core.async.impl.runtime$run_state_machine.invokeStatic(runtime.clj:62)
at clojure.core.async.impl.runtime$run_state_machine.invoke(runtime.clj:61)
at clojure.core.async.impl.runtime$run_state_machine_wrapped.invokeStatic(runtime.clj:66)
at clojure.core.async.impl.runtime$run_state_machine_wrapped.invoke(runtime.clj:64)
at clojure.core.async.impl.runtime$take_BANG_$fn__14117.invoke(runtime.clj:75)
at clojure.core.async.impl.channels.ManyToManyChannel$fn__13927.invoke(channels.clj:140)
at clojure.lang.AFn.run(AFn.java:22)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at clojure.core.async.impl.concurrent$counted_thread_factory$reify__13780$fn__13781.invoke(concurrent.clj:29)
at clojure.lang.AFn.run(AFn.java:22)
at java.base/java.lang.Thread.run(Thread.java:833)
Exception in thread "async-dispatch-20" java.lang.ClassCastException: class clojure.core.async.impl.channels.ManyToManyChannel cannot be cast to class clojure.lang.IFn (clojure.core.async.impl.channels.ManyToManyChannel is in unnamed module of loader clojure.lang.DynamicClassLoader @20b2d351; clojure.lang.IFn is in unnamed module of loader 'app')
at clojure.core.async$pub$fn__20980$state_machine__19381__auto____20993$fn__20995.invoke(async.clj:966)
at clojure.core.async$pub$fn__20980$state_machine__19381__auto____20993.invoke(async.clj:966)
at clojure.core.async.impl.runtime$run_state_machine.invokeStatic(runtime.clj:62)
at clojure.core.async.impl.runtime$run_state_machine.invoke(runtime.clj:61)
at clojure.core.async.impl.runtime$run_state_machine_wrapped.invokeStatic(runtime.clj:66)
at clojure.core.async.impl.runtime$run_state_machine_wrapped.invoke(runtime.clj:64)
at clojure.core.async.impl.runtime$take_BANG_$fn__14117.invoke(runtime.clj:75)
at clojure.core.async.impl.channels.ManyToManyChannel$fn__13927.invoke(channels.clj:140)
at clojure.lang.AFn.run(AFn.java:22)
at java.base/java.util.concurrent.Thre{:mulog/event-name :sys/halt!,
:mulog/event-name :sys/halt!
this looks interesting. Does it sound like something familiar?
Thatās me telling integrant to shutdown the system so I can dig around. You can think of it as me calling interrupt. I think just having someone to talk it out with has helped me realize Iām looking in the wrong place.
If Iām posting to the event bus channel and itās got pubs on top of taps on top of mults, obviously I was looking at the wrong part of my code. This may be tricky.
btw, regarding destructuring ā you can mix keys extraction with different namespaces: {:foo/keys [a b] :bar/keys [c d]} obj
WHAT!!! How did I miss that? Thatās cool.
obviously as long as names are not the same
Found it! Thanks so much for helping me talk through it. The error was in calling pub with two channels as arguments.
Yup, Iāve verified @U064X3EF3 and @U04V4KLKC as good guys for the day. Cheers, I would have been staring in the wrong place for way too long.
@U036UJBDM5G probably too late, but I made a tool that helps debugging those kinds of issues https://github.com/jpmonettas/flow-storm-debugger, maybe the next time it can help
I am looking for a way to either force clj-http
to use TLSv1.3
with the provided keystore and truststore or a lightweight replacement. One of our providers switched to RHEL8 and is now enforcing TLSv1.3
which atm causes an error when using clj-http
regarding an invalid certification path for one of the endpoints we connect to.
I have asked questions regarding this in #CBE668G4R about enabling the logging for the dependency and a question in #C8860D6BS
but that channel isn't very populated.
Error thrown:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
adjacencyList: #object[sun.security.provider.certpath.AdjacencyList 0x7f2de45 "[\nLinkedList[0]:\n]\n"]
And also:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by clojure.core$bean$fn__7278$fn__7279 (file:/C:/Users/thier/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar) to method sun.security.provider.certpath.SunCertPathBuilderException.getAdjacencyList()
WARNING: Please consider reporting this to the maintainers of clojure.core$bean$fn__7278$fn__7279
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-http should work with TLSv1.3 just fine. How do you call request function?
Here's the request (simplified but the same)
(clj-http.core/request {:method :post :url "
I just manually created a connection manager using java methods and explicitly setting TLSv1.3 but it resulted in the same errors.
I guess it must be something to do with the illegal reflective access error
?
Cleared all cached and started a fresh repl. Did everything manual and the same error gets thrown.
WARNING: Illegal reflective access by clojure.core$bean$fn__7278$fn__7279 (file:/C:/Users/thier/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar) to method sun.security.provider.certpath.SunCertPathBuilderException.getAdjacencyList()
I Know the certificate is okay, because when I try with curl I get a response from the server
I have debug logging enabled and this logs:
javax.net.ssl|DEBUG|16|nREPL-session-9a6d32af-28d2-40bc-9f19-df31980cb8d8|2023-02-28 17:04:47.966 CET|SSLCipher.java:1866|KeyLimit read side: algorithm = AES/GCM/NOPADDING:KEYUPDATE
countdown value = 137438953472
javax.net.ssl|DEBUG|16|nREPL-session-9a6d32af-28d2-40bc-9f19-df31980cb8d8|2023-02-28 17:04:47.968 CET|SSLCipher.java:2020|KeyLimit write side: algorithm = AES/GCM/NOPADDING:KEYUPDATE
countdown value = 137438953472
javax.net.ssl|ERROR|16|nREPL-session-9a6d32af-28d2-40bc-9f19-df31980cb8d8|2023-02-28 17:04:47.978 CET|TransportContext.java:361|Fatal (CERTIFICATE_UNKNOWN): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Reflection warning points to the place where clj-http generates response for debugging, so I would ignore it for now. Could be something wrong with keystore or trust-store, do you use full-path to them or relative to the project root?
keystore does seem to get loaded?
and then a printout of the ssl.
Followed by
and a prinout of the chain
Which is then followed by:
countdown value = 137438953472
countdown value = 137438953472
me to, sorry. I never stumbled upon such exception and all I can find out points to some jvm related keystores
I've been at this for 2 days now, seen a zillion pages but nothing that points me in the correct direction. I've tried to enable debug logging on clj-http but my calva session seems to overrule the settings so I cant get it to produce any logs. Tried to find another library but not found one yet that can handle a jks keystore. Tried to manually create a connectionmanager with TLSv1.3 explicitly enabled but I keep on running into the same issue. I know it's not clj-http as we've been and are using this for connections to other service providers without any issue. The issue started after this specific provider updated to RHEL8, things worked fine before that.
you could try another library that offers more control on the connection. for example https://github.com/gnarroway/hato
I'll have a look at it thanks. This whole project I maintain is built on using clj-http haha
Had quick look into it, seems simple enough to drop in replace. Will try this tomorrow
They likely changed their certificate.
Wish it was that simple. Received a new certificate that has the same issue. Like I explained, the certificate works fine with curl.
Same issue with hato @U04V4KLKC :melting_face:
hm... then I would blame JVM š it maintain global certificate chains somewhere
another way ā shell out to call curl %)
š¤· but at least it works š
https://github.com/babashka/babashka.curl didn't try it yet but looks promising
Hello all, I am trying to write a custom test macro, is there a way to override what the (is ) function prints out. In my case it just says actual: false
but I would like to give it more detail why it is false.
The (1) macro can print the the details, println
prints it to wrong place.
user=> (clojure.test/is false "foo")
FAIL in () (NO_SOURCE_FILE:1)
foo
expected: false
actual: false
false
user=>
user=> (doc clojure.test/testing)
-------------------------
clojure.test/testing
([string & body])
Macro
Adds a new string to the list of testing contexts. May be nested,
but must occur inside a test function (deftest).
nil
user=>
user=> (clojure.test/testing "something" (clojure.test/is false))
FAIL in () (NO_SOURCE_FILE:1)
something
expected: false
actual: false
false
user=>
That works perfect, I was actually trying to build function similar to the roughly