SimpAnnotationMethodMessageHandler ignores empty marker annotations
Issue: SPR-13704
This commit is contained in:
parent
fdc14a16ee
commit
f119962378
|
@ -81,6 +81,7 @@ import org.springframework.validation.Validator;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Brian Clozel
|
||||
* @author Juergen Hoeller
|
||||
* @since 4.0
|
||||
*/
|
||||
public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHandler<SimpMessageMappingInfo>
|
||||
|
@ -364,36 +365,47 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
|
|||
|
||||
@Override
|
||||
protected SimpMessageMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
|
||||
MessageMapping typeAnnotation = AnnotationUtils.findAnnotation(handlerType, MessageMapping.class);
|
||||
MessageMapping messageAnnotation = AnnotationUtils.findAnnotation(method, MessageMapping.class);
|
||||
if (messageAnnotation != null) {
|
||||
SimpMessageMappingInfo result = createMessageMappingCondition(messageAnnotation);
|
||||
if (typeAnnotation != null) {
|
||||
result = createMessageMappingCondition(typeAnnotation).combine(result);
|
||||
MessageMapping messageAnn = AnnotationUtils.findAnnotation(method, MessageMapping.class);
|
||||
if (messageAnn != null) {
|
||||
MessageMapping typeAnn = AnnotationUtils.findAnnotation(handlerType, MessageMapping.class);
|
||||
// Only actually register it if there are destinations specified;
|
||||
// otherwise @MessageMapping is just being used as a (meta-annotation) marker.
|
||||
if (messageAnn.value().length > 0 || (typeAnn != null && typeAnn.value().length > 0)) {
|
||||
SimpMessageMappingInfo result = createMessageMappingCondition(messageAnn.value());
|
||||
if (typeAnn != null) {
|
||||
result = createMessageMappingCondition(typeAnn.value()).combine(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
SubscribeMapping subscribeAnnotation = AnnotationUtils.findAnnotation(method, SubscribeMapping.class);
|
||||
if (subscribeAnnotation != null) {
|
||||
SimpMessageMappingInfo result = createSubscribeCondition(subscribeAnnotation);
|
||||
if (typeAnnotation != null) {
|
||||
result = createMessageMappingCondition(typeAnnotation).combine(result);
|
||||
|
||||
SubscribeMapping subscribeAnn = AnnotationUtils.findAnnotation(method, SubscribeMapping.class);
|
||||
if (subscribeAnn != null) {
|
||||
MessageMapping typeAnn = AnnotationUtils.findAnnotation(handlerType, MessageMapping.class);
|
||||
// Only actually register it if there are destinations specified;
|
||||
// otherwise @SubscribeMapping is just being used as a (meta-annotation) marker.
|
||||
if (subscribeAnn.value().length > 0 || (typeAnn != null && typeAnn.value().length > 0)) {
|
||||
SimpMessageMappingInfo result = createSubscribeMappingCondition(subscribeAnn.value());
|
||||
if (typeAnn != null) {
|
||||
result = createMessageMappingCondition(typeAnn.value()).combine(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private SimpMessageMappingInfo createMessageMappingCondition(MessageMapping annotation) {
|
||||
String[] destinations = resolveEmbeddedValuesInDestinations(annotation.value());
|
||||
private SimpMessageMappingInfo createMessageMappingCondition(String[] destinations) {
|
||||
String[] resolvedDestinations = resolveEmbeddedValuesInDestinations(destinations);
|
||||
return new SimpMessageMappingInfo(SimpMessageTypeMessageCondition.MESSAGE,
|
||||
new DestinationPatternsMessageCondition(destinations, this.pathMatcher));
|
||||
new DestinationPatternsMessageCondition(resolvedDestinations, this.pathMatcher));
|
||||
}
|
||||
|
||||
private SimpMessageMappingInfo createSubscribeCondition(SubscribeMapping annotation) {
|
||||
String[] destinations = resolveEmbeddedValuesInDestinations(annotation.value());
|
||||
private SimpMessageMappingInfo createSubscribeMappingCondition(String[] destinations) {
|
||||
String[] resolvedDestinations = resolveEmbeddedValuesInDestinations(destinations);
|
||||
return new SimpMessageMappingInfo(SimpMessageTypeMessageCondition.SUBSCRIBE,
|
||||
new DestinationPatternsMessageCondition(destinations, this.pathMatcher));
|
||||
new DestinationPatternsMessageCondition(resolvedDestinations, this.pathMatcher));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue