You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@rocketmq.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2017/08/11 14:17:00 UTC
[jira] [Commented] (ROCKETMQ-259) Too many reflection calls when
decode remoting command header
[ https://issues.apache.org/jira/browse/ROCKETMQ-259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16123400#comment-16123400 ]
ASF subversion and git services commented on ROCKETMQ-259:
----------------------------------------------------------
Commit f613c3b7dfefc1cea15d8aa22fec763995a624e7 in incubator-rocketmq's branch refs/heads/develop from [~Yukon]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=f613c3b ]
[ROCKETMQ-259]Fix too many reflection calls when decode remoting command header
> 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.0.0-incubating, 4.1.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)