yukon created ROCKETMQ-259:
------------------------------
Summary: Too many reflection calls when decode remoting command
header
Key: ROCKETMQ-259
URL: https://issues.apache.org/jira/browse/ROCKETMQ-259
Project: Apache RocketMQ
Issue Type: Bug
Components: rocketmq-remoting
Affects Versions: 4.1.0-incubating, 4.0.0-incubating
Reporter: yukon
Assignee: yukon
Fix For: 4.2.0-incubating
Each field in a CommandCustomHeader will be checked to ensure some key fields
aren't null when decode RemotingCommand header. This process will cause a
reflection call, and current code has a cache mechanism, but it doesn't work.
{code}
Annotation annotation = getNotNullAnnotation(field);
if (annotation != null) {
throw new RemotingCommandException("the custom field <" + fieldName + "> is
null");
}
{code}
{code}
private Annotation getNotNullAnnotation(Field field) {
Annotation annotation = NOT_NULL_ANNOTATION_CACHE.get(field);
if (annotation == null) {
annotation = field.getAnnotation(CFNotNull.class); //[1]
synchronized (NOT_NULL_ANNOTATION_CACHE) {
NOT_NULL_ANNOTATION_CACHE.put(field, annotation);
}
}
return annotation;
}
{code}
[1]. If a field doesn't has CFNotNull annotation, each check will cause a
reflection call.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)