diff --git a/hutool-http/src/main/java/org/dromara/hutool/http/client/engine/httpclient5/HttpClient5CookieStore.java b/hutool-http/src/main/java/org/dromara/hutool/http/client/engine/httpclient5/HttpClient5CookieStore.java index a4a7ca67e..f46d60af8 100644 --- a/hutool-http/src/main/java/org/dromara/hutool/http/client/engine/httpclient5/HttpClient5CookieStore.java +++ b/hutool-http/src/main/java/org/dromara/hutool/http/client/engine/httpclient5/HttpClient5CookieStore.java @@ -25,6 +25,7 @@ import org.dromara.hutool.http.client.cookie.CookieStoreSpi; import java.net.URI; import java.net.URISyntaxException; +import java.time.Instant; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -70,9 +71,21 @@ public class HttpClient5CookieStore extends SimpleWrapper implem @Override public boolean clearExpired(final Date date) { - // get时检查过期 - this.raw.getCookies(); - return true; + return clearExpired(date.toInstant()); + } + + @Override + public boolean clearExpired(final Instant date) { + boolean removeSome = false; + for (final URI uri : this.raw.getURIs()) { + for (final CookieSpi cookie : this.raw.get(uri)) { + if (cookie.isExpired(date)) { + this.raw.remove(uri, cookie); + removeSome = true; + } + } + } + return removeSome; } @Override diff --git a/hutool-json/src/test/java/org/dromara/hutool/json/JSONObjectTest.java b/hutool-json/src/test/java/org/dromara/hutool/json/JSONObjectTest.java index 44452a1ed..80f0c345c 100644 --- a/hutool-json/src/test/java/org/dromara/hutool/json/JSONObjectTest.java +++ b/hutool-json/src/test/java/org/dromara/hutool/json/JSONObjectTest.java @@ -444,10 +444,13 @@ public class JSONObjectTest { beanWithAlias.setValue1("张三"); beanWithAlias.setValue2(35); + // 测试对象字段中使用alias注解转换json后是否成功 final JSONObject jsonObject = JSONUtil.parseObj(beanWithAlias); + assertEquals("{\"name\":\"张三\",\"age\":35}", jsonObject.toString()); assertEquals("张三", jsonObject.getStr("name")); assertEquals(Integer.valueOf(35), jsonObject.getInt("age")); + // 测试json转对象时,是否使用了alias注解 final JSONObject json = JSONUtil.ofObj() .putValue("name", "张三") .putValue("age", 35);