mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-20 00:24:06 +00:00
fix[protocol]: the protocol number is defined repeatedly
This commit is contained in:
@@ -682,12 +682,16 @@ public class ProtocolAnalysis {
|
||||
// 协议智能语法分析,错误的协议定义将无法启动程序并给出错误警告
|
||||
//-----------------------------------------------------------------------
|
||||
private static void initProtocolClass(short protocolId, Class<?> clazz) {
|
||||
// 协议号重复定义
|
||||
if (protocolIdMap.containsKey(clazz)) {
|
||||
throw new RunException("duplicate protocol:[{}] protocolId:[{}] and [protocolId:{}]", clazz.getSimpleName(), protocolIdMap.get(clazz), protocolId);
|
||||
}
|
||||
protocolIdMap.put(clazz, protocolId);
|
||||
protocolIdPrimitiveMap.putPrimitive(clazz.hashCode(), protocolId);
|
||||
var previous = protocolClassMap.put(protocolId, clazz);
|
||||
var previousProtocolClass = protocolClassMap.put(protocolId, clazz);
|
||||
// 协议号重复
|
||||
if (previous != null) {
|
||||
throw new RunException("[{}][{}] protocol number [protocolId:{}] is repeated", clazz.getCanonicalName(), previous.getCanonicalName(), protocolId);
|
||||
if (previousProtocolClass != null) {
|
||||
throw new RunException("[{}][{}] protocol number [protocolId:{}] is repeated", clazz.getCanonicalName(), previousProtocolClass.getCanonicalName(), protocolId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user