Commit Graph

1082 Commits

Author SHA1 Message Date
Juergen Hoeller 4b6fabbd2f Polishing 2023-08-03 18:10:13 +02:00
Juergen Hoeller d250a5155a Consistent dependency declarations 2023-08-02 00:56:50 +02:00
Sam Brannen 148f5c459e Update copyright headers 2023-08-01 14:54:09 +03:00
Juergen Hoeller 3b1af692cc Merge branch '6.0.x'
# Conflicts:
#	spring-beans/spring-beans.gradle
#	spring-context/spring-context.gradle
#	spring-orm/spring-orm.gradle
#	spring-test/spring-test.gradle
#	spring-web/spring-web.gradle
#	spring-webflux/spring-webflux.gradle
2023-08-02 01:04:31 +02:00
Sam Brannen b00d120514 Merge branch '6.0.x' 2023-08-01 14:54:41 +03:00
Juergen Hoeller 25ea1f4c0f Merge branch '6.0.x'
# Conflicts:
#	spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java
2023-07-19 00:37:06 +02:00
Juergen Hoeller 2f33e77ab4 Consistent equals/hashCode style (and related polishing) 2023-07-19 00:35:19 +02:00
Sam Brannen 63fe45d92a Update copyright headers 2023-07-15 13:11:29 +02:00
Sébastien Deleuze 38f9cbe3de Use latest version of sockjs-client in AbstractSockJsService
Closes gh-30848
2023-07-10 15:27:53 +02:00
Sam Brannen 5bc80fc094 Disable SpEL selector support in WebSocket messaging by default
This commit disables support for evaluating SpEL expressions from
untrusted sources by default. Specifically, this applies to the
SpEL-based 'selector' header support in WebSocket messaging, which
includes the DefaultSubscriptionRegistry and the classes used to
configure the 'selector' header name (SimpleBrokerMessageHandler and
SimpleBrokerRegistration).

The selector header support remains in place but will have to be
explicitly enabled beginning with Spring Framework 6.1.

For example, a custom implementation of WebSocketMessageBrokerConfigurer
can override the configureMessageBroker() method and configure the
selector header name as follows.

  registry.enableSimpleBroker().setSelectorHeaderName("selector");

Closes gh-30550
2023-06-04 17:02:02 +02:00
Sam Brannen 2f35e7756b Integration test status quo for SpEL 'selector' support in messaging
See gh-30550
2023-06-04 16:25:21 +02:00
James Yuzawa 5dacf50b9b Optimize MultiValueMap iteration operations
* use forEach and putIfAbsent to copy headers in DefaultClientRequestBuilder
* use forEach in ReactorClientHttpRequest and ReactorNetty2ClientHttpRequest
* circumvent ReadOnlyHttpHeaders.entrySet()
* ensure the fast path to LinkedCaseInsensitiveMap for forEach and putIfAbsent exists

Closes gh-29972
2023-04-25 09:57:26 +02:00
Johnny Lim 66bd891a0b Polish
See gh-30357
2023-04-20 15:42:01 +02:00
rstoyanchev 073226d792 Polishing contribution
Closes gh-30120
2023-04-11 11:43:24 +01:00
Aleksandrs Jansons 1abe155663 Ensure WebSocket disconnect msg reaches the client
In some application setups, the WebSocket server does not transmit
the disconnect message to the client, so that the client has no idea
that the established connection has been terminated.

This issue arises when the application uses SimpleBrokerMessageHandler
and the error handler is set to the instance of
StompSubProtocolErrorHandler or an extended class that does not
override the handleErrorMessageToClient method.

The commit fixes disconnect message population so that
`java.lang.IllegalArgumentException: No StompHeaderAccessor` exception
is not thrown in the handleErrorMessageToClient method in
StompSubProtocolErrorHandler class.

See gh-30120
2023-04-11 11:43:23 +01:00
Krzysztof Krasoń 1734deca1e
Refactor AssertJ assertions into more idiomatic ones
This commit refactors some AssertJ assertions into more idiomatic and
readable ones. Using the dedicated assertion instead of a generic one
will produce more meaningful error messages. 

