Commit Graph

1022 Commits

Author SHA1 Message Date
Rossen Stoyanchev 61c52d64c5 Polish ConcurrentWebSocketSessionDecoratorTests 2018-08-10 16:15:21 +03:00
Kazuhiro Sera be211ceead Fix typos detected by github.com/client9/misspell 2018-08-08 12:50:46 +02:00
Juergen Hoeller 2474c48749 Polishing 2018-08-02 16:55:53 +02:00
stsypanov b5c691bdac SPR-17074 Replace pointless wrapping with Arrays.asList with iteration over array 2018-08-02 12:07:00 +02:00
Juergen Hoeller 9b671f8408 Polishing 2018-07-31 23:57:19 +02:00
Сергей Цыпанов f8340838b3 Use lambda expressions for lazy instantiation (#1911)
Issue: SPR-17074
2018-07-31 13:03:18 +02:00
Juergen Hoeller 3881a4aded Polishing 2018-07-25 14:16:02 +02:00
Sebastien Deleuze d3b244a81b Optimize class detection by sharing the ClassLoader
Issue: SPR-17083
2018-07-25 11:09:42 +02:00
Juergen Hoeller 02403f6a34 Polishing 2018-07-24 21:44:43 +02:00
Juergen Hoeller 11881ff211 Polishing 2018-07-24 18:45:52 +02:00
Rossen Stoyanchev 23c379d5c0 Order setter for DefaultSimpUserRegistry
Issue: SPR-17023
2018-07-24 12:23:13 -04:00
Rossen Stoyanchev 7500b144ae Option to preserve publish order
Issue: SPR-13989
2018-07-23 23:24:39 -04:00
Juergen Hoeller 9a43d2ec20 Revised log levels: less WARN and INFO, fine-tuned DEBUG vs TRACE
Issue: SPR-16946
2018-07-20 15:05:16 +02:00
Sebastien Deleuze 3c9049d530 Leverage Jetty BOM
Issue: SPR-17058
2018-07-18 14:49:49 +02:00
Rossen Stoyanchev 3d6e38bb43 Conditional registration of task scheduler for SockJS
Issue: SPR-16189
2018-07-11 11:10:03 -04:00
Rossen Stoyanchev 6aa6d91ea9 Remove deprecated constructors in WebSocket config
In preparation for SPR-16189.
2018-07-11 11:10:03 -04:00
Juergen Hoeller 4ff1e3e74b Consistent abstract declaration for utility classes (plus polishing)
Issue: SPR-16968
2018-07-01 02:31:20 +02:00
Phillip Webb a89e716cc7 Use tabs rather than spaces in tests
Update tests to ensure that tabs are used instead of spaces. Also
consistently apply a new line at the end of each file.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 81451aa800 Organize imports
Reorganize imports to ensure consistent ordering. This commit also
expands any `.*` static imports in favor of using fully-qualified
method references.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 5cedd0d5d4 Consistently use tabs rather than spaces
Update code that has accidentally used spaces instead of tabs.
Also remove all trailing whitespace.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 0b53c1096a Always use 'this.' when accessing fields
Ensure that `this.` is used consistently when accessing class
fields.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb eeebd51f57 Use consistent class design
Update all classes so that inner classes are always last. Also
ensure that utility classes are always final and have a private
constructor and make exceptions final whenever possible.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb c3a17dfd47 Ensure all files end with a newline
Update all files to ensure that they always end with a new line.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb e0480f75ac Fix javadoc checkstyle issues
Fix checkstyle violations for javadoc.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Brian Clozel 417354da8a Remove dependency management noise from POMs
Prior to this commit, the generated POMs for Spring Framework modules
would contain unneeded/harmful information from the Spring Framework
build:

1. The BOM imports applied to each module by the dependency
management plugin, for example for Netty or Reactor Netty.
Spring should not export that opinion to its POMs.

2. The exclusion of "org.slf4:jcl-over-slf4j" from *all* dependencies,
which made the POMs much larger than necessary and suggested to
developers that they should exclude it as well when using all those
listed dependencies. In fact, only Apache Tiles currently brings that
transitively.

This commit removes that information from the POMs.
The dependencyManagement Gradle plugin is disabled for POM generation
and we manually resolve the dependency versions during the generation
phase.
The Gradle build is streamlined to exclude "org.slf4:jcl-over-slf4j"
only when necessary.

Issue: SPR-16893
2018-06-11 15:57:54 +02:00
Sebastien Deleuze ac37b678a3 Remove JSONP support
CORS is now widely supported and should be used instead for cross-domain
requests.

Issue: SPR-16914
2018-06-08 12:15:48 +02:00
Rossen Stoyanchev 72b1d4c648 Remove explicit references to Reactor Netty version
...now that 0.8 is also listed in the Reactor bom.

Issue: SPR-16387
2018-06-06 14:35:54 -04:00
Rossen Stoyanchev a3216432b5 Polish
Issue: SPR-16387
2018-05-31 15:38:30 -04:00
Violeta Georgieva ffbc75ae47 Upgrade to Reactor Netty 0.8
Issue: SPR-16387
2018-05-31 15:37:39 -04:00
Rossen Stoyanchev fbf25c536d ChannelInterceptor default methods + deprecate adapter 2018-05-23 21:48:19 -04:00
Rossen Stoyanchev 592dc628d5 Use specific XSD types in spring-websocket.xsd
Issue: SPR-16531
2018-05-18 21:32:46 -04:00
Rossen Stoyanchev 37b0ed9fcb Improve TCP connection info logging.
After the recent changes to expose configuring TcpOperations, it no
longer makes sense to automatically log the relayHost/Port since that's
mutually exclusive with a custom TcpOperations.

Instead we delegate to TcpOperations.toString().

Issue: SPR-16801
2018-05-16 11:40:51 -04:00
Rossen Stoyanchev 020c6c0102 Polish: remove Javadoc tags from spring-websocket.xsd 2018-05-16 10:18:01 -04:00
Rossen Stoyanchev 29158aa79a Expose timeToFirstMessage in Java/XML config
Issue: SPR-16531
2018-05-16 10:03:57 -04:00
Juergen Hoeller 53aa9cc4cd Upgrade to Servlet API 4.0.1 (aligned with Tomcat 9 and Undertow 2)
Issue: SPR-16470
2018-05-07 14:17:28 +02:00
Johnny Lim fb898e1727 Remove inconsistent spaces 2018-05-05 11:07:35 +02:00
Rossen Stoyanchev 0e776d4e77 Add more detail to ISE in ServerEndpointExporter
Issue: SPR-16655
2018-04-23 17:03:09 -04:00
Rossen Stoyanchev ff2228fdaf Selector header name is exposed for configuration
Issue: SPR-16732
2018-04-16 23:56:30 -04:00
igor-suhorukov 4aae6a6dda Use Map.forEach instead of manual Map.Entry iteration wherever possible SPR-16646 2018-03-28 01:09:03 +02:00
Juergen Hoeller e3d0ef6015 Use Map.forEach instead of manual Map.Entry iteration wherever possible
Issue: SPR-16646
2018-03-27 00:38:32 +02:00
Juergen Hoeller d4a8f76bf9 Consistent volatile access to running flag in Lifecycle implementations
Issue: SPR-16488
2018-03-15 15:17:55 +01:00
igor-suhorukov 407ecf7334 to get rid of "magic" time constants 2018-03-08 20:37:48 +01:00
Juergen Hoeller 139dc1d373 Polishing (collapsed if checks, consistent downcasts, refined javadoc) 2018-03-08 18:11:57 +01:00
igor-suhorukov 0f7485b01d Polish: reorder the modifiers to comply with the Java Language Specification. 2018-03-08 17:57:47 +01:00
Juergen Hoeller cec7204fca Polishing 2018-03-02 13:53:17 +01:00
igor-suhorukov ed936cbd89 Polish: Overriding methods should do more than simply call the same method in the super class 2018-03-02 00:06:27 +01:00
Juergen Hoeller bfddbbe731 Polishing 2018-03-01 01:39:06 +01:00
igor-suhorukov 8080f56db8 Polish: "@Override" should be used on overriding and implementing methods 2018-03-01 00:15:18 +01:00
Juergen Hoeller a5cbf5fe24 Consistent use of Collection.toArray with zero-sized array argument
Includes consistent use of ClassUtils.toClassArray (as non-null variant)

Issue: SPR-16523
2018-02-22 11:29:46 +01:00
Juergen Hoeller 0de36d2883 Consistent HttpMethod identity comparisons 2018-02-18 22:01:22 +01:00
Alexander Münch 37f19a4b43 Polish Javadoc
WebSocketMessageBrokerStats's Javadoc now states the correct default
logging period.

Closes gh-1691
2018-02-18 08:57:08 +01:00
Juergen Hoeller d7cab23e6d Consistent use of StringUtils.toStringArray
(cherry picked from commit 6d11b40)
2018-02-16 20:49:17 +01:00
Juergen Hoeller b35274f5a7 WebSocket callbacks need to remain inner classes (retaining generics) 2018-02-16 10:22:05 +01:00
igor-suhorukov 2be4985b8f Polish: anonymous inner classes containing only one method should become lambdas,
use getOrDefault instead of ternary operator
2018-02-16 09:38:19 +01:00
igor-suhorukov 45e520ed86 Polish: remove unused private fields, remove empty operator 2018-02-13 23:00:18 +01:00
Juergen Hoeller 3c631f8ea0 SubProtocolWebSocketHandler closes sessions outside of lifecycle monitor
Issue: SPR-16488
2018-02-13 00:04:55 +01:00
Juergen Hoeller d00e1c5e4f Polishing 2018-02-10 21:35:46 +01:00
Juergen Hoeller 39201adca4 Consistent handling of InterruptedException
Issue: SPR-16479
2018-02-10 13:03:33 +01:00
igor-suhorukov d3a1d44864 Polish: Maps with keys that are enum values should be replaced with EnumMap 2018-02-10 12:09:33 +01:00
igor-suhorukov 9a6fbf59c5 Polish: follow name convention - make immutable fields final 2018-02-10 12:09:19 +01:00
Juergen Hoeller 5c813a366b Consistent use of @throws instead of @exception 2018-02-05 22:51:51 +01:00
Juergen Hoeller cf100d4d03 AbstractClientSockJsSession.close propagates IOException from disconnect
Issue: SPR-16415
2018-01-25 12:24:46 +01:00
Juergen Hoeller 8e2be91353 Fine-tuned logging of WebSocket close exceptions
Issue: SPR-16409
2018-01-25 12:24:40 +01:00
Juergen Hoeller 0e6f8df0a8 ServletServerHttpRequest.getURI() ignores malformed query string
The resolved URI instance is also being cached now. This should not make a difference in a real Servlet environment but does affect tests which assumed they could modify an HttpServletRequest path behind a pre-created ServletServerHttpRequest instance. Our WebSocket test base class has been revised accordingly, re-creating the ServletServerHttpRequest in such a case.

Issue: SPR-16414
2018-01-24 22:13:40 +01:00
sdeleuze 43d3abdfd5 Fix SockJs CorsConfiguration for forbidden origins
After this commit, AbstractSockJsService uses the configured allowed
origins when generating the CorsConfiguration instead of "*".

As a consequence, forbidden origin requests still result in a 403
response but now with no CORS headers in order to improve consistency
between the status code and the headers.

Issue: SPR-16304
2018-01-15 18:07:24 +01:00
Rossen Stoyanchev 61352fe85b Fix compile error 2018-01-15 10:28:12 -05:00
Rossen Stoyanchev dd09c08cdf Replace use of AbstractWebSocketMessageBrokerConfigurer 2018-01-15 10:01:14 -05:00
Sergey d6591a6329 Default methods in WebSocketMessageBrokerConfigurer
+ deprecate AbstractWebSocketMessageBrokerConfigurer
2018-01-15 09:54:55 -05:00
Juergen Hoeller 7406f5993a Polishing 2017-11-13 22:39:39 +01:00
Juergen Hoeller b5cedd43eb Consistent and efficient access to BeanDefinition argument values
Issue: SPR-16192
2017-11-13 21:51:11 +01:00
Christoph Dreis 9fab208fdd Reduce access on headers for STOMP messaging
Issue: SPR-16165
2017-11-06 20:19:00 +01:00
Juergen Hoeller 5809f5b8eb SubProtocolWebSocketHandler provides protected decorateSession method
Issue: SPR-16089
2017-10-21 23:02:54 +02:00
Rossen Stoyanchev 1cc5afe24b Fix lines over 120 characters
https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-Code-Style#line-wrapping
2017-10-20 16:42:26 -04:00
Juergen Hoeller a4537b1b6d Accessors for configured send-time and buffer-size limit
Issue: SPR-16089
2017-10-20 16:02:26 +02:00
Juergen Hoeller 16a08cb465 Upgrade to Jackson 2.9.2 2017-10-16 23:53:23 +02:00
Juergen Hoeller efce7902c4 Polishing 2017-09-27 01:34:11 +02:00
Juergen Hoeller 9190b76ab9 Latest dependency updates (POI 3.17, Rome 1.8, EhCache 3.4, Caffeine 2.5.6, RxJava 2.1.4, Tomcat 8.5.21, JRuby 9.1.13, Rhino 1.7.7.2) 2017-09-23 11:28:19 +02:00
Juergen Hoeller 7ae59d0c2a Nullability refinements on private and static methods
Based on IntelliJ IDEA 2017.3 introspection results.

Issue: SPR-15756
2017-09-22 18:22:14 +02:00
Juergen Hoeller 4cbef27f90 Consistent tolerance of unknown HTTP status codes behind RestTemplate
Issue: SPR-15978
2017-09-20 10:54:58 +02:00
Sebastien Deleuze 1bc93e3d0f Revisit nullability annotations
This commit introduces the following changes.

1) It adds a new Spring @NonNull annotation which allows to apply
@NonNullApi semantic on a specific element, like @Nullable does.
Combined with @Nullable, it allows partial null-safety support when
package granularity is too broad.

