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

Return value from (doall ...) causes getReturnValue to throw #142

Open
lgessler opened this issue Dec 7, 2021 · 0 comments
Open

Return value from (doall ...) causes getReturnValue to throw #142

lgessler opened this issue Dec 7, 2021 · 0 comments

Comments

@lgessler
Copy link

lgessler commented Dec 7, 2021

version: 0.4.3

platform: JVM 14

problem: Subcommands which return a LazySeq seem to crash because the LazySeq is treated as a deferred value by getReturnValue, and P/waitForDeferredValue attempts to deref the LazySeq, causing the crash.

clojure.lang.LazySeq cannot be cast to java.util.concurrent.Future ...
** ERROR: **
Exception: #error {
 :cause clojure.lang.LazySeq cannot be cast to java.util.concurrent.Future
 :via
 [{:type java.lang.ClassCastException
   :message clojure.lang.LazySeq cannot be cast to java.util.concurrent.Future
   :at [clojure.core$deref_future invokeStatic core.clj 2302]}]
 :trace
 [[clojure.core$deref_future invokeStatic core.clj 2302]
  [clojure.core$deref invokeStatic core.clj 2324]
  [clojure.core$deref invoke core.clj 2310]
  [cli_matic.platform$waitForDeferredValue invokeStatic platform.clj 105]
  [cli_matic.platform$waitForDeferredValue invoke platform.clj 91]
  [cli_matic.core$getReturnValue invokeStatic core.cljc 519]
  [cli_matic.core$getReturnValue invoke core.cljc 506]
  [cli_matic.core$invoke_subcmd invokeStatic core.cljc 547]
  [cli_matic.core$invoke_subcmd invoke core.cljc 525]
  [cli_matic.core$run_cmd_STAR_ invokeStatic core.cljc 589]
  [cli_matic.core$run_cmd_STAR_ invoke core.cljc 560]
  [conllu_rest.core$run_cmd invokeStatic core.clj 90]
  [conllu_rest.core$run_cmd invoke core.clj 86]
  [conllu_rest.core$start_app invokeStatic core.clj 112]
  [conllu_rest.core$start_app invoke core.clj 111]
  [conllu_rest.core$_main invokeStatic core.clj 115]
  [conllu_rest.core$_main doInvoke core.clj 114]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [conllu_rest.core main nil -1]]}

repro:

See these two files--note that in the former I am returning an :ok to work around this issue. If you remove the :ok from ingest-conllu-files and then make the call to ingest-conllu-files the last form inside ingest, the issue is triggered as the subcommand will then return the result of (doall (pmap ...))

expected behavior:

It seems like getReturnValue should never throw, so this is an unexpected behavior to me. The final form of my code ended up not needing this to work correctly anyway, since I finish the subcommand with some print statements, but I thought I'd mention this regardless.

@lgessler lgessler changed the title Return value from (doall ...) Return value from (doall ...) causes getReturnValue to throw Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant