Fork me on GitHub

Hello all, why my re-matches is getting StackOverflow?


I have a long string with re-matches it


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


the only function I call is re-match and pass the string


well, about Repl I don´t know


is there any way to see jvm options in repl? Maybe seen the configuration about it


I´m using boot instead


Look at the stacktrack trace and see what code is on the stack


1. Unhandled java.lang.StackOverflowError
   (No message)

     4660  java.util.regex.Pattern$GroupHead/match
     4787  java.util.regex.Pattern$Loop/match
     4719  java.util.regex.Pattern$GroupTail/match
     4570  java.util.regex.Pattern$BranchConn/match
     3779  java.util.regex.Pattern$CharProperty/match
     4606  java.util.regex.Pattern$Branch/match
     4660  java.util.regex.Pattern$GroupHead/match
     4787  java.util.regex.Pattern$Loop/match


may be it´s been recursive inside it


not in recur tail mode


if I increase jvm memory


No, you need to increase the stacksize


Apparently it is a thing, on a large enough string the Java regex library will stackoverflow with certain regexs.


Do you know how to increase stacksize in boot ?


or other way to do this with regex?


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


Well ... in theory :)


I did a parser with instaparser, but it´s much more complex 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 but there is no way to activate them currently


so basically I can't 😄


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 ( 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 ?

Cas Shun12:11:48

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 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


We need a deps.edn for our deps.edn.... :)


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


you're most welcome 🙂


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:


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


I don’t know


fair enough 🙂


Maybe your wrapper isn't useful in this case


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


That might mean you have an unnecessary abstraction


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 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
                               core.clj:648 clojure.core/apply
                               core.clj:641 clojure.core/apply
                               core.clj:156 compojure.core/routes[fn]


What do mean by works locally?


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?


it works with clj test runner


how are you writing it?


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


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


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.


ah alright. what's the downside of not letting lein monkey patching ?


breaks retest according to the docs. which I've never ever seen anyone use


neat idea though


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 for vulnerabilities in libraries

👍 1

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


that is a wild guess from where people often have trouble


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


so now it works correctly with lein too

👍 2

load order :face_with_symbols_on_mouth:


aaand found a test without assertions in one of my own projects:

❤️ 1

(is (= foo) bar) is the killer


Eastwood warns about that, I am pretty sure.


At least, I implemented something in it that caught several instances like that.


Oh yes, and Eastwood has caught it for me