2) @Nullable and @NonNull can apply to ElementType.TYPE_USE in order
to be used on generic type arguments (SPR-15942).

3) Annotations does not apply to ElementType.TYPE_PARAMETER anymore
since it is not supported yet (applicability for such use case is
controversial and need to be discussed).

4) @NonNullApi does not apply to ElementType.FIELD anymore since in a
lot of use cases (private, protected) it is not part for the public API
+ its usage should remain opt-in. A dedicated @NonNullFields annotation
has been added in order to set fields default to non-nullable.

5) Updated Javadoc and reference documentation.

Issue: SPR-15756
2017-09-15 13:26:41 +02:00
Juergen Hoeller fd0132c7e6 Polishing 2017-09-08 16:56:22 +02:00
Brian Clozel cc3d7d2d48 Apply dependency management to selected modules
This commit applies the Dependency Management Plugin to modules that
require it; right now Spring Framework is importing BOMs for Netty and
Reactor dependencies only.

Instead of applying those BOMs to all modules, they're applied only
where they're needed.

Issue: SPR-15885
2017-08-21 14:42:03 +02:00
Brian Clozel 2eeb428e95 Move modules to independent build files
The main `build.gradle` file contains now only the common build
infrastructure; all module-specific build configurations have
been moved to their own build file.

Issue: SPR-15885
2017-08-21 14:41:55 +02:00
Sebastien Deleuze 73cf07e9a4 Fix overridden methods nullability
Issue: SPR-15869
2017-08-17 15:02:59 +02:00
Juergen Hoeller 25e6a2da64 StompSubProtocolHandler consistently accesses current user
Issue: SPR-15822
2017-07-27 11:32:32 +02:00
Rossen Stoyanchev 7e232f989b Improve check for "Broken pipe" error message
Issue: SPR-15802
2017-07-25 10:30:11 +02:00
Juergen Hoeller 46eba3dbfa Nullability fine-tuning around declaration inconsistencies
Issue: SPR-15720
Issue: SPR-15792
2017-07-19 22:22:20 +02:00
Sebastien Deleuze fb4ddb0746 Make getters and setters null-safety consistent
This commit ensure that null-safety is consistent between
getters and setters in order to be able to provide beans
with properties with a common type when type safety is
taken in account like with Kotlin.

It also add a few missing property level @Nullable
annotations.

Issue: SPR-15792
2017-07-19 09:07:56 +02:00
Juergen Hoeller 9afce23845 WebSocketSession.getUri() may return null
Issue: SPR-15721
2017-06-30 20:56:21 +02:00
Juergen Hoeller cc74a2891a @Nullable all the way: null-safety at field level
This commits extends nullability declarations to the field level, formalizing the interaction between methods and their underlying fields and therefore avoiding any nullability mismatch.

Issue: SPR-15720
2017-06-30 01:54:16 +02:00
Juergen Hoeller 7dd8dc62a5 Fixes for ignored tests after last week's nullability commit
Issue: SPR-15540
2017-06-13 11:37:58 +02:00
Stephane Nicoll fc64b8040f Polish "Replace relevant code with lambda"
Closes gh-1454
2017-06-13 09:42:20 +02:00
diguage 4b1478d830 Replace relevant code with lambda
See gh-1454
2017-06-13 08:55:38 +02:00
Juergen Hoeller 3ae84d6dd8 Consistent support for Charset/StandardCharsets in UriUtils etc
Issue: SPR-15613
2017-06-12 15:51:45 +02:00
diguage c1d44d9a34 Use the diamond syntax
Closes gh-1450
2017-06-12 09:19:06 +02:00
Juergen Hoeller f813712f5b Consistent use of @Nullable across the codebase (even for internals)
Beyond just formally declaring the current behavior, this revision actually enforces non-null behavior in selected signatures now, not tolerating null values anymore when not explicitly documented. It also changes some utility methods with historic null-in/null-out tolerance towards enforced non-null return values, making them a proper citizen in non-null assignments.

Some issues are left as to-do: in particular a thorough revision of spring-test, and a few tests with unclear failures (ignored as "TODO: NULLABLE") to be sorted out in a follow-up commit.

Issue: SPR-15540
2017-06-07 14:19:15 +02:00
Sebastien Deleuze 1f28825f9d Add more @Nullable parameters based on null usage
Issue: SPR-15540
2017-05-31 21:42:23 +02:00
Sebastien Deleuze b47d713e14 Add missing @Nullable annotations on parameters
Issue: SPR-15540
2017-05-31 16:56:08 +02:00
Sebastien Deleuze 87598f48e4 Introduce null-safety of Spring Framework API
This commit introduces 2 new @Nullable and @NonNullApi
annotations that leverage JSR 305 (dormant but available via
Findbugs jsr305 dependency and already used by libraries
like OkHttp) meta-annotations to specify explicitly
null-safety of Spring Framework parameters and return values.

In order to avoid adding too much annotations, the
default is set at package level with @NonNullApi and
@Nullable annotations are added when needed at parameter or
return value level. These annotations are intended to be used
on Spring Framework itself but also by other Spring projects.

@Nullable annotations have been introduced based on Javadoc
and search of patterns like "return null;". It is expected that
nullability of Spring Framework API will be polished with
complementary commits.

In practice, this will make the whole Spring Framework API
null-safe for Kotlin projects (when KT-10942 will be fixed)
since Kotlin will be able to leverage these annotations to
know if a parameter or a return value is nullable or not. But
this is also useful for Java developers as well since IntelliJ
IDEA, for example, also understands these annotations to
generate warnings when unsafe nullable usages are detected.

Issue: SPR-15540
2017-05-27 08:57:01 +02:00
Rossen Stoyanchev df8412bded ExceptoinWebSocketHandlerDecorator uses ERROR level
Issue: SPR-15537
2017-05-24 15:00:12 -04:00
Juergen Hoeller 9d8e9cf243 Common root cause introspection algorithm in NestedExceptionUtils
Issue: SPR-15510
2017-05-03 11:31:28 +02:00
Rossen Stoyanchev 779779de7b Refactor use of TaskScheduler in WebSocket Java config
Issue: SPR-15233
2017-04-11 17:41:41 -04:00
Rossen Stoyanchev 190408d1dc Polish 2017-04-11 15:08:39 -04:00
Rossen Stoyanchev 71852a9241 Trap exception from SockJS HeartbeatTask
Issue: SPR-15307
2017-03-16 18:02:06 -04:00
Juergen Hoeller 47c4cf7abf Drop support for Jetty 9.3 and OkHttp 2.x
Issue: SPR-15038
2017-03-06 17:54:02 +01:00
Rossen Stoyanchev 949bb55ef5 Refactor random port in spring-websocket
Remove the use of SocketUtils#findAvailableTcpPort in favor of letting
servers pick a dynamic port by specifying port 0.
2017-01-31 16:49:57 -05:00
Juergen Hoeller f84907a1fc Polishing 2017-01-31 12:00:13 +01:00
Juergen Hoeller 1b2dc3638f Revisit Assert to avoid single-arg assert methods (with refined messages)
Issue: SPR-15196
2017-01-30 22:15:55 +01:00
Rossen Stoyanchev ea67a637ae Align setup of SockJS and WebSocket integration tests
Failures in JettySockJsIntegrationTests after the upgrade to 9.4 were
hidden due to the PERFORMANCE test group but were failing on the CI
performance build with IllegalStateException inside Jetty on
"Failure find the required ServletContext attribute
org.eclipse.jetty.util.DecoratedObjectFactory".
2017-01-26 06:17:03 -05:00
Juergen Hoeller 12973ac702 Polishing 2017-01-24 00:12:53 +01:00
Juergen Hoeller f095aa20eb Polishing 2017-01-23 21:28:40 +01:00
Juergen Hoeller e94fa3f34d WebSocketSession.getExtensions consistently exposes unmodifiable/empty list
Issue: SPR-15180
2017-01-23 21:28:30 +01:00
Rossen Stoyanchev 2e414ab25a Well-known names for beans in message broker XML config
Issue: SPR-15068
2017-01-17 17:10:32 -05:00
Sam Brannen 9ed66bf2eb Clean up warnings across code base 2017-01-07 01:54:38 +01:00
Juergen Hoeller 483abfe266 Avoid explicit DecoratedObjectFactory setup in JettyRequestUpgradeStrategy
Issue: SPR-14940
(cherry picked from commit 709d4ba)
2016-12-21 09:56:13 +01:00
Juergen Hoeller 82c1c859d9 Polishing
(cherry picked from commit 9cb4de8)
2016-12-20 21:17:48 +01:00
Rossen Stoyanchev 47e141675f Minor refactoring + polish reactive WebSocket support
Rename classes not specific to Tomcat:
TomcatWebSocketSession -> StandardWebSocketSession
TomcatWebSocketHandlerAdapter -> StandardWebSocketHandlerAdapter

WebSocketSessionSupport is renamed to AbstractWebSocketSession since it
actually is a WebSocketSession and pre-implements a number of methods.

ServerEndpointRegistration is now package private (mainly for use in
upgrade strategies) and renamed to DefaultServerEndpointConfig.
2016-12-19 18:16:36 -05:00
Juergen Hoeller 7867e56494 Polishing 2016-12-19 02:00:28 +01:00
Juergen Hoeller b366e159f8 Fine-tuned handling of running state
Issue: SPR-14527
2016-12-14 21:59:49 +01:00
Rossen Stoyanchev 2191d80a31 Allow athentication at the STOMP level
This commit makes it possible for a ChannelInterceptor to override the
user header in a Spring Message that contains a STOMP CONNECT frame.

After the message is sent, the updated user header is observed and
saved to be associated with session thereafter.

Issue: SPR-14690
2016-12-13 17:59:51 -05:00
Juergen Hoeller e49813f2c4 Polishing 2016-12-12 22:49:40 +01:00
Juergen Hoeller 52799c0e3d Revised Jetty 9.3 vs 9.4 differentiation
Issue: SPR-14940
2016-12-09 15:21:31 +01:00
Brian Clozel 8d828dd16f Update websocket support for Jetty 9.3+
Due to a few changes in `WebSocketServerFactory` and `Session` API, our
`JettyRequestUpgradeStrategy` and `JettyWebSocketSession` needed to
adapt. As of 9.3.15+ and 9.4.0+, some reflection is required to support
previous versions.

Spring 5.0 supports Jetty 9.3 and 9.4.

Issue: SPR-14940
2016-12-08 21:53:28 +01:00
Rossen Stoyanchev b3fa1b40a0 Synchronized updates of STOMP header key cache
Issue: SPR-14901
2016-12-08 11:13:57 -05:00
Christoph Dreis 9b76dc2ab4 SPR-14901 Allow customization of STOMP message header encoding
Fixes SPR-14901
2016-12-08 11:13:56 -05:00
Juergen Hoeller f6fc0a86b3 Polishing
(cherry picked from commit 0028b29)
2016-12-01 20:11:47 +01:00
Rossen Stoyanchev d201a222b8 Avoid locking in WebSocket session "close" callback
When processing a "close" notification from the server make an effort
to cancel any outstanding heartbeat but avoid going as far as acquiring
the responseLock since the server itself may already hold a lock of its
own leading to a potential deadlock.

The heartbeat task is now also further protected with an isClosed()
check in case the heartbeat does not get cancelled in a concurrent
scenario.

Issue: SPR-14917
2016-11-23 20:49:24 -05:00
Christoph Dreis a929e9ccaa Implement allocation-friendly method to get user count in SimpUserRegistry
SPR-14930
2016-11-21 21:02:10 +01:00
Juergen Hoeller da63898d5f Polishing 2016-11-21 17:36:04 +01:00
Juergen Hoeller a49809b1a4 WebSocketServerSockJsSession uses dedicated disconnect lock
Issue: SPR-14917
2016-11-21 17:24:44 +01:00
Juergen Hoeller ac774cdcef Avoid deprecated Mockito methods
Issue: SPR-14880
2016-11-04 12:24:46 +01:00
Juergen Hoeller 84d3808b3b Upgrade to Mockito 2.2
Issue: SPR-14880
2016-11-03 22:53:35 +01:00
Juergen Hoeller a90e4b230f Polishing
Issue: SPR-14867
2016-11-03 14:41:41 +01:00
Rossen Stoyanchev 87e01513fd Check SockJS session type
This commits adds a validation check whether the SockJS session type
matches the transport type and rejects requests for which they
don't match.

Issue: SPR-14867
2016-11-03 09:35:30 +02:00
Juergen Hoeller 72e1f7e898 Avoid deadlock between SockJS heartbeat and XHR polling
Issue: SPR-14833
2016-10-28 23:34:19 +02:00
Juergen Hoeller 66722afda0 StompSubProtocolHandler does not insist on SimpMessageHeaderAccessor
Issue: SPR-14791
2016-10-12 17:08:05 +02:00
Juergen Hoeller cfa0f6c84b Consistent final logger fields 2016-10-04 23:00:36 +02:00
Juergen Hoeller fb7ae010c8 Avoid unnecessary generics on emptyMap/Set/List 2016-09-26 18:04:49 +02:00
Sam Brannen b521aa879f Clean up warnings related to forthcoming removals in Tomcat 9 2016-09-17 16:16:06 +02:00
Juergen Hoeller ab9fea6b8d Polishing
(cherry picked from commit 3767092)
2016-08-31 02:08:31 +02:00
Juergen Hoeller 4ef428de28 Polishing 2016-08-30 23:57:11 +02:00
Juergen Hoeller 03609c1518 Consistent comma splitting without regex overhead
Issue: SPR-14635
2016-08-30 23:56:58 +02:00
Rossen Stoyanchev 16879a2cf0 Harden synchronization around SockJS heartbeats
Create an explicit heartbeat task with an experiration flag so that
it can be cancelled reliably vs relying on the ScheduledFutureTask
cancel method which may return true even if the task is already
running.

Issue: SPR-14356
2016-08-30 09:26:15 -04:00
Rossen Stoyanchev 8b4f60b8e5 Support receipt on DISCONNECT with simple broker
Issue: SPR-14568
2016-08-29 18:31:19 -04:00
Juergen Hoeller 56b197bce1 Avoid unnecessary String concatenation in StompSubProtocolHandler
Issue: SPR-14624
2016-08-24 20:12:01 +02:00
Juergen Hoeller 59a24b406a Polishing 2016-08-10 14:20:42 +02:00
Juergen Hoeller e03dea1d64 Polishing 2016-07-26 17:15:19 +02:00
Juergen Hoeller 99be15f58b Revise encoding steps towards use of JDK Charset and StandardCharsets
Issue: SPR-14492
2016-07-19 23:43:06 +02:00
Juergen Hoeller aaac199e8b Consistently use constructor-based instantiation instead of Class.newInstance / BeanUtils.instantiate
Issue: SPR-14486
2016-07-19 19:21:06 +02:00
Juergen Hoeller a1f5fb53db Java 8 getParameterCount() instead of getParameterTypes().length
Issue: SPR-13188
2016-07-07 01:04:24 +02:00
Juergen Hoeller da9c24c41e Polishing 2016-07-06 18:11:33 +02:00
Juergen Hoeller bc2c22d51e Streamline XML namespace support towards unversioned schemas
This commit also removes support code for outdated options which were only available in older schema versions.

Issue: SPR-13499
2016-07-05 20:50:03 +02:00
Juergen Hoeller 12d373659a Upgrade to Undertow 1.4 CR3 (and Jackson 2.8 GA)
This commit also renames WebSocketIntegrationTests to WebSocketHandshakeTests.

Issue: SPR-14328
2016-07-05 20:47:53 +02:00
Sam Brannen 1391248ea6 Introduce log4j 2 for Spring's test suite
This commit adds a test runtime dependency on log4j 2 for every project
and migrates all log4j.properties files to log4j2-test.xml files.

Issue: SPR-14431
2016-07-05 19:19:09 +02:00
Stephane Nicoll 00d2606b00 Explicit type can be replaced by <>
Issue: SPR-13188
2016-07-05 17:00:34 +02:00
Juergen Hoeller b5db5d3aac Broadly remove deprecated core classes and methods
Issue: SPR-14430
2016-07-05 15:52:49 +02:00
Juergen Hoeller fb5a096ca2 Require Undertow 1.3 byte buffer pool
Issue: SPR-13495
2016-07-05 15:31:40 +02:00
Juergen Hoeller 51252ebbca Avoid defensive checks against Java 8 API (java.util.Optional etc)
This commit also fixes broken javadoc links and code references.

Issue: SPR-13188
2016-07-05 02:09:00 +02:00
Juergen Hoeller 770f0c0661 Require Undertow 1.3.5+, Tyrus 1.11+, Jetty 9.3+, Tomcat 8.5+
Issue: SPR-13495
2016-07-04 23:27:07 +02:00
Sam Brannen f7dd757593 Support WebSocket ServletServerContainerFB in the TCF
Prior to this commit, any attempt to include a bean of type
ServletServerContainerFactoryBean in the WebApplicationContext for an
integration test class annotated with @WebAppConfiguration in
conjunction the Spring TestContext Framework (TCF) would have resulted
in an IllegalStateException stating that "A ServletContext is required
to access the javax.websocket.server.ServerContainer instance."

In such scenarios, the MockServletContext was in fact present in the
WebApplicationContext; however there was no WebSocket ServerContainer
stored in the ServletContext.

This commit addresses this issue by introducing the following.

- MockServerContainer: a private mock implementation of the
  javax.websocket.server.ServerContainer interface.

- MockServerContainerContextCustomizer: a ContextCustomizer that
  instantiates a new MockServerContainer and stores it in the
  ServletContext under the attribute named
  "javax.websocket.server.ServerContainer".

- MockServerContainerContextCustomizerFactory: a
  ContextCustomizerFactory which creates a
  MockServerContainerContextCustomizer if WebSocket support is present
  in the classpath and the test class is annotated with
  @WebAppConfiguration. This factory is registered by default via the
  spring.factories mechanism.

Issue: SPR-14367
2016-06-22 22:10:16 +02:00
Sam Brannen 7f16bdaf74 Polish error messages in ServletServerContainerFactoryBean
Issue: SPR-14367
2016-06-22 19:30:23 +02:00
Rossen Stoyanchev ba885f3d0b Add heartbeat lock to SockJS server sessions
Even before this change SockJS sessions always cancelled the heartbeat
task first prior to sending messages. However when the heartbeat task
is already in progress, cancellation of it is not enough and we must
wait until the heartbeat is sent.

This commit adds a heartbeat write lock which is obtained and held
during the sending of a heartbeat. Now when sessions send a message
they still cancel the heartbeat task but if that fails they also wait
for the heartbeat write lock.

Issue: SPR-14356
2016-06-17 16:54:54 -04:00
Sam Brannen e2810904b0 Fix Javadoc formatting 2016-06-07 19:07:38 +02:00
Rossen Stoyanchev a9217d51c2 Safe InetSocketAddress init for WebSocket and SockJS
Issue: SPR-14295
2016-05-22 06:36:42 -04:00
Rossen Stoyanchev 3fb58cda8e Wrap Jetty WebSocketException
Issue: SPR-14267
2016-05-18 11:05:09 -04:00
Juergen Hoeller f83cbff543 Consistent SmartLifecycle implementations
Issue: SPR-14233
2016-05-02 13:01:44 +02:00
Brian Clozel 55dae618a6 Improve multi-valued HTTP headers support
Prior to this change, getting header values with `HttpHeaders` when
headers are multi-valued would cause issues.
For example, for a given HTTP message with headers:
    Cache-Control: public, s-maxage=50
    Cache-Control: max-age=42

Getting a `List` of all values would return <"public", "s-maxage=50">
and getting the header value would return "public, s-maxage=50".

This commit takes now into account multi-valued HTTP headers and adds
new getters/setters for "If-Match" and "If-Unmodified-Since" headers.

Note that for ETag-related headers such as "If-Match" and
"If-None-Match", a special parser has been implemented since ETag values
can contain separator characters.

Issue: SPR-14223, SPR-14228
2016-04-28 18:48:47 +02:00
Rossen Stoyanchev 8f0f5faf4d XML config properly initialize WS message broker stats
Issue: SPR-14190
2016-04-26 17:24:22 -04:00
Johnny Lim 44e652f99e Remove duplicate words
Closes gh-1039
2016-04-19 08:24:21 +02:00
Venil Noronha aafd46aeb3 Remove isOpen assertion when sending WebSocket message
Issue: SPR-14138
2016-04-18 09:46:05 -04:00
Venil Noronha 28f2f4a431 Delegate sendMessage
Issue: SPR-14139
2016-04-18 09:30:48 -04:00
Juergen Hoeller 537193a4e0 Consistent license header 2016-04-11 20:49:38 +02:00
Rossen Stoyanchev cfdb683449 Call resetRequest after writeFrame for polling sessions
Previous refactoring (fcf6ae and also 43d937) in the SockJsSession
hierarchy consolidated access to the request and response in the
base class AbstractHttpSockJsSession in order to keep synchronization
concerns there. However that also unintentionally removed the call to
resetRequest() after sending a heartbeat for any of the
PollingSockJsSession classes. In general a polling session should call
resetRequest after every frame written.

This commit brings back the writeFrame override in PollingSockJsSession
with an extra call to resetRequest().

Issue: SPR-14107
2016-04-04 19:30:05 -04:00
Juergen Hoeller 26378cd604 Polishing 2016-04-04 20:51:30 +02:00
Rossen Stoyanchev d554229981 Fix incomplete log message
Commit 48236b from 2014 introduced a logging improvement to avoid
logging each removed session per line and instead log one line at
the end with all removed sessions ids. However that list of removed
session ids wasn't populated. This commit fixes that.

Issue: SPR-14111
2016-04-04 14:01:27 -04:00
Juergen Hoeller 517ebd1d3e Consistent formatting 2016-03-24 19:22:50 +01:00
Juergen Hoeller 9af12d290e Polishing 2016-03-23 18:39:29 +01:00
Rossen Stoyanchev 183594207f Support user destinations without leading slash
Before this commit the DefaultUserDestinationResolver did not support
well broker destinations that use dot as separator with a built in
assumptions that the destinations it resolves must start with slash.

This change adds PathMatcher property that is used to determine if
an alternative path separator is in use and if so the leading slash is
left out.

Issue: SPR-14044
2016-03-15 17:50:13 -04:00
Rossen Stoyanchev 6aa216afb6 Polish SimpUserRegistry related classes
Issue: SPR-13800
2016-03-10 14:37:22 -05:00
Brian Clozel 8ca6a18dae Allow Validator config in XML websocket namespace
This commit adds a new "validator" XML attribute to the
`<websocket:message-broker/>` element. This allows configuring a
specific Validator to be used for payload validation.

Issue: SPR-13996
2016-03-10 16:35:20 +01:00
Rossen Stoyanchev 09a40b8a08 Improve close in ConcurrentWebSocketSessionDecorator
Before this commit the concurrent session wrapper mainly protected the
sending of messages. The close itself however may also cause a message
to be sent as is the case of the SockJS protocol.

This change protects the close and checks if the session has exceeded
send time or buffer limits in which case the close status is changed
to SESSION_NOT_RELIABLE (introduced in commit cbd5af3a) which in turn
signals that extra care should be exercised when closing the session.

Issue: SPR-13904
2016-02-04 17:23:16 -05:00
Rossen Stoyanchev 7ed2b8fd81 Polish WebSocket session decorator and tests 2016-02-04 17:23:16 -05:00
Rossen Stoyanchev 9e16cbda4c Polish ServletServerHttpRequest change 2016-01-20 17:50:36 -05:00
Sammy Chu 5185953f29 Avoid double encoding URI in ServletServerHttpRequest
Issue: SPR-13876
2016-01-20 17:42:40 -05:00
Juergen Hoeller cdc9bf76a9 SessionDisconnectEvent actually preserves given session user
Issue: SPR-13871
2016-01-15 17:03:17 +01:00
Juergen Hoeller d1551bdcec Polishing 2015-12-23 21:19:18 +01:00
Rossen Stoyanchev 74b77e0d74 Fix warnings 2015-12-22 16:16:51 -05:00
Rossen Stoyanchev 8656186f60 Support for public WebSocket upgrade API in Undertow
Issue: SPR-13593
2015-12-22 15:26:31 -05:00
Juergen Hoeller 0084c077bb Aligned import order 2015-12-18 00:19:40 +01:00
Sam Brannen 5b3edcd9f9 Spring Cleaning in December
- Delete unused imports
- Delete unused code
- Clean up warnings
2015-12-17 20:27:33 +01:00
Juergen Hoeller 8ce5e88c66 Require Jackson 2.6+, FreeMarker 2.3.21+, XStream 1.4.5+
Issue: SPR-13062
2015-12-17 17:14:50 +01:00
Juergen Hoeller 2fd48c92d7 Correct spring-websocket-4.2 versus spring-websocket-4.1 xsd declarations
Issue: SPR-13804
2015-12-17 17:11:44 +01:00
Stephane Nicoll 752d3c715a Initiate structure for 4.3 XSDs 2015-12-17 15:43:23 +01:00
Juergen Hoeller 753347ea98 Consistent static final logger declarations 2015-12-16 20:44:00 +01:00
Juergen Hoeller 5d454d5ea7 Polishing 2015-12-15 15:59:30 +01:00
Juergen Hoeller 21329df7e1 Polishing 2015-12-14 00:56:06 +01:00
Juergen Hoeller bdb606b8b1 Polishing 2015-12-13 23:27:05 +01:00
Juergen Hoeller 4261f34b63 Consistent and lenient HttpMethod resolution across all web modules
Issue: SPR-13776
2015-12-09 12:26:44 +01:00
Juergen Hoeller 9973694ed2 Polishing 2015-12-04 20:43:20 +01:00
Juergen Hoeller 3d1ae9c604 Efficient and consistent setAllowedOrigins collection type
Issue: SPR-13761
2015-12-04 16:21:53 +01:00
Juergen Hoeller cd4ce8727e WebSocket namespace consistently applies resolvable allowed-origins value
Issue: SPR-13760
2015-12-04 16:01:14 +01:00
Rossen Stoyanchev f5e681e6e6 lastSessionCheckTime updated after session check
Issue: SPR-13745
2015-12-02 15:07:52 -05:00
Juergen Hoeller 747863d503 Documented units for send-time limit and buffer-size limit
Issue: SPR-13753
2015-12-02 13:52:13 +01:00
Juergen Hoeller 2bf8c0bc42 Polishing 2015-11-10 23:47:46 +01:00
Rossen Stoyanchev 3e807c297d Update WebLogicRequestUpgradeStrategy for WLS 12.2.1
Issue: SPR-13234
2015-10-29 17:09:43 -04:00
Rossen Stoyanchev 5ac57e8ea6 Restore compatibility with WildFly
Issue: SPR-13619
2015-10-28 17:56:02 -04:00
Rossen Stoyanchev 2bd1daa75e Protect against RFD exploits
Issue: SPR-13548
2015-10-15 10:33:27 +02:00
Juergen Hoeller 8fbba84aca Optimized support for GlassFish 4.1.1 (Tyrus 1.9 - 1.12)
Issue: SPR-13566
2015-10-13 20:42:47 +02:00
Brian Clozel 0f70ac74cd Polish
Constructor.getParameterCount is JDK8+ only!
2015-10-13 16:15:02 +02:00
Brian Clozel b7e75c5db4 Fix websocket compatibility with Tyrus 1.9 - 1.12
As of Tyrus 1.9, `TyrusEndpointWrapper`'s constructor has a new Boolean
argument (which is mandatory).

