ehcache 空指针问题
上代码
public static <T> T getValue(Ehcache cache, String key, Class<T> pojoClassOfT) {
T result = null;
try {
T orig = null;
if (null != cache && cache.get(key) != null && cache.get(key).getObjectValue() != null) {
orig = (T) cache.get(key).getObjectValue();
}
if (orig == null) {
return null;
}
if (orig instanceof PmInfo) {
// 单独处理pmInfo,防止读取后修改内存对象
PmInfo pminfo = (PmInfo) orig;
result = (T) new PmInfo(pminfo);
} else {
result = (T) orig;
}
} catch (RuntimeException e) {
Assertion.assertFail(e);
}
return result;
}
标黄的部分报空指针,大侠们看下什么情况会报空