For instance, consider collection size:
```
// expected: 5 but was: 2
assertThat(collection.size()).equals(5);
// Expected size: 5 but was: 2 in: [1, 2]
assertThat(collection).hasSize(5);
```

Closes gh-30104
2023-04-04 17:34:07 +02:00
ghostg00 e66c80667f Fix example in Javadoc for @EnableWebSocket
The `echoWebSocketHandler()` method is not defined in the
`WebSocketConfigurer` interface and should therefore be annotated with
`@Bean` instead of `@Override`.

Closes gh-30183
2023-03-24 17:54:33 +01:00
Sam Brannen e17f5c50a8 Update copyright headers 2023-03-13 21:53:40 +01:00
Sam Brannen 00be19c647 Consistently declare Object::equals argument as @Nullable 2023-03-13 21:43:21 +01:00
Sam Brannen a31cfba992 Apply "instanceof pattern matching" in remainder of spring-websocket module
See gh-30067
2023-03-07 19:18:25 +01:00
Sam Brannen 2e1374b459 Update copyright headers 2023-02-19 13:41:36 +01:00
rstoyanchev 9fcafd2650 WebSocketConnectionManager accepts prepared URI
Closes gh-28524
2023-02-13 18:39:19 +00:00
rstoyanchev 17bc3facaa Polishing contribution
Closes gh-29220
2023-02-13 09:16:33 +00:00
Anatolii Zhmaiev 1de9426df0 Set reason for WebSocket CloseStatus.SESSION_NOT_RELIABLE
See gh-29220
2023-02-13 09:16:33 +00:00
rstoyanchev a7ec6b4a2a Unwrap session before selecting stats counter
See gh-29375
2023-02-08 18:12:42 +00:00
Sam Brannen 0502d18e3d Update copyright headers 2023-01-19 16:20:03 +01:00
Sam Brannen c4c786596f Migrate to Mockito.mock(T...) where feasible 2023-01-19 16:20:02 +01:00
Sam Brannen a4956dfe26 Update copyright headers 2023-01-11 13:52:20 +01:00
Krzysztof Krason afb8a0d1b1 Use new Java features (switch expressions, text blocks, new JDK methods)
Closes gh-29747
2023-01-11 13:51:28 +01:00
Sam Brannen 46fc28fd1a Clean up Javadoc and source code regarding " ." typos 2022-12-12 16:31:14 +01:00
Sam Brannen 9b38e43c17 Use URI#create instead of URI constructor where feasible in spring-websocket 2022-12-09 13:27:34 -05:00
Sam Brannen ad60164911 Update copyright headers for source code changed since August 2022
The changes in this commit were performed using the newly introduced
update_copyright_headers.sh script.
2022-11-29 19:38:42 +01:00
Sam Brannen 052542254a Polishing 2022-11-28 17:51:18 +01:00
Sam Brannen db02c96c55 Avoid deprecation warnings in tests 2022-11-28 17:40:46 +01:00
Sam Brannen 164141a63e Fix broken tests in SockJsServiceTests
See gh-29594
2022-11-28 16:52:15 +01:00
Sam Brannen 0a731413de Polishing 2022-11-28 16:45:38 +01:00
Sam Brannen 6e5dd64025 Polish contribution
See gh-29594
2022-11-28 16:42:22 +01:00
Aashay Chapatwala 650875468c Add title to SockJS iFrames for accessibility compliance
Closes gh-29594
2022-11-28 16:33:41 +01:00
Juergen Hoeller 21d3a7529c Consistent documentation references to Jakarta WebSocket (2.1)
Closes gh-29581
2022-11-25 17:07:30 +01:00
Juergen Hoeller 9c7b471634 Deprecate JettyWebSocketClient in favor of StandardWebSocketClient
JettyWebSocketClient only supported on Jetty 11, to be phased out.

Closes gh-29576
2022-11-25 17:06:15 +01:00
Juergen Hoeller 45d45c2989 Early support for Jetty 12 (developed against 12.0.0.alpha2)
Reflective getHeaders calls to be revisited; see GitHub issue #8938 in Jetty project.
HttpOutput optimization commented out still in order to avoid alpha build dependency.