This commit reflectively chooses the right constructor method for Tyrus
1.9+ versions.

Issue: SPR-13566
2015-10-13 16:05:57 +02:00
Juergen Hoeller b15f40472e Updated compatibility statements in RequestUpgradeStrategy javadocs 2015-10-13 13:39:24 +02:00
Brian Clozel 6b34fe3dd4 Fix undertow httpClientConnect invoke signature
Issue: SPR-13551
2015-10-08 16:23:31 +02:00
Juergen Hoeller 15b88782f7 Polishing 2015-10-07 20:06:18 +02:00
Juergen Hoeller 966f95b9b5 Revised TransportHandlingSockJsService for defensive transport checking and consistent logging
Issue: SPR-13545
2015-10-07 13:25:52 +02:00
Juergen Hoeller 1b31d39b60 Avoid hard reference to org.xnio.StreamConnection through reflection
Issue: SPR-13529
2015-10-05 20:58:36 +02:00
Juergen Hoeller 90409cbe98 Renamed Undertow10BufferSupport to UndertowXnioBufferSupport
Issue: SPR-13366
2015-09-24 20:53:12 +02:00
Juergen Hoeller 1458c7ed43 UndertowRequestUpgradeStrategy auto-adapts to Undertow 1.3's different Pool API
Issue: SPR-13494
2015-09-24 16:41:56 +02:00
Brian Clozel 0510329b54 Support Undertow 1.3.0 in UndertowXhrTransport
As of Undertow 1.3.0, several APIs have been changed: replacing Xnio's
Pool/Pooled references to Undertow's new ByteBufferPool abstraction.
This move has been made, as part of
https://issues.jboss.org/browse/UNDERTOW-522, to prepare deprecations in
the Xnio API.

This commit adds a new strategy to deal with both 1.0-1.2 and 1.3
Undertow generations.

Issue: SPR-13366
2015-09-24 16:17:20 +02:00
Sam Brannen 6a30d04d1e Ensure all 4.2 XSDs reference beans & tool XSDs from 4.2 2015-09-22 01:15:30 -04:00
Juergen Hoeller df0b26f0e6 XhrTransport implementations do not need to redeclare interface when extending from AbstractXhrTransport 2015-09-21 20:48:29 +02:00
Sebastien Deleuze 299b7766fe Allow same-origin WebSocket/SockJS requests once origin is set
Issue: SPR-13464
2015-09-21 17:08:58 +02:00
Juergen Hoeller 491adf1f2f Polishing 2015-08-27 22:04:58 +02:00
Brian Clozel 42588cb03e Prepare Undertow 1.3.0 compatibility
Xnio 3.4.0 will introduce a new source of ByteBuffers: ByteBufferPool.
Previously this feature was offered by Pooled/Pool/ByteBufferSlicePool;
those classes are now marked as deprecated.

As of 1.3.0.Beta9, Undertow still implements the following method in its
ClientConnection interface, using those deprecated types:

    Pool<ByteBuffer> getBufferPool();

This commit prepares compatibility by suppressing warnings in order to
avoid build failures in our build. Once appropriate changes are made in
Undertow, a specific implementation with new types could be introduced.

Issue: SPR-13366
2015-08-26 14:33:25 +02:00
Juergen Hoeller e05fb494f5 Polishing 2015-08-26 11:04:14 +02:00
Sam Brannen 2df3646e90 Let Jetty pick its own available port
In an attempt to make our Jetty-based integration tests more robust,
this commit discontinues use of SocketUtils for picking a random,
available port and instead lets the Jetty Server pick its own port.
2015-08-22 18:58:55 +02:00
Sam Brannen 914ba483b2 Clean up warnings in spring-websocket 2015-08-22 15:15:42 +02:00
Sam Brannen 732a655f82 Reinstate performance test group assumption in SockJS tests 2015-08-22 15:02:18 +02:00
Juergen Hoeller c685fd7c23 Polishing 2015-08-21 17:03:53 +02:00
Rossen Stoyanchev 27899abcb6 Publish events only after successful channel send
The StompSubProtcolHandler now checks the outcome of the send to the
inbound client channel. If the message was prevented from being sent,
e.g. as part of authorization, events are not published

Issue: SPR-13339
2015-08-21 10:46:54 -04:00
Sam Brannen 1d3da12204 Clean up warnings 2015-08-15 21:30:32 +02:00
Sam Brannen c572d0c469 Increase timeout in StompWebSocketIntegrationTests
... with hope of reducing the fragility of these tests on the CI server.
2015-08-15 21:30:17 +02:00
Rossen Stoyanchev 7defbfc18b Ensure concurrent WebSocketSession wrapper is used
Issue: SPR-13326
2015-08-13 08:00:24 -04:00
Rossen Stoyanchev 6e1567b4b0 Add WebSphereRequestUpgradeStrategy
Tested with Aug 2015 WAS Liberty Beta for the upcoming 8.5.5.7 release.

Issue: SPR-12367
2015-08-12 11:49:58 -04:00
Juergen Hoeller b1d6ae77e1 Polishing 2015-07-30 00:08:36 +02:00
Juergen Hoeller 965fca808a Polishing 2015-07-29 01:08:16 +02:00
Rossen Stoyanchev b7bdd724b2 Simplify use of headers for SockJsClient requests
Before this change, XhrTransport implementations had to be configured
with the headers to use for HTTP requests other than the initial
handshake.

After this change the handshake headers passed to SockJsClient by
default are used for all other HTTP requests related to the SockJS
connection (e.g. info request, xhr send/receive). A property on
SockJsClient allows restricting the headers to use for other HTTP
requests to a subset of the handshake headers.

Issue: SPR-13254
2015-07-28 14:22:33 -04:00
Rossen Stoyanchev 9f557cf930 Polish SockJS client 2015-07-28 14:22:33 -04:00
Juergen Hoeller edd6e76b9f Polishing 2015-07-21 22:58:34 +02:00
Sam Brannen 24ff4f56e1 Introduce logging in TomcatWebSocketTestServer
This commit replaces calls to System.out.println() with explicit logging.
2015-07-20 17:03:44 +02:00
Rossen Stoyanchev 05f163b37d Avoid duplicates from <websocket:decorator-factory>
Before this change <websocket:decorator-factory> decorated to
the SubProtocolWebSocketHandler RootBeanDefinition rather than
using a RuntimeBeanReference, which led to a separate instance
of SubProtocolWebSocketHandler to be created.

Issue: SPR-13190
2015-07-02 16:09:39 -04:00
Sebastien Deleuze 79c7e30832 Fix SockJsServiceTests
Issue: SPR-12422
2015-07-02 16:35:32 +02:00
Sebastien Deleuze 6c58258d11 Update AbstractSockJsService and ref doc to SockJS client 1.0.0
Issue: SPR-12422
2015-07-02 15:38:36 +02:00
Sam Brannen e8c8d2a6ad Refactor WebSocket int. tests to work w/ Jetty 9.3
Recent builds of Jetty 9.3 require that Jetty's own ServletContext
implementation be supplied to WebSocketServerFactory's init() method.
Otherwise, the Jetty server will fail to start with the exception
message: "Not running on Jetty, WebSocket support unavailable".

This commit refactors AbstractWebSocketIntegrationTests,
AbstractSockJsIntegrationTests, and all WebSocketTestServer
implementations in order to support this new requirement.

Specifically:

- WebSocketTestServer defines a new getServletContext() method;
  TomcatWebSocketTestServer, UndertowTestServer, and
  JettyWebSocketTestServer have all been updated to return the
  ServletContext created by the embedded server.

- The setup() methods in AbstractWebSocketIntegrationTests and
  AbstractSockJsIntegrationTests have been updated so that the
  WebApplicationContext is supplied the appropriate ServletContext,
  after deployConfig() has been invoked on the WebSocketTestServer but
  before the WebApplicationContext is refreshed.

