If a payload is present but conversion returns null (meaning no
converter knows how to convert), raise a MessageConversionException
that provides information about the type we were trying to convert
to and the message itself whose headers (namely content-type) contain
crucial information required to debug the problem.
Issue: SPR-11577
When no @Payload is provided, it is equivalent to @Payload with default
attribute values. Since the default value of required=true, then
an argument that's not annotated is required.
A payload that is required will now throw an appropriate exception
regardless of if a conversion is required or not.
isEmptyPayload now takes the payload instead of the message
so that both the original payload and the converted payload, if
necessary, share the same logic.
JSR-303 validation is now consistently applied.
Issue: SPR-11577
Prior to this commit, the codebase was using a mix of log4j.xml
and log4j.properties for test-related logging configuration. This
can be an issue as log4j takes the xml variant first when looking
for a default bootstrap configuration.
In practice, some modules declaring the properties variant were
taking the xml variant configuration from another module.
The general structure of the configuration has also been
harmonized to provide a standard console output as well as an
easy way to enable trace logs for the current module.
The clientInboundChannel and clientOutboundChannel now use twice
the number of available processors by default to accomodate for some
degree of blocking in task execution on average.
In practice these settings still need to be configured explicitly in
applications but these should serve as better default values than
the default values in ThreadPoolTaskExecutor.
Issue: SPR-11450
This change exposes the WebSocketSession attributes through a message header.
The StompSubProtocolHandler adds this to incoming messages.
For now messaging handling methods can access the map via @Header, e.g.:
@Header(StompHeaderAccessor.SESSION_ATTRIBUTES) Map<String, Object> attrs) {
Issue: SPR-11566
Use a custom ConfigReader to enforce the use of SynchronousDispatcher
and no other dispatchers otherwise created by default. Avoids the
creation thread pools never to be used.
Ignore DISCONNECT messages if already disconnected. This can occur if
the client explicitly sends a DISCONNECT frame and then closes the
socket quickly. The closing of the WebSocket sessions also sends a
DISCONNECT upstream to ensure the broker is aware.
Even though Netty is a required dependency of reactor-tcp at present,
there is no hard dependency in the spring-messaging Reactor-based
implementation.
Configure explicitly use of SynchronousDispatcher instead of the one
used otherwise by default (RingBufferDispatcher). As a result TCP
optations are now scoped to Netty's threads.
Remove Environment field. It is no longer required to shut it down
since we're now using SynchronousDispatcher by default.
Replace connection.in() with connection.consume() when composing
connection handling. The former creates a Stream for further composing,
e.g. via map(), filter() but all we need is to read a message.
Provide additional constructor that aceepts a pre-configured Reactor
TcpClient instance.
Issue: SPR-11531
Add accessor for brokerAvailable in AbstractBrokerMessageHandler
Ensure brokerAvailable is set even if eventPublisher is not
Add tests BrokerMessageHandlerTests
Turn off brokerAvailable when StompBrokerRelayMessageHandler stops
Actually stop message handling when brokerAvailable=false
Improve log messages
Issue: SPR-11563
After this change if a content-length header is provided but is less
than 0 or cannot be parsed as a number, it is ignored and the body
is read sequentially, i.e. until we reach a null byte terminator.
This provides better protection against clients that may set the
content-length header in error.
Issue: SPR-11528
Fix NPE exception when closing TcpConnection
Ensure a ConnectionHandler is cleared when a TcpConnection is closed
(at the same time), logging an exception if the closing fails.
Improve error messages.
Issue: SPR-11531
Before this change CompositeMessageConverter had a ContentTypeResolver
field that was in turn set on all contained converters.
After this change that field is removed and effectively
CompositeMessageConverter is a simple container of other converters.
Each converter in turn must have been configured with a
ContentTypeResolver.
Doing so means it is less likely to have unexpected consequences when
configuring converters, the ContentTypeResolver set in the composite
converter overriding the one configured in a contained converter.
Also commit 676ce6 added default ContentTypeResolver initialization
to AbstractMessageConverter, which ensures that converters are still
straight forward to configure.
Issue: SPR-11462
Previously AbstractMessageConverter did not have a ContentTypeResolver
configured by default. However the Java config and XML namespace in
spring-messaging and spring-websocket always configured one.
This change ensures every AbstractMessageConverter is configured with an
instance of DefaultContentTypeResolver by default. This makes sense since
all the resolver does is make an attempt to find a content type to use
for matching. If it can't it returns null and it's up to the converter
to decide whether it can convert or not.
Issue: SPR-11462
AbstractMessageConverter now supports a strictContentTypeMatching mode
in which the content type of a message must be resolved to a (non-null)
value that matches one of the configured supported MIME types in order
for the converter to be used.
Issue: SPR-11463
Before this change tests on the CI server showed the following message:
Store limit is 102400 mb, whilst the data directory:
/opt/.../KahaDB only has 74810 mb of usable space
This change turns off store persistence and also explicitly sets the
limit on memory usage.
Prior to this commit, one couldn't set the virtualHost property on
StompBrokerRelayMessageHandler via JavaConfig, since
StompBrokerRelayRegistration's API didn't offer that possibility.
This commit adds a new method in StompBrokerRelayRegistration's fluent
API to set the virtualHost used by StompBrokerRelayMessageHandler.
Note: this property is already configurable via xml config.
Issue: SPR-11433
Before this change, when a client subscribed to a "user" destination
(e.g. /user/foo), actual messages received in response to that
subscription contained the server-translated, unique user destination
(e.g. /foo-user123).
This is not an issue for clients such as stomp.js since the
subscription is unique and sufficient to match subscription responses.
However, other STOMP clients do additional checks on the destination
of the subscription and the response.
This change ensures that messages sent to clients on user destionations
always contain a destination that matches the one on the original
subscription.
Issue: SPR-11423
Before this change, issues surrounding the use of @Controller's in
combination with AOP proxying, resulted in an IllegalArgumentException
when trying to invoke the controller method.
This change detects such cases proactively and reports them with a
clear recommendation to use class-based proxying when it comes to
@Controller's. This is the most optimcal approach for controllers
in many respects, also allows @MVC annotations to remain on the
class.
The documentation has also been updated to have a specific section
on @Controller's and AOP proxying providing the same advice.
Issue:SPR-11281
Headers provided to the SimpMessagingTemplate's convertAndSend methods
are now automatically moved into the "nativeHeaders" sub-map. This
ensures the headers will go out with the STOMP message and be received
by subscribers.
Issue: SPR-11387
Assertions made in callbacks invoked on separate thread were not
reaching the test framework. This fix ensures failures are detected
and cause tests to fail.
Prior to this commit, all MethodMessageHandlers tests were
implemented in a single class. Since SimpAnnotationMsgHandler
has been refactored with an abstract class, tests also
needed such a refactoring.
This commit creates test fixtures for AbstractMethodMessageHandler.
Issue: SPR-11191
Prior to this commit, several spring-messaging exceptions
had defined serialVersionUIDs. Those exception aren't
supposed to leave the system via Java serialization; also,
their deserialization is supported only against the same
version of Spring.
Issue: SPR-11339