About the issue of using the dubbo-2.5.10 boot log output version is 2.0.1,Why?
- [ ] I have searched the issues of this repository and believe that this is not a duplicate.
- [ ] I have checked the FAQ of this repository and believe that this is not a duplicate.
Environment
- Dubbo version: 2.5.10
- Operating System version: windows7
- Java version: jdk1.8
when is use dubbo-2.5.10 startup my application ,show me the log is
[DUBBO] Using select timeout of 500, dubbo version: 2.0.1, current host: 192.168.1.18
About the issue of using the dubbo-2.5.10 boot log output version is 2.0.1 but if i use dubbo of 2.6.x ,it is no problem; and when i see the MANIFEST.MF of 2.5.10 and 2.6.2,i found them:
dubbo-2.5.10 MANIFEST.MF file
Manifest-Version: 1.0
Implementation-Vendor: The Dubbo Project
Implementation-Title: Dubbo
Implementation-Version: 2.0.1
Implementation-Vendor-Id: com.alibaba
Built-By: ken.lj
Build-Jdk: 1.7.0_80
Specification-Vendor: The Dubbo Project
Specification-Title: Dubbo
Created-By: Apache Maven 3.1.1
Specification-Version: 2.0.0
Archiver-Version: Plexus Archiver
but when i see the dubbo-2.6.2 MANIFEST.MF file
Manifest-Version: 1.0
Implementation-Vendor: The Apache Software Foundation
Implementation-Title: dubbo-all
Implementation-Version: 2.6.2
Implementation-Vendor-Id: com.alibaba
Built-By: ken.lj
Build-Jdk: 1.7.0_80
Specification-Vendor: The Apache Software Foundation
Specification-Title: dubbo-all
Created-By: Apache Maven 3.5.0
Implementation-URL: https://github.com/apache/incubator-dubbo/dubbo
Specification-Version: 2.6
and the source code of com.alibaba.dubbo.common.logger.support.FailsafeLogger
package com.alibaba.dubbo.common.logger.support;
import com.alibaba.dubbo.common.Version;
import com.alibaba.dubbo.common.logger.Logger;
import com.alibaba.dubbo.common.utils.NetUtils;
public class FailsafeLogger implements Logger {
private Logger logger;
public FailsafeLogger(Logger logger) {
this.logger = logger;
}
public Logger getLogger() {
return logger;
}
public void setLogger(Logger logger) {
this.logger = logger;
}
private String appendContextMessage(String msg) {
return " [DUBBO] " + msg + ", dubbo version: " + Version.getVersion() + ", current host: " + NetUtils.getLogHost();
}
.... other code
source code of com.alibaba.dubbo.common.Version
public static String getVersion(Class<?> cls, String defaultVersion) {
try {
// 首先查找MANIFEST.MF规范中的版本号
String version = cls.getPackage().getImplementationVersion();
if (version == null || version.length() == 0) {
version = cls.getPackage().getSpecificationVersion();
}
if (version == null || version.length() == 0) {
// 如果规范中没有版本号,基于jar包名获取版本号
CodeSource codeSource = cls.getProtectionDomain().getCodeSource();
if(codeSource == null) {
logger.info("No codeSource for class " + cls.getName() + " when getVersion, use default version " + defaultVersion);
}
else {
String file = codeSource.getLocation().getFile();
if (file != null && file.length() > 0 && file.endsWith(".jar")) {
file = file.substring(0, file.length() - 4);
int i = file.lastIndexOf('/');
if (i >= 0) {
file = file.substring(i + 1);
}
i = file.indexOf("-");
if (i >= 0) {
file = file.substring(i + 1);
}
while (file.length() > 0 && ! Character.isDigit(file.charAt(0))) {
i = file.indexOf("-");
if (i >= 0) {
file = file.substring(i + 1);
} else {
break;
}
}
version = file;
}
}
}
// 返回版本号,如果为空返回缺省版本号
return version == null || version.length() == 0 ? defaultVersion : version;
} catch (Throwable e) { // 防御性容错
// 忽略异常,返回缺省版本号
logger.error("return default version, ignore exception " + e.getMessage(), e);
return defaultVersion;
}
}
why the dubbo-2.5.x boot log output 2.0.1 ,can fix it?
similar to #2174
2.0.1 and 2.0.2(will be present in 2.6.3 and 2.7.x) is the dubbo protocol version, it's useless for users, just for dubbo developers for compatibility.
This problem is only exists in 2.5.9 and 2.5.10. I suggest you upgrade to 2.6.2 or 2.6.3(coming soon).
Feel free to reopen if necessary.
dubbo协议版本从2.0.1变更为2.0.2,原因原来是这个引起。