Issue: SPR-13162
2015-06-24 20:16:25 +02:00
Rossen Stoyanchev 8b50750511 Fix failure in performance build
The JettySockJsIntegrationTests are enabled in the performance build
only. Following the upgrade to Jetty 9.3 where the
JettyRequestUpgradeStrategy is now Lifecycle as wel as
ServletContextAware, we need to make sure the ApplicationContext
refresh occurs after the ServletContext has been set. This change
removes the explicit .refresh() call in the test setup and instead
relies on the DispatcherServlet to do that, which ensures that the
ServletContext with which it is initialized by Jetty has been set
on the ApplicationContext before that.
2015-06-24 10:46:45 -04:00
Rossen Stoyanchev e083683f4f Update WebSocket support for Jetty 9.3
Issue: SPR-13140
2015-06-22 22:30:44 -04:00
Rossen Stoyanchev 25ff34f3c7 JettyRequestUpgradeStrategy implements Lifecycle
After this change JettyRequestUpgradeStrategy implements Lifecyle,
which is used to init and cleanup the Jetty WebSocketServerFactory.

Since a RequestUpgradeStrategy is typically created reflectively
within DefaultHandshakeHandler, the Lifecycle events are propagated
from the top, i.e. the Spring MVC HandlerMapping through the
WebSocket/SockJsHttpRequestHandler.

Issue: SPR-13140
2015-06-22 22:30:44 -04:00
Rossen Stoyanchev b6b76ad1b4 Polish WebMvcStompEndpointRegistry 2015-06-22 22:30:44 -04:00
Rossen Stoyanchev d1cc8bac5c Add config option for StompSubProtocolErrorHandler
Issue: SPR-13142
2015-06-22 22:30:44 -04:00
Juergen Hoeller 92bf32b9be Polishing 2015-05-23 20:04:48 +02:00
Juergen Hoeller e0a11f2ae7 SockJsTransportFailureException provides constructor variant without session id 2015-05-23 20:02:42 +02:00
Juergen Hoeller 05d475a275 Polishing 2015-05-22 23:50:47 +02:00
Rossen Stoyanchev c48e8708a7 Fix NPE in DefaultSimpUserRegistry 2015-05-22 13:44:09 -04:00
Rossen Stoyanchev 92bd7bba50 Restore userSessionRegistry field in StompSubProtocolHandler
This change ensures that the deprecated UserSessionRegistry is still
used if configured.
2015-05-22 13:44:09 -04:00
Juergen Hoeller b4095c3e1d Class identity comparisons wherever possible
Issue: SPR-12926
2015-05-20 14:34:16 +02:00
Stephane Nicoll cf391f5ce1 polish
Remove unused imports
2015-05-19 08:49:01 +02:00
Rossen Stoyanchev 696a010e81 Add SubProtocolErrorHandler
Issue: SPR-12732
2015-05-15 18:18:05 -04:00
Juergen Hoeller 02d28ae9ee Actual hasText assertion in SockJsFrame
Issue: SPR-13019
2015-05-13 14:54:36 +02:00
Juergen Hoeller 49c600b234 Resolved cyclic dependency between handler.invocation and handler.annotation
Issue: SPR-12696
2015-05-12 22:04:59 +02:00
Rossen Stoyanchev 281588d7bb Add SimpUserRegistry with multi-server support
This change introduces SimpUserRegistry exposing an API to access
information about connected users, their sessions, and subscriptions
with STOMP/WebSocket messaging. Provides are methods to access users
as well as a method to find subscriptions given a Matcher strategy.

The DefaultSimpUserRegistry implementation is also a
SmartApplicationListener which listesn for ApplicationContext events
when users connect, disconnect, subscribe, and unsubscribe to
destinations.

The MultiServerUserRegistry implementation is a composite that
aggregates user information from the local SimpUserRegistry as well
as snapshots of user  on remote application servers.

UserRegistryMessageHandler is used with MultiServerUserRegistry. It
broadcats user registry information through the broker and listens
for similar broadcasts from other servers. This must be enabled
explicitly when configuring the STOMP broker relay.

The existing UserSessionRegistry which was primiarly used internally
to resolve a user name to session id's has been deprecated and is no
longer used. If an application configures a custom UserSessionRegistr
still, it will be adapted accordingly to SimpUserRegistry but the
effect is rather limited (comparable to pre-existing functionality)
and will not work in multi-server scenarios.

Issue: SPR-12029
2015-05-12 15:29:12 -04:00
Brian Clozel 4b07bc39da Always set heart-beat header in STOMP CONNECTED frames
Since SPR-10954, the SimpleBrokerMessageHandler supports `heart-beats`.

Even if the STOMP spec states that the `heart-beat` header is OPTIONAL,
and if absent considered as `heart-beat: 0,0`,
some clients rely on this to be set in CONNECTED frames.

This commit adds this header information even if no task
scheduler/heart-beat have been configured.

See: https://stomp.github.io/stomp-specification-1.2.html#Heart-beating

Issue: SPR-10954
2015-05-05 16:09:42 +02:00
Sam Brannen 572cbb0821 Consistently supply test name to @Parameters 2015-05-05 14:07:00 +02:00
Sebastien Deleuze 83f269b512 Make DefaultCorsProcessor Servlet 2.5 compliant
This commit adds CORS related headers to HttpHeaders
and update DefaultCorsProcessor implementation to
use ServerHttpRequest and ServerHttpResponse instead
of HttpServletRequest and HttpServletResponse. Usage
of ServerHttpResponse allows to avoid using Servlet 3.0
specific methods in order keep CORS support Servlet 2.5
compliant.

Issue: SPR-12885
2015-05-05 09:31:41 +02:00
Rossen Stoyanchev 49e90575e9 Disable ShallowEtagHeaderFilter for HTTP streaming
Issue: SPR-12960
2015-05-04 06:08:25 -04:00
Rossen Stoyanchev 68ecb92d1f Allow "ws" and "wss" for isValidCorsOrigin checks
Issue: SPR-12956
2015-05-04 06:08:25 -04:00
Rossen Stoyanchev 222f6998e4 Add userProperties to StandardWebSocketClient
Issue: SPR-12955
2015-05-04 06:08:25 -04:00
Rossen Stoyanchev c29eae3307 Support user destinations with multiple app servers
This change adds support for broadcasting messages with unresolved
user destinations so that other servers can try to resolve it.
That enables sending messages to users who may be connected to a
different server.

Issue: SPR-11620
2015-04-17 11:55:44 -04:00
Rossen Stoyanchev a3df66931f Add path-helper attribute for websocket namespace
Issue: SPR-11771
2015-04-13 22:39:50 -04:00
Rossen Stoyanchev de9675bf5a Support heartbeat in SimpleBrokerMessageHandler
Issue: SPR-10954
2015-04-06 16:57:23 -04:00
Sebastien Deleuze b0e1e66b7f Add CORS support
This commit introduces support for CORS in Spring Framework.