See gh-29575
2022-11-25 17:04:48 +01:00
Sam Brannen 7fcd1de8e3 Use AssertJ's isEmpty() instead of hasSize(0)
Achieved via global search-and-replace.
2022-11-22 17:11:50 +01:00
Sam Brannen d5b0b2b1a1 User AssertJ's hasSize() for arrays
Achieved via global search-and-replace.
2022-11-22 17:03:45 +01:00
Sam Brannen 36f7597f25 Use AssertJ's hasSize() for collections and maps
Achieved via a global search-and-replace.
2022-11-22 16:50:10 +01:00
Sam Brannen 917c41fd52 Use Set.of() for constant sets where appropriate 2022-11-21 16:49:07 +01:00
Arjen Poutsma 792371ac1f Generalize Jackson version numbers
This commit removes specific version info from Jackson codecs and
converters, in favor of generic info or removing the version information
all together.

See gh-29508
2022-11-17 16:56:38 +01:00
Sam Brannen abf3400c07 Use Assert.state() where appropriate 2022-11-15 12:31:10 +01:00
rstoyanchev e0b405869f Merge branch '5.3.x' 2022-11-11 15:16:26 +00:00
rstoyanchev 8ade083a05 Filter out null WebSocketSession attributes
Closes gh-29315
2022-11-11 11:20:18 +00:00
Juergen Hoeller d7d44c6c51 Polishing 2022-11-10 18:26:49 +01:00
Sam Brannen 95f3337bb5 Revise contribution
This commit reverts changes to AbstractCacheManager since iterating
over the caches in a for-loop and a stream is duplicated effort.

This commit reverts changes to DefaultRenderingResponseBuilder,
RouterFunctions, and OriginHandshakeInterceptor since order matters for
those use cases: they were originally based on the semantics of
LinkedHashSet or LinkedHashMap; whereas, Set.copyOf() and Map.copyOf()
do not provide any guarantees regarding ordering.

This commit also applies analogous changes to "sibling" implementations
across Servlet mocks as well as Web MVC and WebFlux.

See gh-29321
2022-11-08 14:14:29 +01:00
divcon ba136dcf40 Replace use of Collections.unmodifiable*() methods where appropriate
Closes gh-29321
2022-11-08 13:51:31 +01:00
Juergen Hoeller a2ac764f9c Reuse StandardWebSocketUpgradeStrategy as a base class for Tomcat etc
Includes non-reflective instantiation of well-known strategy classes.

See gh-29436
2022-11-07 17:35:31 +01:00
Juergen Hoeller 19cf503534 Align with Servlet 6.0 and introduce support for Jakarta WebSocket 2.1
Includes corresponding build upgrade to Tomcat 10.1.1 and Undertow 2.3.0
(while retaining runtime compatibility with Tomcat 10.0 and Undertow 2.2)

