开发者

org.apache.http.impl.cookie.BasicClientCookie not serializable?

I am quite confused... I am reading here and BasicClientCookie clearly implements Serializable per JavaDoc: http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/impl/cookie/BasicClientCookie.html

However, my simple Groovy script:

#!/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.withObjectOutpu开发者_如何学编程tStream() { oos->
    oos.writeObject(cookie)
}

outputs:

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)

I have checked and I have no other versions of HttpClient anywhere in classpath (if I take Grapes statement out it cannot find file).

Thank you! Misha Koshelev


The javadoc you linked to is for httpclient 4.1 alpha, but you are using httpclient 4.0.1.

Check the source, it confirms the Serializable interface was added in between 4.0.1 and the trunk.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