Cross-origin resource sharing (CORS) is a mechanism that allows
many resources (e.g. fonts, JavaScript, etc.) on a web page to
be requested from another domain outside the domain from which
the resource originated. It is defined by the CORS W3C
recommandation (http://www.w3.org/TR/cors/).

A new annotation @CrossOrigin allows to enable CORS support
on Controller type or method level. By default all origins
("*") are allowed.

@RestController
public class SampleController {

	@CrossOrigin
	@RequestMapping("/foo")
	public String foo() {
		// ...
	}
}

Various @CrossOrigin attributes allow to customize the CORS configuration.

@RestController
public class SampleController {

	@CrossOrigin(origin = { "http://site1.com", "http://site2.com" },
				 allowedHeaders = { "header1", "header2" },
				 exposedHeaders = { "header1", "header2" },
				 method = RequestMethod.DELETE,
				 maxAge = 123, allowCredentials = "true")
	@RequestMapping(value = "/foo", method = { RequestMethod.GET, RequestMethod.POST} )
	public String foo() {
		// ...
	}
}

A CorsConfigurationSource interface can be implemented by HTTP request
handlers that want to support CORS by providing a CorsConfiguration
that will be detected at AbstractHandlerMapping level. See for
example ResourceHttpRequestHandler that implements this interface.

Global CORS configuration should be supported through ControllerAdvice
(with type level @CrossOrigin annotated class or class implementing
CorsConfigurationSource), or with XML namespace and JavaConfig
configuration, but this is not implemented yet.

Issue: SPR-9278
2015-04-02 16:12:11 +02:00
Brian Clozel 100d75da26 Fix client-library-url ignored in MVC namespace
Prior to this commit, the `client-library-url` XML attribute was not
effective in the MVC namespace, leaving the default value configured:

```xml
<websocket:sockjs client-library-url="/js/sockjs.js" />
```

This commit fixes the sockjs namespace handler and makes sure that this
attribute is configured on the `SockJsService` Bean to be created.

Issue: SPR-12874
2015-04-01 14:44:12 +02:00
Rossen Stoyanchev 73d6d30951 Add flag whether to create HTTP session
Issue: SPR-12840
2015-03-26 17:28:26 -04:00
Juergen Hoeller d23893fd25 Consistent javadoc param declarations for type variables 2015-03-25 00:44:01 +01:00
Rossen Stoyanchev e81862eed6 Allow modifying HandshakeInterceptor list
The getter in TransportHandlingSockJsService now returns a mutable
List. The immutable wrapper doesn't make sense since it's possible
anyway to modify the list by creating a new list and calling the
setter again. It's also consistent with the same field on
WebSocketHttpRequestHandler.

This is related to work for SPR-12845.
2015-03-24 18:03:15 -04:00
Rossen Stoyanchev 0c9cd4cc32 SubProtocolWebSocketHandler checks if session is open
Issue: SPR-12812
2015-03-20 17:45:27 -04:00
Rossen Stoyanchev 41e437066e Support @MessageExceptionHandler w/ @ControllerAdvice
This change adds support for global @MessageExceptionHandler methods
with STOMP over WebSocket messages. Such methods can be added to
@ControllerAdvice annotated components, much like @ExceptionHandler
methods for Spring MVC.

Issue: SPR-12696
2015-03-19 14:21:24 -04:00
Sam Brannen 8ee0e98540 Ensure WebSocketStompClientTests compiles in Gradle build as well 2015-03-17 18:47:24 +01:00
Sam Brannen 9930a8715f Clean up & suppress warnings in spring-messaging 2015-03-17 17:58:32 +01:00
Sam Brannen 03739c25d3 Ensure WebSocketStompClientTests compiles in STS 3.6.4 2015-03-17 17:46:46 +01:00
Rossen Stoyanchev d30b3eaf55 Add STOMP client
WebSocketStompClient can be used with any implementation of
org.springframework.web.socket.client.WebSocketClient, which includes
org.springframework.web.socket.sockjs.client.SockJsClient.

Reactor11TcpStompClient can be used with reactor-net and provides STOMP
over TCP. It's also possible to adapt other WebSocket and TCP client
libraries (see StompClientSupport for more details).

For example usage see WebSocketStompClientIntegrationTests.

Issue: SPR-11588
2015-03-12 21:48:29 -04:00
Juergen Hoeller 2b3409461f Polishing 2015-02-27 22:29:42 +01:00
Sebastien Deleuze 90e6304b49 Adjust log level for invalid SockJS or Websocket requests 2015-02-19 16:52:19 +01:00
Rossen Stoyanchev 917eb1de0b Ignore Pong messages in StompSubProtocolHandler
Issue: SPR-12728
2015-02-18 11:52:59 -05:00
Rossen Stoyanchev 1f990c3df6 Fix handling of empty payload Pong message on Jetty
Issue: SPR-12727
2015-02-18 11:36:22 -05:00
Sebastien Deleuze 6062e15572 Change SockJS and Websocket default allowedOrigins to same origin
This commit adds support for a same origin check that compares
Origin header to Host header. It also changes the default setting
from all origins allowed to only same origin allowed.

Issues: SPR-12697, SPR-12685
2015-02-18 09:30:15 +01:00
Rossen Stoyanchev b4fa1c24cc Pass SockJS session attributes to HandshakeHandler
Before this change the WebSocketTransportHandler passed
Collections.emptyMap as attributes to the HandshakeHandler because
it didn't matter what attributes the underlying WebSocketSession has
since it is wrapped by the SockJsSession and that's what exposed for
use everywhere.

This change has the WebSocketTransportHandler passing the attributes
from the SockJsSession instead since it's more accurate for the
underlying WebSocketSession to have access to the same map instance
and it allows the HandshakeHandler to change the attributes even if
it doesn't need to do that today.

Issue: SPR-12716
2015-02-16 14:12:12 -05:00
Stephane Nicoll f0fca890bb Annotation-based event listeners
Add support for annotation-based event listeners. Enabled automatically
when using Java configuration or can be enabled explicitly via the
regular <context:annotation-driven/> XML element. Detect methods of
managed beans annotated with @EventListener, either directly or through
a meta-annotation.

Annotated methods must define the event type they listen to as a single
parameter argument. Events are automatically filtered out according to
the method signature. When additional runtime filtering is required, one
can specify the `condition` attribute of the annotation that defines a
SpEL expression that should match to actually invoke the method for a
particular event. The root context exposes the actual `event`
(`#root.event`) and method arguments (`#root.args`). Individual method
arguments are also exposed via either the `a` or `p` alias (`#a0` refers
to the first method argument). Finally, methods arguments are exposed via
their names if that information can be discovered.

Events can be either an ApplicationEvent or any arbitrary payload. Such
payload is wrapped automatically in a PayloadApplicationEvent and managed
explicitly internally. As a result, users can now publish and listen
for arbitrary objects.

If an annotated method has a return value, an non null result is actually
published as a new event, something like:

@EventListener
public FooEvent handle(BarEvent event) { ... }

Events can be handled in an aynchronous manner by adding `@Async` to the
event method declaration and enabling such infrastructure. Events can
also be ordered by adding an `@Order` annotation to the event method.

Issue: SPR-11622
2015-02-10 09:13:02 +01:00
Sebastien Deleuze 9b3319b3b3 Fix SockJS origin check
This commit introduces the following changes:
 - Requests without Origin header are not rejected anymore
 - Disable Iframe when allowedOrigins is not empty and not equals to *
 - The Iframe is not cached anymore in order to have a reliable origin check
 - allowedOrigins must not be null or empty
 - allowedOrigins format is now validated (should be * or start by http(s)://)

Issue: SPR-12660
2015-02-09 11:56:51 +01:00
Ralph Schaer e0d407dad0 Fix javadoc 2015-02-03 10:41:56 -05:00
Rossen Stoyanchev 52b8f34468 Add JdkIdGenerator and use it in SockJS client
Issue: SPR-12658
2015-01-22 21:27:36 -05:00
Rossen Stoyanchev ab629a0e26 Deprecate writePrelude in AbstractHttpSockJsSession
A logical follow-up on commit 43d937, this change also removes (or
rather deprecates for now) writePrelude that is only of concern to
streaming SockJS session implementations.

Issue: SPR-12427
2015-01-13 10:26:59 -05:00
Rossen Stoyanchev 43d93712f1 Remove isStreaming flag from AbstractHttpSockJsSession
This change removes the need for the isStreaming field from the base
class AbstractHttpSockJsSession. This field was used to account for
differences between polling vs streaming SockJS sessions without having
to expose to sub-classes private fields that are otherwise protected
from concurrent access by the base class. The change manages to delegate
to sub-classes without providing direct access to protected fields.

Issue: SPR-12427
2015-01-12 14:48:09 -05:00
Rossen Stoyanchev 8a47c181f7 Assign Jetty SockJS tests to "performance" test group
This change designates Jetty SockJS integration tests to run as part of
the "performance", but not the main "publication", CI build due to
recurring low-level failures suspected to be Jetty issues, e.g.
"java.io.IOException: Cannot append to finished buffer" or
"java.io.IOException: Out of order Continuation frame encountered".

The tests will still run at once a day with the performance build but
should not fail the main build with false negatives. Also note that
an Undertow variant of the exact same tests, which hasn't been failing,
will continue to run as part of the main build.
2015-01-06 09:43:54 -05:00
Rossen Stoyanchev 51367dec05 Refine condition to send WebSocket binary messages
The following two refinements have been added:
1) SockJS doesn't support binary messages so don't even try
2) don't bother if payload.length == 0

Issue: SPR-12475
2014-12-29 15:13:09 -05:00
Rossen Stoyanchev 670974d76a Allow sending binary messages with STOMP
After this change the StompSubProtocolHandler sends STOMP frames
with content-type=octet-stream as a binary WebSocket message.

Issue: SPR-12475
2014-12-23 14:24:43 -05:00
Rossen Stoyanchev b796c1e87e Synchronize message sending
Issue: SPR-12516
2014-12-07 16:10:40 -05:00
Sebastien Deleuze 2fccf3ff44 Add support for autowiring Jackson handlers
This commit introduces the SpringHandlerInstantiator
class, a Jackson HandlerInstantiator that allows to autowire
Jackson handlers (JsonSerializer, JsonDeserializer, KeyDeserializer,
TypeResolverBuilder and TypeIdResolver) if needed.

SpringHandlerInstantiator is automatically used with
@EnableWebMvc and <mvc:annotation-driven />.

Issue: SPR-10768
2014-12-05 17:37:28 +01:00
Sebastien Deleuze fbd85925de Use Jackson improved default configuration everywhere
With this commit, Jackson builder is now used in spring-websocket
to create the ObjectMapper instance.

It is not possible to use the builder for spring-messaging
and spring-jms since these modules don't have a dependency on
spring-web, thus they now just customize the same features:
 - MapperFeature#DEFAULT_VIEW_INCLUSION is disabled
 - DeserializationFeature#FAIL_ON_UNKNOWN_PROPERTIES is disabled

Issue: SPR-12293
2014-12-03 09:49:41 +01:00
Rossen Stoyanchev dc5b5ca8ee Check the user of a SockJS request
Issue: SPR-12497
2014-12-02 12:13:35 -05:00
Juergen Hoeller e6d7af4ea8 Polishing 2014-11-28 17:36:58 +01:00
Juergen Hoeller 0caeffcd54 Polishing
(cherry picked from commit 7e07f3d)
2014-11-27 18:57:57 +01:00
Brian Clozel bb150c47cf Add undertow 1.1.0.Final support
Upgrade undertow dependency to 1.1.0.Final.
Add support for undertow 1.1.0.Final in the
UndertowRequestUpgradeStrategy, after a breaking change in the
`io.undertow.websockets.jsr.ConfiguredServerEndpoint` constructor.

Issue: SPR-12302
2014-11-24 14:22:10 +01:00
Juergen Hoeller 05bdc2cf77 Consistent declaration and use of UTF-8 Charset constants, plus related polishing 2014-11-11 02:38:30 +01:00
Juergen Hoeller 9ff8a01f29 Polishing 2014-11-07 17:14:50 +01:00
Brian Clozel 1fff631daa Fix SubProtocolHandler duplicate registration
Prior to this change, duplicate SubProtocolHandlers could be registered
when configuring STOMP with several registrations:

    public void registerStompEndpoints
          (final StompEndpointRegistry registry) {
      this.endpointRegistry.addEndpoint("/stompOverWebSocket");
      this.endpointRegistry.addEndpoint("/stompOverSockJS").withSockJS();
    }

This commit registers sub-protocols in a Set instead of a list (see
SubProtocolWebSocketHandler), thus fixing the issue.

