我使用的是Jersey 2.25。
我尝试将connectTimeout
和readTimeout
设置为客户端,但它返回null而不是Client实例。我是通过ClientBuilder.build()
创建客户端的。
ClientBuilder builder = ClientBuilder.newBuilder();
builder.sslContext(createSSLContext());
Client client = builder.build();
client = client.property("jersey.config.client.connectTimeout", 100); //returns null
client = client.property("jersey.config.client.readTimeout", 100); //returns null
有没有理由期望property()返回null?怎么可能修好?
答案 0 :(得分:3)
您无需重新分配client
实例,只需调用从builder.build()
返回的同一实例上的方法:
Client client = builder.build();
client.property(ClientProperties.CONNECT_TIMEOUT, 100);
client.property(ClientProperties.READ_TIMEOUT, 100);
...