代码优化

This commit is contained in:
thinkgem
2021-11-19 13:46:20 +08:00
parent 611cd1cdc8
commit dd850c88a0
2 changed files with 7 additions and 4 deletions

View File

@@ -212,7 +212,7 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
}
}
long totalTime = System.currentTimeMillis() - beginTime;
if (totalTime > 3000){
if (totalTime > 3000 && object != null){
logger.warn(object.getClass() + " unserialize time: " + TimeUtils.formatDateAgo(totalTime));
}
return object;
@@ -255,7 +255,7 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
long beginTime = System.currentTimeMillis();
Object object = fstConfiguration.get().asObject(bytes);
long totalTime = System.currentTimeMillis() - beginTime;
if (totalTime > 3000){
if (totalTime > 3000 && object != null){
logger.warn(object.getClass() + " fst unserialize time: " + TimeUtils.formatDateAgo(totalTime));
}
return object;

View File

@@ -288,7 +288,10 @@ abstract class VFS {
// Try each implementation class until a valid one is found
VFS vfs = null;
for (int i = 0; vfs == null || !vfs.isValid(); i++) {
for (int i = 0; true; i++) {
if (!(vfs == null || !vfs.isValid())) {
break;
}
Class<? extends VFS> impl = impls.get(i);
try {
vfs = impl.getDeclaredConstructor().newInstance();
@@ -302,7 +305,7 @@ abstract class VFS {
}
}
log.debug("Using VFS adapter " + vfs.getClass().getName());
log.debug("Using VFS adapter " + vfs == null ? null : vfs.getClass().getName());
return VFS.instance = vfs;
}