Issue: SPR-12403
2014-11-03 14:25:27 +01:00
Sam Brannen 14f4d34fdb Clean up warnings in spring-websocket 2014-11-01 16:11:57 +01:00
Juergen Hoeller 1146d5ba1d Polishing 2014-10-29 22:44:59 +01:00
Rossen Stoyanchev 38ef6dec50 Fix test issue with Set iteration order 2014-10-29 17:23:04 -04:00
Rossen Stoyanchev 8f21c85511 Explicitly close Spring context in WS integration test 2014-10-28 22:10:49 -04:00
Rossen Stoyanchev 8c727be4e1 Close Spring context in SockJS integration test setup 2014-10-28 17:51:15 -04:00
Rossen Stoyanchev 70e6e3bb39 Fix condition check in SockJsClient lifecycle method 2014-10-28 17:51:15 -04:00
Rossen Stoyanchev da612d079f Replace "if(" with "if (" 2014-10-27 09:04:23 -04:00
Sebastien Deleuze 6592784ef4 Fix a package tangle between SockJS support and transport packages
Issue: SPR-12379
2014-10-27 13:28:01 +01:00
Sebastien Deleuze 58f4014b17 Add an option to disable automatic addition of CORS header
Issues: SPR-12283
2014-10-26 21:20:53 +01:00
Sebastien Deleuze 743356fa21 Add an option to set an Origin whitelist for Websocket and SockJS
This commit introduces a new OriginHandshakeInterceptor. It filters
Origin header value against a list of allowed origins.

AbstractSockJsService as been modified to:
 - Reject CORS requests with forbidden origins
 - Disable transport types that does not support CORS when an origin
   check is required
 - Use the Origin request header value instead of "*" for
   Access-Control-Allow-Origin response header value
   (mandatory when  Access-Control-Allow-Credentials=true)
 - Return CORS header only if the request contains an Origin header

It is possible to configure easily this behavior thanks to JavaConfig API
WebSocketHandlerRegistration#addAllowedOrigins(String...) and
StompWebSocketEndpointRegistration#addAllowedOrigins(String...).
It is also possible to configure it using the websocket XML namespace.

Please notice that this commit does not change the default behavior:
cross origin requests are still enabled by default.

Issues: SPR-12226
2014-10-26 21:18:04 +01:00
Rossen Stoyanchev 01aa64c534 Simple broker sends notice after disconnect
Before this change the simple broker simply removed subscriptions
upon receiving a DISCONNECT message assuming it was a result of
a client STOMP WebSocket session ending.

However, if the server-side application sends a DISCONNECT to
the broker in order to terminate a session, the STOMP WebSocket
session could remain unware without any further action. This
change ensures the simple broker sends a DISCONNECT_ACK message
downstream whenever it receives a DISCONNECT.

Issue: SPR-12288
2014-10-24 09:48:18 -04:00
Rossen Stoyanchev 687955a704 Add ImmutableMessageChannelInterceptor
This change adds a ChannelInterceptor that flips the immutable flag on
messages being sent. This allows components sending messages to leave
the message mutable for interceptors to further apply modifications
before the message is sent (and exposed to concurrency).

The interceptor is automatically added with the STOMP/WebSocket Java
and XML config and the StompSubProtocolHandler leaves parsed incoming
messages mutable so they can be further modified before being sent.

Issue: SPR-12321
2014-10-23 15:25:51 -04:00
Juergen Hoeller 3106905877 Polishing 2014-10-22 01:19:14 +02:00
Juergen Hoeller 8325b10080 Consistent formatting of license headers, package javadocs, and import declarations 2014-10-21 01:44:07 +02:00
Juergen Hoeller b6fdcffc94 HttpSessionHandshakeInterceptor and related web.socket.server polishing
Issue: SPR-12352
2014-10-20 23:32:46 +02:00
Juergen Hoeller 77a62ec8b8 Polishing 2014-10-20 17:42:18 +02:00
Juergen Hoeller 10328f1c22 Reimplemented ServerEndpointExporter to avoid BeanPostProcessor role
Issue: SPR-12340
2014-10-20 17:41:14 +02:00
Rossen Stoyanchev 3056301015 Improve HttpSessionHandshakeInterceptor
Use explicit flag whether to copy all attributes.
2014-10-14 09:29:06 -04:00
Sam Brannen 2f54b273a5 Delete unused imports in spring-websocket module 2014-10-13 20:37:08 +02:00
Rossen Stoyanchev 97596fb9f6 Allow plugging in a WebSocketHandlerDecorator
The WebSocketMessageBroker config now allows wrapping the
SubProtocolWebSocketHandler to enable advanced use cases that may
require access to the underlying WebSocketSession.

Issue: SPR-12314
2014-10-13 09:35:51 -04:00
Rossen Stoyanchev f0323be786 Add option to copy HTTP session id to handshake attrs
Issue: SPR-12314
2014-10-10 15:21:04 -04:00
Rossen Stoyanchev 4a29e164a8 Allow binary messages in StompSubProtocolHandler
Issue: SPR-12301
2014-10-10 14:31:39 -04:00
Brian Clozel 4cf19df462 SockJs client: add an XhrTransport for Undertow
This change adds a new XhrTransport for the SockJs client
implementation. This transport is based on `UndertowClient`,
Undertow's HTTP client.

Note that this transport can be customized with an OptionMap that is
used by the Xnio worker backing the I/O communications (see
http://xnio.jboss.org).

Implementation tested with undertow 1.0.36, 1.1.0.RC3, 1.2.0.Beta1.

Issue: SPR-12008
2014-10-08 16:52:40 +02:00
Brian Clozel 2a39081819 Add Vary:Origin HTTP header in SockJS responses
This change adds a "Vary: Origin" HTTP response header for /info and
/iframe SockJS endpoints.
This is preventing proxies and browsers from caching a response and
reusing it for an invalid Origin.

Reference: https://groups.google.com/forum/#!topic/sockjs/svsLWRorSis

Issue: SPR-12310
2014-10-08 16:37:50 +02:00
Juergen Hoeller e56559fd4d WebSocketSession extends java.io.Closeable, plus reorganization of AbstractSockJsSession's code
Issue: SPR-12311
2014-10-07 13:45:07 +02:00
Juergen Hoeller da14aeea7a TextMessage.toString() does not throw StringIndexOutOfBoundsException for payload with multibyte characters
Issue: SPR-12307
2014-10-07 13:35:38 +02:00
Juergen Hoeller 3a3c52dbdd Polishing 2014-10-01 01:10:25 +02:00
Juergen Hoeller 7f9baa3a09 Polishing 2014-09-26 22:38:41 +02:00
Brian Clozel a6e1c53f23 Update default SockJS CDN location
This commit updates the default location of the SockJS' client library.
The previous location is being retired by the project maintainers.

The new default location is backed by several CDN providers:
* https://cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js

See sockjs/sockjs-client#198

Issue: SPR-12254
2014-09-26 21:42:08 +02:00
Rossen Stoyanchev 371d93b346 Detect unsent DISCONNECT messages
This change uses a ChannelInterceptor (inserted at index 0) to detect
when a DISCONNECT message is precluded from being sent on the
clientInboundChannel. This can happen if another interceptor allows
a runtime exception out from preSend or returns false.

It is crucial for such messages to be processed, so when detected
they're processed still.

Issue: SPR-12218
2014-09-25 23:22:12 -04:00
Juergen Hoeller 070642c148 Introduced addScope convenience method on CustomScopeConfigurer (for use in WebSocket configuration) 2014-09-25 01:31:33 +02:00
Juergen Hoeller 3836aa051f Message broker thread pools should be set up in allowCoreThreadTimeOut mode
Issue: SPR-12249
2014-09-25 01:29:00 +02:00
Rossen Stoyanchev b0e6091cad Lower "no session" message log level in SubProtocolWSH
Issue: SPR-12247
2014-09-24 15:04:57 -04:00
Rossen Stoyanchev 5b1cbf0306 Log WebSocket connection issues at DEBUG level
WebSocket clients going away is an expected and common occurance.
Logging at ERROR level on failure to close a connection or on failures
to write data to a WebSocket sessions has a high potential for false
positives with very little to do. This change lowers the log level for
a number of log messages that fit this category.

This should be helped by the effort already spent for 4.1 to ensure
logging at DEBUG level doesn't produce excessive amounts of logging.

Issue: SPR-12155
2014-09-24 10:07:15 -04:00
Rossen Stoyanchev 237b50a9c8 Allow configuring custom argument types
The WebSocket messaging namespace now exposes configuration options for
custom argument resolvers and return value handlers.

Issue: SPR-12217
2014-09-19 16:47:39 -04:00
Rossen Stoyanchev a99ef6d9b2 Extend websocket scope to event publication
This change extends the "websocket" scope to ApplicationContext events
published from StompSubProtocolHandler. This however will only work
with ApplicationEventMulticaster that multicasts events in the same
thread.

Issue: SPR-12172
2014-09-19 13:46:40 -04:00
Rossen Stoyanchev dc57cb2c9f Update SessionDisconnectEvent
SessionDisconnectEvent now extends AbstractSubProtocolEvent.

Issue: SPR-12156
2014-09-18 15:21:11 -04:00
Rossen Stoyanchev 4af9851585 Add user to DISCONNECT in StompSubProtocolHandler
Issue: SPR-12215
2014-09-18 15:06:08 -04:00
Rossen Stoyanchev 49b872e387 Adjust logging following SockJS client disconnect
Issue: SPR-11870
2014-09-04 00:23:10 -04:00
Juergen Hoeller 86b7118da8 Polishing 2014-09-04 02:30:25 +02:00
Juergen Hoeller 20c2ba35dc Polishing 2014-09-04 00:55:38 +02:00
Rossen Stoyanchev 2a0765e76d Allow setting SockJsMessageCodec in WebSocket config
Issue: SPR-12091
2014-08-25 15:19:50 -04:00
Juergen Hoeller b93dd95475 Polishing 2014-08-22 22:55:57 +02:00
Juergen Hoeller 86c5880888 Polishing 2014-08-21 18:41:23 +02:00
Juergen Hoeller 11805b6a5d ServerEndpointExporter can initialize itself based on a late-provided ServletContext as well (for Boot)
Also allows for direct setting of a ServerContainer and for custom triggering of endpoint registration.

Issue: SPR-12109
2014-08-21 18:40:35 +02:00
Juergen Hoeller 2ef3d66c89 Polishing 2014-08-18 19:27:08 +02:00