When a send timeout is detected, the WebSocket session is now closed
with a custom close status that indicates so. This allows skipping
parts of the close logic that may cause further hanging.
Issue: SPR-11450
Before this change SockJsSession implementations of WebSocketSession
used synchronization around its method implementations protecting
internal state and ensuring only a single thread is sending messages
at a time.
A WebSocketSession is generally expected to be used from one thread
at a time and now that application messages are sent through
ConcurrentWebSocketSessionDecorator, there is no concern about
application messages sent from the different threads.
While there are some remaining concerns, those can be addressed
without using the synchronized keyword. This change removes it from
the methods of all SockJS session implementations.
Issue: SPR-11450
Before this change the decorator ensured that for a specific WebSocket
session only one thread at a time can send a message. Other threads
attempting to send would have their messages buffered and each time
that occurs, a check is also made to see if the buffer limit has been
reached or the send time limit has been exceeded and if so the session
is closed.
This change adds further protection to ensure only one thread at a time
can perform the session limit checks and attempt to close the session.
Furthermore if the session has timed out and become unresponsive,
attempts to close it may block yet another thread. Taking this into
consideration this change also ensures that state associated with the
session is cleaned first before an attempt is made to close the session.
Issue: SPR-11450
Since we now wrap the WebSocketSession with a concurrent decorator, the
synchronized keyword around message sending needed to be removed.
Issue: SPR-11586
- AnnotationAttributesReadingVisitor no longer processes annotations
from the java.lang.annotation package.
- Simplified logic in AnnotationReadingVisitorUtils
getMergedAnnotationAttributes().
Issue: SPR-11574
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
Prior to this commit, configuring a custom handshakeHandler when setting
up a stomp-endpoint with SockJS would not be taken into account:
<websocket:stomp-endpoint path="/foo">
<websocket:handshake-handler ref="customHandler"/>
<websocket:sockjs/>
</websocket:stomp-endpoint>
This commit fixes this by creating and registering a
WebsocketTransportHandler (with this handshakeHandler) as a
transportHandler override for the SockJSService.
Issue: SPR-11568
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
Prior to this commit, Spring supported meta-annotation attribute
overrides in custom composed annotations with reflection-based
annotation processing but not with ASM-based annotation processing.
This commit ensures that meta-annotation attribute overrides are
supported in AnnotationMetadataReadingVisitor.getAnnotationAttributes().
Issue: SPR-11574
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
This commit sets the DB_CLOSE_ON_EXIT flag to false for embedded H2
databases loaded using H2EmbeddedDatabaseConfigurer (i.e., via Spring's
<jdbc:embedded-database /> XML namespace, EmbeddedDatabaseBuilder,
EmbeddedDatabaseFactory, and EmbeddedDatabaseFactoryBean).
Issue: SPR-11573
This commit improves the configurability of EmbeddedDatabaseBuilder by
exposing the following new configuration methods.
- setDataSourceFactory(DataSourceFactory)
- addScripts(String...)
- setScriptEncoding(String)
- setSeparator(String)
- setCommentPrefix(String)
- setBlockCommentStartDelimiter(String)
- setBlockCommentEndDelimiter(String)
- continueOnError(boolean)
- ignoreFailedDrops(boolean)
If more fine grained control over the configuration of the embedded
database is required, users are recommended to use
EmbeddedDatabaseFactory with a ResourceDatabasePopulator and forego use
of the builder.
Issue: SPR-11410
Prior to this commit, AnnotationAttributesReadingVisitor treated Class
annotation attributes as Strings instead of Classes. As a result,
look-ups for Class attributes in meta-annotations failed with an
IllegalArgumentException.
This commit fixes this issue by consistently treating Class attributes
as Classes in AnnotationAttributesReadingVisitor.
Issue: SPR-11557
In Tiles v3 integration, underscores in filenames are
intended to identify the definition locale. This behavior
is now documented in order to avoid unexpected results
with filenames like tiles_definitions.xml.
This commit also updates Tiles v2 references to Tiles v3
in the Spring reference documentation.
Issue: SPR-11491
This commit updates reference documentation in order
to specify that ServletServerContainerFactoryBean is for
server side use and WebSocketContainerFactoryBean
for client side use.
Issue: SPR-11565
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.
In ScriptUtils and related classes, SQLExceptions are now caught and
wrapped in ScriptExceptions wherever feasible.
Affected "throws" declarations have also been revised as appropriate.
Issue: SPR-11564
This commit continues the work began in SPR-9531 as follows.
- ScriptException now extends DataAccessException.
- DatabasePopulator.populate() now explicitly throws ScriptException.
- Introduced UncategorizedScriptException.
- DatabasePopulatorUtils.execute() now throws an
UncategorizedScriptException instead of a
DataAccessResourceFailureException.
Issue: SPR-11564
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
Changes made in conjunction with SPR-9531, introduced a regression with
regard to support for using a single newline character as the statement
separator within SQL scripts. Investigation of the cause of this issue
resulted in the discovery of another, similar issue: support for
multiple newlines as a statement separator has been broken for years
but has gone unnoticed until now.
The reason that both of these issues have gone unnoticed is a result of
the fact that the test suite only executes SQL script integration tests
against HSQL DB, and HSQL does not care if two statements occur on the
same line; whereas, the H2 database will throw an exception if multiple
statements are included on the same line when executing an update.
This commit addresses both of these issues and provides further
enhancements to Spring's SQL script support as follows.
- ScriptUtils now properly checks if the supplied script contains the
custom statement separator or default separator before falling back
to the 'fallback' separator (i.e., newline).
- Introduced FALLBACK_STATEMENT_SEPARATOR constant in ScriptUtils.
- ScriptUtils.readScript() no longer omits empty lines from the input
file since a statement separator string may in fact be composed of
multiple newline characters.
- Introduced overloaded variants of splitSqlScript() and
executeSqlScript() in ScriptUtils with smaller argument lists for
common use cases.
- Extracted AbstractDatabasePopulatorTests from DatabasePopulatorTests
and introduced concrete HsqlDatabasePopulatorTests and
H2DatabasePopulatorTests subclasses for testing against HSQL and H2.
- Split ScriptUtilsTests into ScriptUtilsUnitTests and
ScriptUtilsIntegrationTests for faster builds.
Issue: SPR-11560