我很困惑......我在这里阅读并且BasicClientCookie 明确地实现了每个JavaDoc的Serializable: http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/impl/cookie/BasicClientCookie.html
但是,我的简单Groovy脚本:
#!/usr/bin/env groovy
@Grapes(
@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.0.1')
)
import org.apache.http.impl.cookie.BasicClientCookie
import java.io.File
def cookie=new BasicClientCookie("name","value")
println cookie instanceof Serializable
def f=new File("/tmp/test")
f.withObjectOutputStream() { oos->
oos.writeObject(cookie)
}
输出:
false
Caught: java.io.NotSerializableException: org.apache.http.impl.cookie.BasicClientCookie
at t$_run_closure1.doCall(t.groovy:12)
at t.run(t.groovy:11)
我已经检查过,我在classpath中的任何地方都没有其他版本的HttpClient(如果我拿出Grapes语句,它找不到文件)。
谢谢! Misha Koshelev