This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-04
Channels
- # announcements (13)
- # beginners (51)
- # boot (3)
- # calva (10)
- # cider (20)
- # clj-kondo (55)
- # cljs-dev (60)
- # clojure (99)
- # clojure-europe (6)
- # clojure-gamedev (9)
- # clojure-italy (19)
- # clojure-nl (7)
- # clojure-spec (20)
- # clojure-uk (42)
- # clojurescript (96)
- # clojurex (37)
- # clojutre (1)
- # cursive (37)
- # data-science (2)
- # datomic (15)
- # defnpodcast (9)
- # duct (7)
- # emacs (6)
- # events (9)
- # fulcro (124)
- # jackdaw (4)
- # jobs (4)
- # leiningen (9)
- # malli (7)
- # mount (3)
- # off-topic (109)
- # other-languages (8)
- # re-frame (39)
- # reagent (4)
- # reitit (6)
- # remote-jobs (2)
- # rewrite-clj (36)
- # ring (4)
- # shadow-cljs (16)
- # spacemacs (16)
- # tools-deps (91)
- # vim (8)
- # yada (2)
Are you sure re-matches is stackoverflowing? If you are calling a function in repl there is potentially lots of other code invoked in printing the result for example
1. Unhandled java.lang.StackOverflowError
(No message)
Pattern.java: 4660 java.util.regex.Pattern$GroupHead/match
Pattern.java: 4787 java.util.regex.Pattern$Loop/match
Pattern.java: 4719 java.util.regex.Pattern$GroupTail/match
Pattern.java: 4570 java.util.regex.Pattern$BranchConn/match
Pattern.java: 3779 java.util.regex.Pattern$CharProperty/match
Pattern.java: 4606 java.util.regex.Pattern$Branch/match
Pattern.java: 4660 java.util.regex.Pattern$GroupHead/match
Pattern.java: 4787 java.util.regex.Pattern$Loop/match
...
Apparently it is a thing, on a large enough string the Java regex library will stackoverflow with certain regexs.
The easiest thing to do might be to preprocess the string, split it in to smaller strings based on some separator(if nothing else splitting by lines), and then regex the smaller strings
Could switching to instaparse and a grammar solve this? I imagine a full parser won’t be limited (as much) by the stack?
@dpsutton I know that instaparse is good for this too, but by regex is simple than that
doing preprocess the string is an option too, I´ve done it, but I have some \r\n in the middle of string that will break the rule for spliting string
and I tried the regex expression in on-line test and it worked, but this problem happen
Can I introduce my own reader conditional features in a library? like that: #?(:mylib/jdk8 old-and-busted-form :mylib/jdk11 new-hotness-form)
You can’t unless you are in control of reading the source. That is, the reader supports it, the langs do not.
There are several ways to do jdk-conditional code though - checking java system properties, or the presence of classes, etc
probably quite common issue when you start functional programming I’m trying to make my code more testable/functional and I wrote the gist (https://gist.github.com/tdantas/1daa70b780d80e51e86416eb7dcf95ac) to understand how would you guys transform the js imperative code into clojure (testable/idiomatic ) one my first approach was only using functions, my second one will be using protocols for ‘statefull’ components. is that make sense ?
I have a dependency that I wish to integrate with tools.deps, however it's an FTP only distro on a password protected server. Is there any sane way to automatically pull and add this to my classpath?
Not directly, no
If you have the jar locally, you can just use :local/root to refer to it as a dep
would this be a good candidate for clojure.tools.deps.alpha.extensions
for a person to extend tools.deps to handle FTP?
willing to consider it
one big thing is we want no creds in deps.edn files
oh i meant for a user to personally extend, not for a patch to tools.deps. it seems open is why i was wondering
it is open with the caveat that there currently is no way to get your code on the classpath when building classpaths
under clj, I mean
if using tools.deps directly, then that's up to you of course
Has anyone managed to wrap the java library Redisson
in a nice way?
I wrapped it myself, works for now.
Is there a way to specify exclusions in deps.edn dependencies?
ch.qos.logback/logback-classic {:mvn/version "1.2.3" :exclusions [org.slf4j/slf4j-api]}
as an example
cool thanks
I have a library which wraps a java library and puts it into a big tree structure. The tree structure itself can be useful to end users for some situations. How do people feel about a library using something like datascript internally and exposing a datascript db of some static data? It feels wrong to me to do that and instead i've just used regular clojure to represent the tree, and have a namespace where i turn the tree into flat maps representing the "queries" i need for easy lookup in a query namespace. This works ok but as a user I keep wanting to use the tree in new ways which either requires repeating a lot of what's in the query namespace, or putting things in the query namespace which aren't used by the library. I feel like I'm slowly implementing a more datascript-like structure anyway.
not sure if I understand your situation, but you could maybe think about exposing a thin wrapper over your java-tree-structure implementing clojure’s map abstraction
@U04VDQDDY used this approach in to expose javascript objects to clojurescript users for interop here: https://github.com/mfikes/cljs-bean/blob/master/doc/overview.md
I actually have that aspect of things working ok, that is, transforming the complex java objects to maps. I do this by using the structure of the class hierarchy. But the class hierarchy itself can be useful to expose (for example generating specs or datomic schema, things I would like to make possible but not directly include in the library). So I guess I'm wondering if this seems like a good use case for including/exposing datascript in a library, or if that's something that should be avoided? I haven't seen it done anywhere
And you just shouldn't bother wrapping that Java library,but just have people use it directly?
I say that because it sounds like you're saying there's just more and more things that the user might just want direct access to the Java structure
the thing is the java library doesn't expose the structure usefully, my library creates it from a lot of reflection. The java library uses a bunch of "data classes" which can be modelled as just clojure maps, but they use individual classes which are a pain to create. They are often nested as well. Besides this there are ~150 methods that use various arrangements of this data as ordered arguments. My wrapper basically just reflects on this data to create a tree structure, and then uses that to implement clojure.data.java calls to translate to and from the java objects and clojure maps. And this gets me at feature parity with the Java api, but I think additional features could be added with the use of the structure data. (The low hanging fruit being specs/datomic schema).
If you made the tree structure available via datascript, would that allow you to remove a lot of the Clojure API? Smaller is better, if possible.
Hum.. ya then if you do provide additional value I'd say that's good. If exposing DataScript provides even more value I'd say that's fine then. It's all going to be based on how much value you provide for the complexities or additional gotchas and dependencies that using your lib bring with it.
Anyone ever run an external API on a windows aws machine? Code works locally, but on the windows machine I'm getting the following error:
java.lang.NullPointerException: null
core.clj:151 compojure.core/routing[fn]
core.clj:2592 clojure.core/some
core.clj:2583 clojure.core/some
core.clj:151 compojure.core/routing
core.clj:148 compojure.core/routing
RestFn.java:139 clojure.lang.RestFn.applyTo
core.clj:648 clojure.core/apply
core.clj:641 clojure.core/apply
core.clj:156 compojure.core/routes[fn]
My wild guess is you are loading a resource as a file (from the filesystem) instead of as a resource (from the classpath), which works locally when the file is present, but when you package up your code and ship it off, you just ship the jar, so the file isn't on the filesystem
That isn't really based on your stacktrace there because the stacktrace is incomplete and it looks like you are using some library that is editing and omitting parts of it as well
That is the exception you would get if one of your handlers was the value nil
instead of a ring handler
If I'm writing output to *err*
I don't see it during lein test. What should I do to see that?
I would expect that to just work, but maybe something like missing flushing when printing or something. I am however increasingly out of date on how stuff works with lein
@hiredman https://github.com/borkdude/naw/blob/32a9cc263b41896ed97eea23059f8fa55d714b0a/src/naw/core.cljc#L34
if you are using pprint, definitely insert a flush afterwards, if youare using multiple threads, I think the lein runner injects a call to shutdown-agents at the end
oh, lein does its own manipulating of clojure.test/report
, so who knows if the multimethod you register that method on is even being called
https://github.com/technomancy/leiningen/blob/master/src/leiningen/test.clj#L108-L109
You can tell lein
not to monkey-patch clojure.test
via some key in project.clj
but, yeah, that's probably what's shooting you in the foot there.
breaks retest according to the docs. which I've never ever seen anyone use https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L356
In Python and Javascript, Github has a nice way of alerting you of known security vulnerabilities. Is there anything similar for Clojure? The only way I can think of to look for security patches is to manually read through changelogs of different libraries and decide which ones need to be upgraded.
It looks like Github scans https://cve.mitre.org/ for vulnerabilities in libraries
There are some java tools for this that work for java deps of Clojure
Ah okay, but I’m guessing for the Clojure libraries themselves there’s no centralized place to announce and discover security vulnerabilities I was looking at lein-nvd which looks through jars in the classpath and crosschecks the national vulnerability database
@hiredman If I run lein ring server-headless on my machine I can run a localhost curl and hit the server. When I do the same on the aws windows desktop machine, I get the null point after compojure core routing. Maybe something to do with the fact that it's an aws windows desktop machine?
running from lein vs. running from a jar file (is that how you deploy?) are different
my guess is it has nothing to do with the windows server, and your issue is something you are doing doesn't work when running from a jar
my example of a file system file vs. a resource from a classloader is an example of a difference
loading resources via the classloader will work for both, loading a file can be made to work for both, but won't without extra work so people often trip over it
working from what I have seen of your error, when you build your routes, one of the handlers you are building your routes out of is nil
not a handler
Solved by setting the :host ring arg to the IP address of the windows server
Solved by setting the :host ring arg to the IP address of the windows server
@hiredman So I have a new error that seems like it's not compiling all the dependencies I need, which probably has to do with your other comment. It works when I run the system via a main method, but not working through the handler...
@hiredman @seancorfield it turned out not to be the monkey-patch issue, but lein test loads all namespaces and I had some defmethods elsewhere (to test if my lib wraps earlier registered defmethods correctly), but I didn't anticipate the loading order of leiningen
load order :face_with_symbols_on_mouth:
aaand found a test without assertions in one of my own projects: https://twitter.com/borkdude/status/1191482400599158785
Eastwood warns about that, I am pretty sure.
At least, I implemented something in it that caught several instances like that.
Solved by setting the :host ring arg to the IP address of the windows server