Fork me on GitHub
#clojure
<
2022-09-02
>
jumar10:09:42

Did anyone notice a problem with Timbre when using JDK 17? I got a log with this stacktrace:

[33mtaoensso.timbre/[1;33mstacktrace[m  [32m            timbre.cljc:  944[m
                                                      [33mio.aviso.exception/[1;33mformat-exception[m  [32m          exception.clj:  641[m
                                                      [33mio.aviso.exception/[1;33mformat-exception[m  [32m          exception.clj:  643[m
                                                       [33mio.aviso.exception/[1;33mwrite-exception[m  [32m          exception.clj:  636[m
                                                     [33mio.aviso.exception/[1;33manalyze-exception[m  [32m          exception.clj:  453[m
                                                      [33mio.aviso.exception/[1;33mexpand-exception[m  [32m          exception.clj:  418[m
                                                            [33mio.aviso.exception/[1;33mmatch-keys[m  [32m          exception.clj:  101[m
                                                                      [33mclojure.core/[1;33mreduce[m  [32m               core.clj: 6886[m
                                                              [33mclojure.core.protocols/fn/[1;33mG[m  [32m          protocols.clj:   13[m
                                                                [33mclojure.core.protocols/[1;33mfn[m  [32m          protocols.clj:   75[m
                                                        [33mclojure.core.protocols/[1;33mseq-reduce[m  [32m          protocols.clj:   24[m
                                                                         [33mclojure.core/[1;33mseq[m  [32m               core.clj:  139[m
                                                                                      [37m...[m  [32m                             [m
                                                              [33mclojure.core/bean/thisfn/[1;33mfn[m  [32m         core_proxy.clj:  427[m
                                                                      [33mclojure.core/bean/[1;33mv[m  [32m         core_proxy.clj:  419[m
                                                                  [33mclojure.core/bean/fn/[1;33mfn[m  [32m         core_proxy.clj:  413[m
                                                                                      [37m...[m  [32m                             [m
                                [37mjdk.internal.reflect.Reflection.newIllegalAccessException[m  [32m        Reflection.java:  392[m
[1;31mjava.lang.IllegalAccessException[m: [3mclass clojure.core$bean$fn__7278$fn__7279 cannot access class sun.security.provider.certpath.SunCertPathBuilderException (in module java.base) because module java.base does not export sun.security.provider.certpath to unnamed module @26933859[m
It looks like it's trying to access sun.security.provider.certpath.SunCertPathBuilderException which is no longer exposed in JDK 17 (or maybe some earlier JDK versions)?

rolt12:09:22

--add-exports=java.base/sun.security.provider.certpath=ALL-UNNAMED something along those lines in jvm opts ? (or add-opens even) (i don't think it's timbre related, it looks like it's aviso pretty not being able to "datafy" the exception)

jumar17:09:08

But it's timbre using aviso, right? I'm wondering what information they are trying to get that makes it more useful than plain stacktrace..

rolt21:09:42

yes, maybe you can propose a fallback when the exception is not introspectable

skylize17:09:07

clj꞉user꞉> 
(StackTraceElement->vec (.getStackTrace (Thread/currentThread)))

; Execution error (ClassCastException) at user/eval9690 (REPL:138).
; class [Ljava.lang.StackTraceElement; cannot be cast to class java.lang.StackTraceElement ([Ljava.lang.StackTraceElement; and java.lang.StackTraceElement are in module java.base of loader 'bootstrap')
What is the difference between Ljava.lang.x and java.lang.x and can one be converted to the other?

p-himik17:09:22

It's [Ljava.lang.x; actually - the [ and ; bits are still important. https://stackoverflow.com/a/5085907/564509

p-himik17:09:14

And on how to convert - just map over all of them, assuming you need all of them:

(map StackTraceElement->vec (.getStackTrace (Thread/currentThread)))

skylize17:09:24

🙏:skin-tone-3: Makes obvious sense, once you know what it means. Of course a list of stack traces is not the same as a single stack trace.

skylize17:09:56

...err I guess I mean "stack trace elements". Ok got it now. 💡