当我将 Clojure 项目升级到 OpenJDK 17 时,我遇到了不寻常的异常。
S3 的 get-object 函数需要两个参数,我们以映射格式传递这些参数
(s3/get-object :bucket-name "bucketname" :key "filename.json")
但现在我猜这被视为四个论点。
您伪造了#'get-object,其参数计数与函数定义的参数不匹配:
提供了 4 个参数,其中有效选项为:1、2 个参数
14:15:53.243|E| #错误{
:导致无法以读者身份打开。
:通过
[{:类型 com.netflix.hystrix.exception.HystrixRuntimeException
:消息 s-clojure.component.s3-storage/s3-get-object-contents 失败,并且没有可用的后备。
:在 [com.netflix.hystrix.AbstractCommand$22 调用 AbstractCommand.java 822]}
{:类型 java.lang.IllegalArgumentException
:消息无法以读者身份打开。
:在 [clojure.java.io$fn__11641 invokeStatic io.clj 288]}]
提供了 4 个参数,其中有效选项为:1、2 个参数
发生另一个错误
|E| #error { :cause Cannot open <nil> as a Reader.
:via [{:type com.netflix.hystrix.exception.HystrixRuntimeException
:message s-clojure.component.s3-storage/s3-get-object-contents failed and no fallback available.
:at [com.netflix.hystrix.AbstractCommand$22 call AbstractCommand.java 822]} {:type java.lang.IllegalArgumentException
:message Cannot open <nil> as a Reader.
:at [clojure.java.io$fn__11641 invokeStatic io.clj 288]}]
这段代码可以在 Clojure 中使用 java 17 工作吗?
{:input-stream (java.io.ByteArrayInputStream. (.getBytes response "UTF-8"))}
看起来您遇到了这个问题:https://github.com/mcohen01/amazonica/issues/323
Amazonica 基于 Amazon v1 SDK 构建,不支持 JDK 17。
您要么需要保留 JDK 11,直到 Amazonica 迁移到 v2 SDK,要么切换到类似 https://github.com/cognitect-labs/aws-api 的版本(尽管对于后者请记住这个问题) :https://github.com/cognitect-labs/aws-api/issues/250)