Closes gh-29435
Closes gh-29436
2022-11-06 16:08:30 +01:00
Andy Wilkinson 95395b53d5 Make WebSocket upgrade strategies compatible with Tomcat 10.1 2022-11-06 00:30:35 +01:00
Sam Brannen 82823517fa Merge branch '5.3.x'
# Conflicts:
#	build.gradle
#	spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.java
#	spring-messaging/src/main/java/org/springframework/messaging/rsocket/MetadataEncoder.java
#	spring-messaging/src/main/java/org/springframework/messaging/simp/broker/OrderedMessageChannelDecorator.java
#	spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java
#	spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java
#	spring-web/src/main/java/org/springframework/http/HttpRange.java
#	spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RedirectView.java
#	spring-webflux/src/main/java/org/springframework/web/reactive/socket/CloseStatus.java
#	spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/RedirectViewControllerRegistration.java
2022-11-05 14:50:18 +01:00
Sam Brannen 5f02323b9c Avoid String allocations with Assert.isTrue() 2022-11-05 14:40:45 +01:00
Sam Brannen 723e09c164 Polishing
See gh-29408
2022-11-02 12:46:44 +01:00
Kulwant Singh 5245327962 Fix tests and checkstyle violations
See gh-29408
2022-11-02 12:46:44 +01:00
Kulwant Singh 20d0becbc6 Fix Javadoc links
See gh-29408
2022-11-02 12:46:44 +01:00
Kulwant Singh 5f2a6fd7f1 Use List.of() instead of Arrays.asList() where appropriate
See gh-29408
2022-11-02 12:46:44 +01:00
Kulwant Singh eec3c6f7bb Replace concatenated strings with text blocks
See gh-29408
2022-11-02 12:46:44 +01:00
Kulwant Singh 19955c5b77 Remove unnecessary calls to toString()
See gh-29408
2022-11-02 12:46:44 +01:00
Kulwant Singh bd57d860d2 Use StandardCharsets
See gh-29408
2022-11-02 12:46:44 +01:00
Sébastien Deleuze aa776e40f9 Ensure classpath checks can be evaluated at build-time
Closes gh-29352
2022-10-19 10:49:11 +02:00
Adam Ostrožlík 0ccb64fe10 Replace Collectors.toList with Stream.toList
Closes gh-29203
2022-09-26 18:32:01 +02:00
Sam Brannen 321092ce6f Consistent use of @Deprecated(since = "6.0") 2022-09-20 14:34:24 +02:00
rstoyanchev c854e35c9d Merge branch '5.3.x' 2022-09-12 12:27:31 +01:00
rstoyanchev 4eabe29b9a Polishing contribution
Closes gh-28785
2022-09-12 10:52:53 +01:00
npriebe cd10171f98 Make WebSocketConnectionManager#isConnected public
See gh-28785
2022-09-12 09:54:57 +01:00
Andy Wilkinson a5fb55fd6d Replace dependency management plugin with built-in platform support 2022-08-30 17:03:24 +01:00
Sam Brannen e4395f2f8b Clean up warnings and polishing 2022-07-31 14:14:56 +03:00
Arjen Poutsma 2aa74c9121 Deprecate ListenableFuture in favor of CompletableFuture
This commit deprecates ListenableFuture in favor of CompletableFuture.
ListenableFuture was introduced in Spring Framework 4.0, when
CompletableFuture was not yet available. Spring now requires JDK 17, so
having our own type no longer seems necessary.

Major changes in this commit include:
- Deprecation of ListenableFuture and related types
  (ListenableFutureCallback, SettableListenableFuture, etc.)
- Deprecation of AsyncListenableTaskExecutor in favor of default methods
  in AsyncTaskExecutor (submitCompletable).
- AsyncHandlerMethodReturnValueHandler now has toCompletableFuture
  instead of toListenableFuture.
- WebSocketClient now has execute methods, which do the same as
  doHandshake, but return CompletableFutures (cf. the reactive
  WebSocketClient).

All other changes
- add an overloaded method that takes a CompletableFuture parameter
  instead of ListenableFuture, and/or
- add a method with a 'Async' suffix that returns a CompletableFuture
  instead of a ListenableFuture (connectAsync, sendAsync).

Closes gh-27780
2022-07-27 12:41:35 +02:00
Stephane Nicoll ae6a464a80 Merge branch '5.3.x' 2022-07-22 16:15:55 +02:00
Stephane Nicoll 421b5cb311 Polish "Deprecate SockJsServiceRegistration#setSupressCors"
See gh-28853
2022-07-22 16:07:47 +02:00
Marc Wrobel 1cc36e5be9 Deprecate SockJsServiceRegistration#setSupressCors
SockJsServiceRegistration#setSupressCors name contains a typo. It is
now deprecated in favor of a correctly spelled method, setSuppressCors.

See gh-28853
2022-07-22 16:06:54 +02:00
Stephane Nicoll 2c92d7da8f Harmonize RuntimeHintsRegistrar implementations
Closes gh-28801
2022-07-12 18:30:23 +02:00
Sam Brannen 7751c44487 Merge branch '5.3.x'
# Conflicts:
#	spring-websocket/src/main/java/org/springframework/web/socket/CloseStatus.java
#	spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardToWebSocketExtensionAdapter.java
#	spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/SockJsClient.java
2022-07-11 21:37:13 +02:00
Marc Wrobel 03f0c57704 Fix and improve Javadoc in spring-websocket
Closes gh-28788
2022-07-11 21:30:32 +02:00
Arjen Poutsma 9b739a2310 Update scheduling package to use java.time
This commit deprecates all methods in org.springframework.scheduling
that use

