Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graciously handle empty paths to by-path #555

Closed
arichiardi opened this issue Dec 28, 2016 · 6 comments
Closed

Graciously handle empty paths to by-path #555

arichiardi opened this issue Dec 28, 2016 · 6 comments

Comments

@arichiardi
Copy link
Contributor

Hi folks!

When the paths param to by-path is an empty seq, this is the 💥 I receive :

                              java.lang.Thread.run              Thread.java:  745
java.util.concurrent.ThreadPoolExecutor$Worker.run  ThreadPoolExecutor.java:  617
 java.util.concurrent.ThreadPoolExecutor.runWorker  ThreadPoolExecutor.java: 1142
               java.util.concurrent.FutureTask.run          FutureTask.java:  266
                             clojure.lang.AFn.call                 AFn.java:   18
               clojure.core/binding-conveyor-fn/fn                 core.clj: 2020
                                 boot.core/boot/fn                 core.clj: 1029
                               boot.core/run-tasks                 core.clj: 1019
              pandeiro.boot-http/eval1138/fn/fn/fn            boot_http.clj:  110
                    boot.task.built-in/fn/fn/fn/fn             built_in.clj:  416
                 boot.task.built-in/fn/fn/fn/fn/fn             built_in.clj:  419
              boot.task.built-in/fn/fn/fn/fn/fn/fn             built_in.clj:  419
                    boot.task.built-in/fn/fn/fn/fn             built_in.clj:  235
               adzerk.boot-reload/eval803/fn/fn/fn          boot_reload.clj:  187
            adzerk.boot-reload/eval803/fn/fn/fn/fn          boot_reload.clj:  188
                        adzerk.boot-reload/changed          boot_reload.clj:   29
                             boot.core/not-by-path                 core.clj: 1266
                        clojure.lang.RestFn.invoke              RestFn.java:  442
                                 boot.core/by-path                 core.clj: 1261
                        clojure.lang.RestFn.invoke              RestFn.java:  442
                          boot.core/file-filter/fn                 core.clj: 1221
                                clojure.core/apply                 core.clj:  657
                       clojure.lang.RestFn.applyTo              RestFn.java:  132
                    clojure.lang.AFn.applyToHelper                 AFn.java:  152
                        clojure.lang.RestFn.invoke              RestFn.java:  399
                       clojure.lang.AFn.throwArity                 AFn.java:  429

Potentially this involves also the other by-* and not-by-* functions. It basically happens because juxt does not like to be called in an "empty" apply this.

Should be an easy fix in file-filter 🕺

@hit023
Copy link

hit023 commented Mar 11, 2017

A possible try-catch like this:

@hit023
Copy link

hit023 commented Mar 11, 2017

Any feedback/ constructive-criticism would be great!

@arichiardi
Copy link
Contributor Author

I don't see your try catch but it is probably better to avoid passing nil on there instead of let it throw and then catch the exception. I would not call apply juxt .. at all and return nil directly there.

@DonyorM
Copy link
Contributor

DonyorM commented Apr 30, 2017

So @hit023 have you added a fix for this that you're planning to pull request, or should I see if I can give it a shot?

@hit023
Copy link

hit023 commented May 1, 2017

@DonyorM , you can go ahead with it.

DonyorM pushed a commit to DonyorM/boot that referenced this issue May 1, 2017
This modifies the file-filter function so that if the criteria seq is
empty, it simply returns an empty list.
DonyorM pushed a commit to DonyorM/boot that referenced this issue May 2, 2017
This modifies the file-filter function so that if the criteria seq is
empty, it simply returns nil.
DonyorM pushed a commit to DonyorM/boot that referenced this issue Jun 16, 2017
This modifies the file-filter function so that if the criteria seq is
empty, it throws an error.
DonyorM pushed a commit to DonyorM/boot that referenced this issue Jun 16, 2017
This modifies the file-filter function so that if the criteria seq is
empty, it throws an error.
DonyorM pushed a commit to DonyorM/boot that referenced this issue Jun 16, 2017
This modifies the file-filter function so that if the criteria seq is
empty, it throws an error.
DonyorM pushed a commit to DonyorM/boot that referenced this issue Jun 16, 2017
This modifies the file-filter function so that if the criteria seq is
empty, it throws an error.
DonyorM pushed a commit to DonyorM/boot that referenced this issue Jun 17, 2017
This modifies the file-filter function so that if the criteria seq is
empty, it throws an error.
DonyorM pushed a commit to DonyorM/boot that referenced this issue Jul 11, 2017
This modifies the file-filter function so that if the criteria seq is
empty, it throws an error.
alandipert pushed a commit that referenced this issue Jul 11, 2017
boot.core/file-filter: if the criteria seq is empty, now throws an error.
@martinklepsch
Copy link
Member

Fixed in cb923ee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants