Synchronized updates of STOMP header key cache

Issue: SPR-14901
This commit is contained in:
Rossen Stoyanchev
2016-12-08 11:13:08 -05:00
parent 9b76dc2ab4
commit b3fa1b40a0
2 changed files with 47 additions and 36 deletions

View File

@@ -88,13 +88,14 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
private static final byte[] EMPTY_PAYLOAD = new byte[0];
private StompSubProtocolErrorHandler errorHandler;
private int messageSizeLimit = 64 * 1024;
private StompEncoder stompEncoder;
private StompEncoder stompEncoder = new StompEncoder();
private StompDecoder stompDecoder;
private StompDecoder stompDecoder = new StompDecoder();
private final Map<String, BufferingStompDecoder> decoders = new ConcurrentHashMap<>();
@@ -106,10 +107,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
private final Stats stats = new Stats();
public StompSubProtocolHandler() {
setEncoder(new StompEncoder());
setDecoder(new StompDecoder());
}
/**
* Configure a handler for error messages sent to clients which allows
@@ -129,24 +126,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
return this.errorHandler;
}
/**
* Configure a {@link StompEncoder} for encoding STOMP frames
* @param encoder the encoder
* @since 4.3.5
*/
public void setEncoder(StompEncoder encoder) {
this.stompEncoder = encoder;
}
/**
* Configure a {@link StompDecoder} for decoding STOMP frames
* @param decoder the decoder
* @since 4.3.5
*/
public void setDecoder(StompDecoder decoder) {
this.stompDecoder = decoder;
}
/**
* Configure the maximum size allowed for an incoming STOMP message.
* Since a STOMP message can be received in multiple WebSocket messages,
@@ -167,6 +146,24 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
return this.messageSizeLimit;
}
/**
* Configure a {@link StompEncoder} for encoding STOMP frames
* @param encoder the encoder
* @since 4.3.5
*/
public void setEncoder(StompEncoder encoder) {
this.stompEncoder = encoder;
}
/**
* Configure a {@link StompDecoder} for decoding STOMP frames
* @param decoder the decoder
* @since 4.3.5
*/
public void setDecoder(StompDecoder decoder) {
this.stompDecoder = decoder;
}
/**
* Configure a {@link MessageHeaderInitializer} to apply to the headers of all
* messages created from decoded STOMP frames and other messages sent to the