REQ-2596-修复NPE问题
This commit is contained in:
parent
af26c4bb6d
commit
7c1b5b1a48
@ -28,7 +28,7 @@ public class MultiVersionBeanUtils {
|
|||||||
throw new NullPointerException("no beans of type " + clazz.getName());
|
throw new NullPointerException("no beans of type " + clazz.getName());
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(version)) {
|
if (StringUtils.isEmpty(version)) {
|
||||||
T t = beans.values().stream().filter(bean -> bean.getVersion() == null).findFirst().orElse(null);
|
T t = beans.values().stream().filter(bean -> bean.getVersion() == null || bean.getVersion() == UNKNOWN_VERSION).findFirst().orElse(null);
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
@ -42,7 +42,8 @@ public class MultiVersionBeanUtils {
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
DefaultArtifactVersion targetVersion = new DefaultArtifactVersion(version);
|
DefaultArtifactVersion targetVersion = new DefaultArtifactVersion(version);
|
||||||
for (int i = sortedList.size() - 1; i >= 0; i--) {
|
for (int i = sortedList.size() - 1; i >= 0; i--) {
|
||||||
int flag = sortedList.get(i).getVersion().compareTo(targetVersion);
|
DefaultArtifactVersion classVersion = sortedList.get(i).getVersion() == null ? UNKNOWN_VERSION : sortedList.get(i).getVersion();
|
||||||
|
int flag = classVersion.compareTo(targetVersion);
|
||||||
if (flag <= 0) {
|
if (flag <= 0) {
|
||||||
return sortedList.get(i);
|
return sortedList.get(i);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user