clojure-emacs / refactor-nrepl

nREPL middleware to support refactorings in an editor agnostic way
Eclipse Public License 1.0
257 stars 69 forks source link

Issue with clj-add-project-dependency - NullPointerException #382

Closed mukundzare closed 2 years ago

mukundzare commented 2 years ago

Expected behavior

Add missing dependency using cljr-add-project-dependency should show me a list of dependencies to add.

Actual behavior

I get an error:

Retrieving list of available libraries...
cljr--get-error-value: Error in nrepl-refactor: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "String.length()" because "s" is null
 at java.util.concurrent.FutureTask.report (FutureTask.java:122)
    java.util.concurrent.FutureTask.get (FutureTask.java:191)
    clojure.core$deref_future.invokeStatic (core.clj:2304)
    clojure.core$future_call$reify__8477.deref (core.clj:6976)
    clojure.core$deref.invokeStatic (core.clj:2324)
    clojure.core$deref.invoke (core.clj:2310)
    refactor_nrepl.artifacts$update_artifact_cache_BANG_.invokeStatic (artifacts.clj:126)
    refactor_nrepl.artifacts$update_artifact_cache_BANG_.invoke (artifacts.clj:122)
    refactor_nrepl.artifacts$artifact_list.invokeStatic (artifacts.clj:137)
    refactor_nrepl.artifacts$artifact_list.invoke (artifacts.clj:134)
    clojure.lang.Var.invoke (Var.java:384)
    refactor_nrepl.middleware$artifact_list_reply$fn__3335.invoke (middleware.clj:121)
    refactor_nrepl.ns.libspec_allowlist$with_memoized_libspec_allowlist_STAR_.invokeStatic (libspec_allowlist.clj:28)
    refactor_nrepl.ns.libspec_allowlist$with_memoized_libspec_allowlist_STAR_.invoke (libspec_allowlist.clj:26)
    refactor_nrepl.middleware$artifact_list_reply.invokeStatic (middleware.clj:121)
    refactor_nrepl.middleware$artifact_list_reply.invoke (middleware.clj:120)
    refactor_nrepl.middleware$wrap_refactor$fn__3418.invoke (middleware.clj:221)
    nrepl.middleware$wrap_conj_descriptor$fn__1221.invoke (middleware.clj:16)
    cider.nrepl$wrap_classpath$fn__3585.invoke (nrepl.clj:137)
    nrepl.middleware$wrap_conj_descriptor$fn__1221.invoke (middleware.clj:16)
    nrepl.middleware.session$session$fn__1660.invoke (session.clj:325)
    nrepl.middleware$wrap_conj_descriptor$fn__1221.invoke (middleware.clj:16)
    nrepl.server$default_handler$fn__2228.invoke (server.clj:141)
    nrepl.server$handle_STAR_.invokeStatic (server.clj:24)
    nrepl.server$handle_STAR_.invoke (server.clj:21)
    nrepl.server$handle$fn__2196.invoke (server.clj:41)
    clojure.core$binding_conveyor_fn$fn__5772.invoke (core.clj:2034)
    clojure.lang.AFn.call (AFn.java:18)
    java.util.concurrent.FutureTask.run (FutureTask.java:264)
    java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1130)
    java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:630)
    java.lang.Thread.run (Thread.java:831)
Caused by: java.lang.NullPointerException: Cannot invoke "String.length()" because "s" is null
 at java.io.StringReader.<init> (StringReader.java:50)
    refactor_nrepl.inlined_deps.datajson.v2v3v1.clojure.data.json$read_str.invokeStatic (json.clj:416)
    refactor_nrepl.inlined_deps.datajson.v2v3v1.clojure.data.json$read_str.doInvoke (json.clj:408)
    clojure.lang.RestFn.invoke (RestFn.java:439)
    refactor_nrepl.artifacts$get_mvn_artifacts_BANG_.invokeStatic (artifacts.clj:76)
    refactor_nrepl.artifacts$get_mvn_artifacts_BANG_.invoke (artifacts.clj:69)
    refactor_nrepl.artifacts$get_artifacts_from_mvn_central_BANG_$fn__5479.invoke (artifacts.clj:102)
    clojure.core$map$fn__5884.invoke (core.clj:2759)
    clojure.lang.LazySeq.sval (LazySeq.java:42)
    clojure.lang.LazySeq.seq (LazySeq.java:51)
    clojure.lang.RT.seq (RT.java:535)
    clojure.core$seq__5419.invokeStatic (core.clj:139)
    clojure.core$apply.invokeStatic (core.clj:662)
    clojure.core$mapcat.invokeStatic (core.clj:2787)
    clojure.core$mapcat.doInvoke (core.clj:2787)
    clojure.lang.RestFn.invoke (RestFn.java:423)
    refactor_nrepl.artifacts$get_artifacts_from_mvn_central_BANG_.invokeStatic (artifacts.clj:101)
    refactor_nrepl.artifacts$get_artifacts_from_mvn_central_BANG_.invoke (artifacts.clj:98)
    refactor_nrepl.artifacts$update_artifact_cache_BANG_$fn__5511.invoke (artifacts.clj:125)
    clojure.core$binding_conveyor_fn$fn__5772.invoke (core.clj:2034)
    clojure.lang.AFn.call (AFn.java:18)
    java.util.concurrent.FutureTask.run (FutureTask.java:264)
    java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1130)
    java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:630)
    java.lang.Thread.run (Thread.java:831)

Steps to reproduce the problem

Follow the steps as shown in the video here: https://www.youtube.com/watch?v=aWJPlRVZX90 . The place where the author @magnars adds a project dependency is where I am getting the error -- at mark 2:40.

Environment & Version information

clj-refactor.el version information

clj-refactor 3.5.2 (package: 20220315.2251), refactor-nrepl 3.5.2

CIDER version information

;; CIDER 1.4.0 (Kyiv), nREPL 0.9.0
;; Clojure 1.10.3, Java 16.0.1

Leiningen or Boot version

Leiningen 2.9.6

Emacs version

28.1 (Native compilation)

Operating system

Ubuntu 20.04

vemv commented 2 years ago

Hi, could you verify if this is an intermittent issue?

I think sometimes these http requests just fail, there's some retry logic but if the http endpoint is down there's not much we can do

mukundzare commented 2 years ago

@vemv, nope. It never worked I have been trying it every few hours but it just fails.

vemv commented 2 years ago

Alright! I'll have a look when I can.

vemv commented 2 years ago

I've created clj-refactor.el v3.5.4 just now. It will be available in melpa within a few hours.

It features better error handling if anything unexpected happens while fetching these deps over http. It also applies a timeout.

If it still doesn't work the issue might be deeper. But it works on my repl and in CI. There's a proxy-opts setting.

Cheers - V

mukundzare commented 2 years ago

Thank @vemv : I will check this out!