Skip to content

Commit 5fd41d7

Browse files
beiwei30chickenlj
authored andcommitted
dubbox升级dubbo版本的兼容性问题 (#3996)
Fixes #3537
1 parent 455d29a commit 5fd41d7

File tree

1 file changed

+13
-8
lines changed
  • dubbo-common/src/main/java/org/apache/dubbo/common

1 file changed

+13
-8
lines changed

dubbo-common/src/main/java/org/apache/dubbo/common/Version.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*/
3838
public final class Version {
3939
private static final Logger logger = LoggerFactory.getLogger(Version.class);
40-
40+
4141
private static final Pattern PREFIX_DIGITS_PATTERN = Pattern.compile("^([0-9]*).*");
4242

4343
// Dubbo RPC protocol version, for compatibility, it must not be between 2.0.10 ~ 2.6.2
@@ -104,6 +104,11 @@ public static boolean isSupportResponseAttachment(String version) {
104104
return false;
105105
}
106106

107+
// 2.8.x is reserved for dubbox
108+
if (iVersion >= 2080000 && iVersion < 2090000) {
109+
return false;
110+
}
111+
107112
return iVersion >= LOWEST_VERSION_FOR_RESPONSE_ATTACHMENT;
108113
}
109114

@@ -157,19 +162,19 @@ public static String getVersion(Class<?> cls, String defaultVersion) {
157162
return version;
158163
}
159164
}
160-
165+
161166
// guess version fro jar file name if nothing's found from MANIFEST.MF
162167
CodeSource codeSource = cls.getProtectionDomain().getCodeSource();
163168
if (codeSource == null) {
164169
logger.info("No codeSource for class " + cls.getName() + " when getVersion, use default version " + defaultVersion);
165170
return defaultVersion;
166-
}
167-
171+
}
172+
168173
String file = codeSource.getLocation().getFile();
169174
if (!StringUtils.isEmpty(file) && file.endsWith(".jar")) {
170175
version = getFromFile(file);
171176
}
172-
177+
173178
// return default version if no version info is found
174179
return StringUtils.isEmpty(version) ? defaultVersion : version;
175180
} catch (Throwable e) {
@@ -185,19 +190,19 @@ public static String getVersion(Class<?> cls, String defaultVersion) {
185190
private static String getFromFile(String file) {
186191
// remove suffix ".jar": "path/to/group-module-x.y.z"
187192
file = file.substring(0, file.length() - 4);
188-
193+
189194
// remove path: "group-module-x.y.z"
190195
int i = file.lastIndexOf('/');
191196
if (i >= 0) {
192197
file = file.substring(i + 1);
193198
}
194-
199+
195200
// remove group: "module-x.y.z"
196201
i = file.indexOf("-");
197202
if (i >= 0) {
198203
file = file.substring(i + 1);
199204
}
200-
205+
201206
// remove module: "x.y.z"
202207
while (file.length() > 0 && !Character.isDigit(file.charAt(0))) {
203208
i = file.indexOf("-");

0 commit comments

Comments
 (0)