- Date, in favor of variants that take an Instant.
- long & TimeUnit, in favor of variants that take a Duration.

Closes: gh-28714
2022-07-08 16:25:27 +02:00
rstoyanchev a92b4279d7 Merge branch '5.3.x' 2022-07-04 16:52:16 +01:00
rstoyanchev 007bdede46 Add missing check to avoid re-initialization
Noticed during review of #28736 that a check protecting against
re-initialization was accidentally removed in commit
3d6e38bb43.
2022-07-04 16:17:57 +01:00
rstoyanchev 22cc6c5918 Polishing contribution
Closes gh-28736
2022-07-04 16:12:57 +01:00
CodeInDreams 461ba53b39 Qualify channelExecutor and taskScheduler in WebSocket config
See gh-28736
2022-07-04 15:51:40 +01:00
Johnny Lim 1205f53c4a Polish 2022-07-02 15:11:35 +09:00
Sébastien Deleuze ecdd934658 Add runtime hints for AbstractHandshakeHandler
Closes gh-28697
2022-06-30 16:50:43 +02:00
Juergen Hoeller 4e1b9f1492 Replace deep exception message nesting with custom inclusion of cause messages
Includes deprecation of NestedServletException, whereas NestedCheckedException and NestedRuntimeException remain as base classes with several convenience methods.

Closes gh-25162
2022-06-14 14:00:28 +02:00
Sam Brannen 70415b1781 Merge branch '5.3.x' 2022-05-17 15:41:08 +02:00
Sam Brannen 59c7bb1f86 Use Arrays.toString instead of Arrays.asList when generating Strings 2022-05-17 15:36:31 +02:00
Sam Brannen d45b5f6e8a Merge branch '5.3.x'
# Conflicts:
#	spring-webflux/src/main/java/org/springframework/web/reactive/resource/VersionResourceResolver.java
#	spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java
2022-05-10 11:44:14 +02:00
Sam Brannen 1c10cdd1e8 Update copyright dates
See gh-28433
2022-05-10 11:33:32 +02:00
evgeny.bovykin 941b92cbed Make inner classes static when feasible
A static nested class does not keep an implicit reference to its
enclosing instance.

This prevents a common cause of memory leaks and uses less memory per
instance of the class.

Closes gh-28433
2022-05-10 11:32:37 +02:00
Juergen Hoeller 2b65f274dc Use Set.of instead of HashSet with Arrays.asList 2022-05-06 16:19:27 +02:00
Arjen Poutsma 28ac0d3883 Use HttpStatusCode interface
This commit contains changes made because of the introduction of
HttpStatusCode. In general, methods that used to return a HttpStatus
now return HttpStatusCode instead, and methods that returned raw status
codes are now deprecated.

See gh-28214
2022-03-23 12:49:38 +01:00
Sam Brannen 9764f0e59b Merge branch '5.3.x'
# Conflicts:
#	spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpRequestTests.java
#	spring-web/src/test/java/org/springframework/http/server/reactive/HeadersAdaptersTests.java
#	spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java
#	spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java
#	spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java
#	spring-webmvc/src/test/java/org/springframework/web/servlet/handler/MappedInterceptorTests.java
#	spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java
#	spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java
2022-03-16 15:07:53 +01:00
Sam Brannen c462fe30ed Use Named arguments in parameterized tests 2022-03-16 14:45:47 +01:00
Stephane Nicoll 67b7c16bc0 Fix visibility of DefaultSockJsSchedulerContainer
Closes gh-28146
2022-03-09 16:38:10 +01:00
Sam Brannen 8c6d59aaaf Polish contribution
See gh-28014
2022-02-19 14:43:26 +01:00
a.yazychyan c5c926726d Use enhanced switch expressions where feasible
Closes gh-28014
2022-02-19 14:34:05 +01:00
rstoyanchev 4782d4c080 Merge branch '5.3.x' into main 2022-02-14 20:52:09 +00:00