Skip to content

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

@lgessler

Description

@lgessler

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions