Skip to content

Commit

Permalink
Fix npe when package is null. (#3557)
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjboy authored and ralf0131 committed Feb 26, 2019
1 parent ade0cd7 commit 5434ab7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions dubbo-common/src/main/java/org/apache/dubbo/common/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,18 @@ private static String getPrefixDigits(String v) {
public static String getVersion(Class<?> cls, String defaultVersion) {
try {
// find version info from MANIFEST.MF first
String version = cls.getPackage().getImplementationVersion();
if (!StringUtils.isEmpty(version)) {
return version;
}

version = cls.getPackage().getSpecificationVersion();
if (!StringUtils.isEmpty(version)) {
return version;
Package pkg = cls.getPackage();
String version = null;
if (pkg != null) {
version = pkg.getImplementationVersion();
if (!StringUtils.isEmpty(version)) {
return version;
}

version = pkg.getSpecificationVersion();
if (!StringUtils.isEmpty(version)) {
return version;
}
}

// guess version fro jar file name if nothing's found from MANIFEST.MF
Expand Down

0 comments on commit 5434ab7

Please sign in to comment.