refactor: remove parameter assertion (#1787)

pull/1791/head^2
guqing 2022-03-29 19:53:21 +08:00 committed by GitHub
parent 489ffc8418
commit a7825f3f45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.lang.NonNull;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import run.halo.app.exception.ServiceException;
import run.halo.app.utils.JsonUtils;
@ -20,7 +21,9 @@ import run.halo.app.utils.JsonUtils;
public abstract class AbstractStringCacheStore extends AbstractCacheStore<String, String> {
protected Optional<CacheWrapper<String>> jsonToCacheWrapper(String json) {
Assert.hasText(json, "json value must not be null");
if (!StringUtils.hasText(json)) {
return Optional.empty();
}
CacheWrapper<String> cacheWrapper = null;
try {
cacheWrapper = JsonUtils.jsonToObject(json, new TypeReference<>() {});