Commit Graph

698 Commits

Author SHA1 Message Date
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 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
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