Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.0-incubating, 4.1.0-incubating
-
None
Description
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.
Annotation annotation = getNotNullAnnotation(field); if (annotation != null) { throw new RemotingCommandException("the custom field <" + fieldName + "> is null"); }
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; }
[1]. If a field doesn't has CFNotNull annotation, each check will cause a reflection call.