Compare commits

...

138 Commits

Author SHA1 Message Date
Spring Builds 4343423f1c Release v5.3.15 2022-01-13 11:08:53 +00:00
Stephane Nicoll cfefcee788 Polishing
See gh-27926
2022-01-13 08:28:54 +01:00
Sam Brannen 5fb58e51e5 Infer UTF-8 encoding for JSON response with MockMvc's andDo(print(...))
Prior to this commit, the PrintingResultHandler in MockMvc -- typically
invoked via .andDo(print()) -- printed an `application/json` response
body using the default encoding (ISO-8859-1), which resulted in UTF-8
characters being garbled.

Since an `application/json` response is implicitly encoded using UTF-8,
the PrintingResultHandler now infers UTF-8 encoding for such response
bodies.

Closes gh-27926
2022-01-12 17:07:45 +01:00
Juergen Hoeller 67c4b4182f Upgrade to Hibernate ORM 5.4.33, Hibernate Validator 6.2.1, Mockito 4.2, AssertJ 3.22, HtmlUnit 2.56, XMLUnit 2.8.4 2022-01-12 16:36:18 +01:00
Juergen Hoeller 6b3052200a Skip "data:" lines without content
Closes gh-27923
2022-01-12 16:35:42 +01:00
Juergen Hoeller cf5b86369d Explicitly close InputStream after resolution in RequestPartMethodArgumentResolver
Closes gh-27773
2022-01-12 16:31:39 +01:00
rstoyanchev 7067461d71 Fix exception in Jetty10RequestUpgradeStrategy
Closes gh-27899
2022-01-12 15:04:05 +00:00
rstoyanchev 34cb5df859 Consistent id for ReactorServerHttpRequest
Closes gh-27885
2022-01-12 08:55:32 +00:00
rstoyanchev 01231fe923 Minor refactoring in STOMP documentation
Closes gh-27906
2022-01-12 08:55:32 +00:00
rstoyanchev 7665424ea8 Polishing contribution
Closes gh-27888
2022-01-12 08:55:32 +00:00
Max Demydenko f63a106c85 clear() method also clears argument resolver cache
See gh-27888
2022-01-12 08:55:32 +00:00
rstoyanchev caaf48d4ec Add missing overrides to ServerHttpResponseDecorator
Closes gh-27889
2022-01-12 08:55:32 +00:00
Stephane Nicoll e52fc2176d Upgrade to Reactor 2020.0.15
Closes gh-27897
2022-01-12 09:39:09 +01:00
rstoyanchev e8e7fbba94 Polishing contribution and fix failing test
The failing test is for Apache HttpComponents where we cannot apply the
Content-Length together with other headers, and must pass it instead
explicitly to ReactiveEntityProducer when writing at which point it gets
set in the native headers.

Closes gh-27768
2022-01-11 17:07:26 +00:00
sokomishalov bd1f34e174 Apply adapters to client request headers after committed
See gh-27768
2022-01-11 15:30:03 +00:00
Arjen Poutsma a490723f02 NettyHeadersAdapter::putAll does not overwrite headers
Similar to 4078b73cec, but for the
client-side NettyHeadersAdapter::putAll.

See gh-27887
2022-01-11 13:33:15 +01:00
Sam Brannen df263d01b9 Use idiomatic AssertJ assertions for true, false, and null 2022-01-10 14:15:55 +01:00
kuanghc1 2a80b64d40 Add tests for StringUtils matchesCharacter() method
Closes gh-27909
2022-01-10 13:27:15 +01:00
kuanghc1 e24043ab90 Simplify HashMap declaration in test fixture 2022-01-10 13:27:15 +01:00
Arjen Poutsma 4078b73cec NettyHeadersAdapter::putAll does not overwrite headers
NettyHeadersAdapter::putAll uses HttpHeaders::add, which does not
overwrite existing headers. putAll should use HttpHeaders::set instead,
just like NettyHeadersAdapter::put does.

Closes gh-27887
2022-01-10 10:54:04 +01:00
Stephane Nicoll dca155e438 Reintroduce references to JBoss AS Javadoc
Closes gh-27860
2022-01-10 10:12:05 +01:00
waahhh edabde8a11 Fix syntax in WebFlux Validation example
Closes gh-27907
2022-01-09 17:26:11 +01:00
Sam Brannen 8087eb69bf Improve error message in ResolvableType.forClassWithGenerics()
Prior to this commit, the error message generated for a mismatched
number of generics did not include the information about the class in
question.

This commit improves the error message by providing more context,
specifically the result of invoking toGenericString() on the class.

For example, instead of throwing an IllegalArgumentException with the
error message "Mismatched number of generics specified", the error
message would now be "Mismatched number of generics specified for
public abstract interface java.util.Map<K,V>".

Closes gh-27847
2022-01-09 17:05:07 +01:00
Sam Brannen e41d865193 Polishing 2022-01-09 17:05:07 +01:00
Sam Brannen d68bb4eecd Simplify StreamConverterTests 2022-01-09 16:15:32 +01:00
Sam Brannen 730ad4436f Polish contribution 2022-01-09 16:15:32 +01:00
kth496 23ab9ca8ca Refactor tests to use lambda expressions & method references
Closes gh-27386
2022-01-09 15:37:54 +01:00
Sam Brannen 51d263bd06 Simplify H2SequenceMaxValueIncrementerTests
@hpoettker made me aware of the ModeEnum in H2 that allows the
parameterized test to be simplified, which was the primary impetus for
this commit.

See gh-27870
2022-01-08 17:24:19 +01:00
Sam Brannen 518dc6df65 Polishing 2022-01-08 17:06:25 +01:00
Sam Brannen 59c6b7e445 Fix SpEL withTypedRootObject() test 2022-01-08 17:06:25 +01:00
justlikeliuen 3e75ec73ab Fix SpEL withRootObject test
The test case is intended to be for the method 'withRootObject()', but
actually it's copied from the previous test method that does not use
'withRootObject()'.

This commit fixes the propertyReadWriteWithRootObject() test method in
PropertyAccessTests.

Closes gh-27905
2022-01-08 17:06:25 +01:00
Sam Brannen 709a41fd43 Fix broken links to WebSocket support in Spring Security & Spring Session 2022-01-08 16:35:58 +01:00
Sam Brannen 90072d06fb Test H2SequenceMaxValueIncrementer against all H2 2.0.x compatibility modes
See gh-27870
2022-01-07 16:17:11 +01:00
Sam Brannen 54bdab4553 Partially upgrade to H2 database 2.0.206
Commit ed4e2289cd introduced support for H2 2.0.x but did not upgrade
the H2 dependency.

This commit upgrades the H2 dependency to version 2.0.206 but also
adds an explicit test dependency on version 1.4.200 in spring-r2dbc,
since r2dbc-h2 does not yet support H2 2.0.x.

Once https://github.com/r2dbc/r2dbc-h2/pull/204 has been included in a
released version of r2dbc-h2 we will be able to upgrade spring-r2dbc's
test dependency on the H2 database to 2.0.x as well.

See gh-27870
See gh-27902
2022-01-07 15:50:44 +01:00
Sam Brannen 75e1811470 Ensure H2SequenceMaxValueIncrementer works with all H2 compatibility modes
See gh-27870
2022-01-07 14:29:17 +01:00
Sam Brannen 18781e58ac Polish contribution
See gh-27870
2022-01-07 10:09:45 +01:00
Henning Poettker ed4e2289cd Support H2 1.4 & 2.0 in H2SequenceMaxValueIncrementer
Prior to this commit, H2SequenceMaxValueIncrementer only supported H2
database 1.4.

This commit updates H2SequenceMaxValueIncrementer's getSequenceQuery()
method so that the syntax used supports version 1.4 and 2.0 of the H2
database.

This commit also updates several test schemas so that they work with H2
1.4 and 2.0 as well as HSQL.

Closes gh-27870
2022-01-07 10:09:27 +01:00
Stephane Nicoll ccf95413ed Start building against Reactor 2020.0.15 snapshots
See gh-27897
2022-01-06 16:48:15 +01:00
Johannes Wengert fdd6e50721 Correct not compiling example code in Data Access docs
The EntityManager interface does not implement AutoCloseable until
JPA 3.1.

This commit therefore partially reverts 189e1afc6e so that the
example code compiles with the supported JPA version.

See gh-22269
Closes gh-27886
2022-01-04 16:50:23 +01:00
Sam Brannen c04fa858fc Partially revert e1200f34e7
Syntax for this try-with-resources use case only permitted on Java 9+.
2022-01-04 16:20:55 +01:00
Sam Brannen c3ce4f0f90 Polish contribution
See gh-27823
2022-01-04 15:12:29 +01:00
Marten Deinum e1200f34e7 Use try-with-resources for AutoClosables where feasible
Where unfeasible, this commit adds inline comments to explain why
try-with-resources must not be used in certain scenarios. The purpose
of the comments is to avoid accidental conversion to try-with-resources
at a later date.

Closes gh-27823
2022-01-04 15:12:29 +01:00
Stephane Nicoll 999376f9f9 Temporarily remove references to JBoss AS Javadoc
See gh-27860
2022-01-04 15:00:44 +01:00
Sam Brannen c942d789c3 Ignore unsupported @SuppressWarnings tokens in Eclipse IDE
This helps to reduce noise in the "Problems" view by not displaying
warnings resulting from @SuppressWarnings tokens that Eclipse does not
understand -- for example, tokens supported by IntelliJ IDEA or other
tools.
2022-01-04 14:52:23 +01:00
Sam Brannen 03668f9c10 Replace remaining use of StringBuffer with StringBuilder
Although this commit only applies to test classes, it serves to reduce
the noise when searching for undesirable usage of StringBuffer in
production code.
2022-01-04 14:06:13 +01:00
Sam Brannen 3e14cdbc69 Polish tests 2022-01-04 14:02:32 +01:00
Sam Brannen f04e9a8366 Deprecate getBeanFactory() method in AbstractBeanDefinitionReader
The getBeanFactory() method has been obsolete for more than 13 years
since it was superseded by the getRegistry() method in the
BeanDefinitionReader interface.

Closes gh-27875
2022-01-04 12:45:11 +01:00
Sam Brannen c1606c5a5e Polishing 2022-01-04 12:39:28 +01:00
Sam Brannen 95fac2589f Upgrade to Log4j2 2.17.1 2022-01-03 11:50:37 +01:00
Spring Builds 41c8bb4fe1 Next development version (v5.3.15-SNAPSHOT) 2021-12-16 08:46:23 +00:00
Juergen Hoeller 31a4c274b7 Upgrade to SnakeYAML 1.30, MockK 1.12.1, Jetty Reactive HttpClient 1.1.10 2021-12-15 21:51:05 +01:00
Juergen Hoeller d665977787 Polishing 2021-12-15 21:50:30 +01:00
Juergen Hoeller 0b6a54dcc7 Upgrade to R2DBC Arabba-SR11, Kotlin 1.5.32, Jackson 2.12.6 2021-12-15 17:58:59 +01:00
Juergen Hoeller 1885ab3e07 Polishing 2021-12-15 17:58:28 +01:00
Stephane Nicoll de10bb69cb Stop resolving AsyncConfigurer instances eagerly
Closes gh-27808
2021-12-15 10:53:09 +01:00
Stephane Nicoll c7642422c3 Stop resolving CachingConfigurer instances eagerly
Closes gh-27751
2021-12-15 10:52:09 +01:00
Stephane Nicoll 4c2e0ee5ff Upgrade to Log4j2 2.16.0 2021-12-15 09:49:57 +01:00
Juergen Hoeller 79804d92c2 Upgrade to Protobuf 3.19.1, Gson 2.8.9, Woodstox 6.2.7, Apache Johnzon 1.2.15, Caffeine 2.9.3 2021-12-14 18:36:05 +01:00
Juergen Hoeller f191cf4eb3 Revised comment on explicit LocalDataSourceJobStore configuration
See gh-27709
2021-12-14 18:32:32 +01:00
Juergen Hoeller 0ebb1c5baa Upgrade to Tomcat 9.0.56, Undertow 2.2.14, Apache HttpClient 5.1.2 & HttpAsyncClient 4.1.5, Mockito 4.1 2021-12-14 16:48:40 +01:00
Juergen Hoeller 4b7d9b1f9c Avoid compilation warning for test class with serializable base class 2021-12-14 16:48:07 +01:00
Juergen Hoeller ca84559588 Provide findAnnotationOnBean variant with allowFactoryBeanInit flag
Closes gh-27796
2021-12-14 16:47:12 +01:00
Juergen Hoeller 1af21bb451 Declare serialVersionUID on DefaultAopProxyFactory
Closes gh-27784
2021-12-14 16:46:59 +01:00
Juergen Hoeller ac581bed92 Avoid NPE against null value from toString call
Closes gh-27782
2021-12-14 16:46:42 +01:00
Juergen Hoeller 0802581aff Unit test for identifying type variable argument
See gh-27748
2021-12-14 16:46:26 +01:00
Juergen Hoeller d7b9270672 Clarify SchedulerFactoryBean's LocalDataSourceJobStore overriding
Includes clarification of interface-level cache annotations for target-class proxies.

Closes gh-27709
See gh-27726
2021-12-14 16:46:13 +01:00
Juergen Hoeller c44447f622 Avoid early initialization of empty interceptor names
Closes gh-12238
2021-12-14 16:46:01 +01:00
Stephane Nicoll 8b80d38c33 Upgrade to Reactor 2020.0.14
Closes gh-27793
2021-12-14 15:33:55 +01:00
Stephane Nicoll b06d267232 Remove references to AsyncConfigurerSupport
Closes gh-27812
2021-12-14 13:59:05 +01:00
Stephane Nicoll 8422d9d22f Add default methods to CachingConfigurer
This commit adds default methods to CachingConfigurer and
JCacheConfigurer and removes the reference to their respective support
classes as they are now irrelevant.

Closes gh-27811
2021-12-14 13:49:57 +01:00
Stephane Nicoll c50a5096a0 Upgrade to Netty 4.1.72.Final 2021-12-13 16:18:25 +01:00
Stephane Nicoll c25c550113 Merge pull request #27804 from aoyvx
* pr/27804:
  Polish "Fix javadoc reference to ThrowsAdvice"
  Update copyright year of changed file
  Fix javadoc reference to ThrowsAdvice

Closes gh-27804
2021-12-12 16:33:45 +01:00
Stephane Nicoll 9e09d6cde4 Polish "Fix javadoc reference to ThrowsAdvice"
See gh-27804
2021-12-12 16:32:35 +01:00
Stephane Nicoll 31b8587ce6 Update copyright year of changed file
See gh-27804
2021-12-12 16:30:06 +01:00
xay 00375df4e8 Fix javadoc reference to ThrowsAdvice
See gh-27804
2021-12-12 16:27:28 +01:00
Stephane Nicoll b1352e1833 Upgrade to Log4j2 2.15.0 2021-12-10 15:05:56 +01:00
Sam Brannen b2e94f611f Convert single null argument to Optional.empty() in SpEL varargs expression
Prior to this commit, if a single null value was passed to a method with
a varargs array of type java.util.Optional, that null value was passed
unmodified. On the contrary, a null passed with additional values to
such a method resulted in the null being converted to Optional.empty().

This commit ensures that a single null value is also converted to
Optional.empty() for such SpEL expressions.

Closes gh-27795
2021-12-10 13:53:28 +01:00
Sam Brannen ad7cdc5ce9 Fix regression for null varargs in SpEL expressions
A regression was introduced in gh-27582. Specifically, when null is
supplied as the single argument for a varargs parameter in a method or
function in a SpEL expression, ReflectionHelper currently throws a
NullPointerException instead of leaving the null value unchanged.

This commit fixes this regression.

Closes gh-27719
2021-12-10 13:12:44 +01:00
Stephane Nicoll 6cc9538ab9 Start building against Reactor 2020.0.14 snapshots
See gh-27793
2021-12-10 07:55:44 +01:00
Rossen Stoyanchev e9083d7d20 Apply LogFormatUtils in more places 2021-12-09 14:53:52 +00:00
Stephane Nicoll 98ce171b30 Revert "Mention explicitly that @EventListener should be put on public methods"
This reverts commit 57a5370eec.

See gh-27777
2021-12-09 15:18:56 +01:00
Stephane Nicoll 57a5370eec Mention explicitly that @EventListener should be put on public methods
Closes gh-27777
2021-12-09 14:43:00 +01:00
Rossen Stoyanchev 99c7608ffe Replace both EOL and control characters 2021-12-08 11:25:38 +00:00
Arjen Poutsma c0f79ee00a Merge pull request #25092 from jkatada:fix-ModelAndView-status-for-redirect
* gh-25092:
  Fix for ModelAndView.status not working with RedirectView
2021-12-07 13:56:19 +01:00
Katada, Junya 9261766677 Fix for ModelAndView.status not working with RedirectView 2021-12-07 13:39:57 +01:00
Juergen Hoeller 14f24f43d7 Polishing 2021-12-03 22:36:31 +01:00
Juergen Hoeller d7e0eed8d2 Clarify getBeanProvider(ResolvableType) semantics for unresolved generics
Closes gh-27727
2021-12-03 22:33:50 +01:00
Juergen Hoeller 7c834d98c2 Upgrade to ASM master (including early support for Java 19 bytecode)
Closes gh-27740
2021-12-03 22:32:26 +01:00
Juergen Hoeller 70974e006e Upgrade to Tomcat 9.0.55, Undertow 2.2.13, RxJava 3.1.3, SmallRye Mutiny 1.2, Joda-Time 2.10.13, JRuby 9.2.20.1, HtmlUnit 2.55, Checkstyle 9.2 2021-12-03 22:32:00 +01:00
Arjen Poutsma 2f557d9583 Merge pull request #25358 from ivd-git:router-function-handler-not-found-to-exception-pr
* gh-25358:
  Polish "Throw 404 ResponseStatusException when no routes found"
  Throw 404 ResponseStatusException when no routes found
2021-12-03 12:51:44 +01:00
Arjen Poutsma b84fe99d07 Polish "Throw 404 ResponseStatusException when no routes found"
See gh-25358
2021-12-03 12:01:49 +01:00
Ingmar van Dijk 69df27a99f Throw 404 ResponseStatusException when no routes found
This commit makes it possible to customize 404 responses generated by
RouterFunctionWebHandler, by throwing an ResponseStatusException
instead of returning a standard 404 response.

See gh-25358
2021-12-03 12:01:49 +01:00
Rossen Stoyanchev 5649a6f8ef Update exchangeToMono Javadoc
This time showing a more representative example.

See gh-27645
2021-12-03 09:21:21 +00:00
Arjen Poutsma be6eeafe78 Revert change createException to createError
createError is not available in 5.3.

See gh-27645
2021-12-02 15:59:51 +01:00
Arjen Poutsma b77b45434f Change createException to createError
See gh-27645
2021-12-02 15:11:15 +01:00
Rossen Stoyanchev 6582787678 Apply resources after application HttpClient mapper
Closes gh-27749
2021-12-02 12:28:36 +00:00
Rossen Stoyanchev 8b89128c7b Update createException example for WebClient
Closes gh-27645
2021-12-02 11:53:43 +00:00
Arjen Poutsma 2a5713f389 Always copy ServerResponse headers
Prior to this commit, ServerResponse headers would only be written if
there were no existing headers with the same name, thus making it
impossible to overwrite existing headers.

With the changes in this commit, headers are always written.

Closes gh-27741
2021-11-30 13:38:16 +01:00
Sam Brannen 40d2058b97 Upgrade to JUnit 5.8.2
Closes gh-27744
2021-11-30 12:22:31 +01:00
Rossen Stoyanchev 0d478ca8dd Add link to WebSocket scope from the Spring Core section
Closes gh-25172
2021-11-29 17:37:37 +00:00
Rossen Stoyanchev 445c0def0c Update docs on heartbeats with simple broker
Closes gh-27746
2021-11-29 17:13:57 +00:00
Stephane Nicoll ef696c787b Merge pull request #22246 from diguage
* pr/22246:
  Polish "Fix reference to CountingBeforeAdvice"
  Fix reference to CountingBeforeAdvice

Closes gh-22246
2021-11-28 10:53:15 +01:00
Stephane Nicoll 27257fb82e Polish "Fix reference to CountingBeforeAdvice"
See gh-22246
2021-11-28 10:52:16 +01:00
diguage e209a460ca Fix reference to CountingBeforeAdvice
See gh-22246
2021-11-28 10:44:48 +01:00
Brian Clozel d019c1f82b Polish
See gh-2030
2021-11-24 21:34:23 +01:00
Stephane Nicoll 82d6e07090 Merge pull request #2030 from matips
* pr/2030:
  Polish "Clarify behaviour of AnnotationBeanNameGenerator with acronyms"
  Clarify behaviour of AnnotationBeanNameGenerator with acronyms

Closes gh-2030
2021-11-24 16:29:45 +01:00
Stephane Nicoll a1b2695c3a Polish "Clarify behaviour of AnnotationBeanNameGenerator with acronyms"
See gh-2030
2021-11-24 16:29:13 +01:00
Mateusz 341f4882ed Clarify behaviour of AnnotationBeanNameGenerator with acronyms
Name transformation is delegated to Introspector#decapitalize, which
states "but in the (unusual) special case when there is more than one
character and both the first and second characters are upper case, we
leave it alone.". This commit clarifies this behavior.

See gh-2030
2021-11-24 16:00:22 +01:00
Rossen Stoyanchev 829bed03af Polishing contribution
Closes gh-27723
2021-11-24 13:05:05 +00:00
Andreas Grub ce0aed216b Add getter for RequestMappingInfo.BuilderConfiguration
This improves support for programmatic registration of mappings to
use the same config as that of the RequestMappingHandlerMapping.

See gh-27723
2021-11-24 13:05:05 +00:00
Rossen Stoyanchev 0d7c562693 Polishing contribution
Closes gh-910
2021-11-24 13:05:05 +00:00
/usr/local/ΕΨΗΕΛΩΝ 913cc079af TagWriter can write empty attribute
See gh-910
2021-11-24 13:05:05 +00:00
Rossen Stoyanchev 3f7dec0b0d Polishing contribution
Closes gh-699
2021-11-24 13:05:05 +00:00
Marco Krikke 830cc3450f Improved DataBinder Javadoc for xxx*yyy pattern matching
The default documentation does not mention xxx*yyy pattern matching,
which is, however, supported by PatternMatchUtils. Such a pattern
can be useful for matching nested properties in all elements of a
collection, e.g. property[*].nestedProperty.

See gh-699
2021-11-24 13:05:05 +00:00
Stephane Nicoll 6f6d27f50f Merge pull request #1246 from fededonna
* pr/1246:
  Polish "Expose prestartAllCoreThreads on ExecutorService"
  Expose prestartAllCoreThreads on ExecutorService

Closes gh-1246
2021-11-24 14:02:48 +01:00
Stephane Nicoll 19a8b94b21 Polish "Expose prestartAllCoreThreads on ExecutorService"
See gh-1246
2021-11-23 17:17:22 +01:00
Federico Donnarumma 2c53e9e308 Expose prestartAllCoreThreads on ExecutorService
See gh-1246
2021-11-23 16:14:39 +01:00
Arjen Poutsma 2271b6078e Polishing contribution
See gh-1607
2021-11-23 10:44:45 +01:00
qxo e8eeb99ac8 Repect StaxDriver in XStreamMarshaller::marshalXmlStreamWriter
This commit makes sure that namespaces configured via the streamDriver
property are respected.
2021-11-23 10:41:04 +01:00
Stephane Nicoll b67e97d388 Polish 2021-11-22 16:13:37 +01:00
Stephane Nicoll 656f0591c6 Merge pull request #1330 from kazuki43zoo
* pr/1330:
  Polish "Add tests for AbstractRoutingDataSource"
  Add tests for AbstractRoutingDataSource

Closes gh-1330
2021-11-22 13:46:29 +01:00
Stephane Nicoll 23babe27bb Polish "Add tests for AbstractRoutingDataSource"
See gh-1330
2021-11-22 13:43:08 +01:00
Kazuki Shimizu bcb9f159ca Add tests for AbstractRoutingDataSource
See gh-1330
2021-11-22 13:43:08 +01:00
Stephane Nicoll 8ca9187938 Merge pull request #1025 from julianladisch
* pr/1025:
  Fix simple data format in appendix

Closes gh-1025
2021-11-22 13:27:56 +01:00
julianladisch 1e0bdf95d0 Fix simple data format in appendix
See gh-1025
2021-11-22 13:26:57 +01:00
Stephane Nicoll 44da9451c4 Merge pull request #1000 from awgtek
* pr/1000:
  Polish "Refine StoredProcedure#declareParameter Javadoc"
  Refine StoredProcedure#declareParameter Javadoc

Closes gh-1000
2021-11-22 13:21:00 +01:00
Stephane Nicoll 544f357661 Polish "Refine StoredProcedure#declareParameter Javadoc"
See gh-1000
2021-11-22 13:20:16 +01:00
awgtek ca4f338d75 Refine StoredProcedure#declareParameter Javadoc
See gh-1000
2021-11-22 13:18:24 +01:00
Stephane Nicoll 8e8c88ea5c Merge pull request #767 from thomasdarimont
* pr/767:
  Document @Bean definitions via default methods

Closes gh-767
2021-11-22 12:55:38 +01:00
Thomas Darimont 767299c6dd Document @Bean definitions via default methods
See gh-767

Co-authored-by: Stephane Nicoll <snicoll@vmware.com>
2021-11-22 12:55:22 +01:00
Stephane Nicoll 3290495222 Merge pull request #27699 from quaff
* pr/27699:
  Fix typo

Closes gh-27699
2021-11-22 10:31:13 +01:00
Yanming Zhou b4b3c2ead6 Fix typo
See gh-27699
2021-11-22 10:30:45 +01:00
Jerome Prinet dfd5374f02 Upgrade Gradle enterprise plugin to 3.7.2
Closes gh-27704
2021-11-19 15:06:27 +01:00
Arjen Poutsma 722ab25f27 Support empty file names in UriUtils::extractFileExtension
Closes gh-27639
2021-11-19 12:37:00 +01:00
Sam Brannen c37d6c30a0 Fix nullability declarations in MergedContextConfiguration 2021-11-18 19:23:28 +01:00
Arjen Poutsma 5fbdd6dcfe Throw exception using capturing patterns in AntPathMatcher
Closes gh-27688
2021-11-17 16:52:17 +01:00
d4ksn 29572600dc Ensure that references > MAX_REFERENCE_SIZE are not processed
This commit ensures that only HTML references of length <
MAX_REFERENCE_SIZE are considered as potential references. This check is
possible because reference longer than 10 digits are out of bounds for
Integers.

Closes gh-1249
2021-11-16 15:04:08 +01:00
Spring Builds aaf626a537 Next development version (v5.3.14-SNAPSHOT) 2021-11-11 07:42:44 +00:00
248 changed files with 2225 additions and 1314 deletions
+49 -49
View File
@@ -3,8 +3,8 @@ plugins {
id 'io.spring.nohttp' version '0.0.10'
id "io.freefair.aspectj" version '6.2.0' apply false
id 'org.jetbrains.dokka' version '1.5.0' apply false
id 'org.jetbrains.kotlin.jvm' version '1.5.31' apply false
id "org.jetbrains.kotlin.plugin.serialization" version "1.5.31" apply false
id 'org.jetbrains.kotlin.jvm' version '1.5.32' apply false
id "org.jetbrains.kotlin.plugin.serialization" version "1.5.32" apply false
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'org.asciidoctor.jvm.pdf' version '3.3.2'
id "org.unbroken-dome.xjc" version '2.0.0' apply false
@@ -27,19 +27,19 @@ configure(allprojects) { project ->
dependencyManagement {
imports {
mavenBom "com.fasterxml.jackson:jackson-bom:2.12.5"
mavenBom "io.netty:netty-bom:4.1.70.Final"
mavenBom "io.projectreactor:reactor-bom:2020.0.13"
mavenBom "io.r2dbc:r2dbc-bom:Arabba-SR10"
mavenBom "com.fasterxml.jackson:jackson-bom:2.12.6"
mavenBom "io.netty:netty-bom:4.1.72.Final"
mavenBom "io.projectreactor:reactor-bom:2020.0.15"
mavenBom "io.r2dbc:r2dbc-bom:Arabba-SR11"
mavenBom "io.rsocket:rsocket-bom:1.1.1"
mavenBom "org.eclipse.jetty:jetty-bom:9.4.44.v20210927"
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.5.31"
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.5.32"
mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.5.2"
mavenBom "org.jetbrains.kotlinx:kotlinx-serialization-bom:1.2.2"
mavenBom "org.junit:junit-bom:5.8.1"
mavenBom "org.junit:junit-bom:5.8.2"
}
dependencies {
dependencySet(group: 'org.apache.logging.log4j', version: '2.14.1') {
dependencySet(group: 'org.apache.logging.log4j', version: '2.17.1') {
entry 'log4j-api'
entry 'log4j-core'
entry 'log4j-jul'
@@ -67,23 +67,23 @@ configure(allprojects) { project ->
dependency "io.reactivex:rxjava:1.3.8"
dependency "io.reactivex:rxjava-reactive-streams:1.2.1"
dependency "io.reactivex.rxjava2:rxjava:2.2.21"
dependency "io.reactivex.rxjava3:rxjava:3.1.1"
dependency "io.smallrye.reactive:mutiny:1.1.1"
dependency "io.reactivex.rxjava3:rxjava:3.1.3"
dependency "io.smallrye.reactive:mutiny:1.2.0"
dependency "io.projectreactor.tools:blockhound:1.0.6.RELEASE"
dependency "com.caucho:hessian:4.0.63"
dependency "com.fasterxml:aalto-xml:1.3.0"
dependency("com.fasterxml.woodstox:woodstox-core:6.2.6") {
dependency("com.fasterxml.woodstox:woodstox-core:6.2.7") {
exclude group: "stax", name: "stax-api"
}
dependency "com.google.code.gson:gson:2.8.8"
dependency "com.google.protobuf:protobuf-java-util:3.18.0"
dependency "com.google.code.gson:gson:2.8.9"
dependency "com.google.protobuf:protobuf-java-util:3.19.1"
dependency "com.googlecode.protobuf-java-format:protobuf-java-format:1.4"
dependency("com.thoughtworks.xstream:xstream:1.4.18") {
exclude group: "xpp3", name: "xpp3_min"
exclude group: "xmlpull", name: "xmlpull"
}
dependency "org.apache.johnzon:johnzon-jsonb:1.2.14"
dependency "org.apache.johnzon:johnzon-jsonb:1.2.15"
dependency("org.codehaus.jettison:jettison:1.3.8") {
exclude group: "stax", name: "stax-api"
}
@@ -92,10 +92,10 @@ configure(allprojects) { project ->
entry 'jibx-run'
}
dependency "org.ogce:xpp3:1.1.6"
dependency "org.yaml:snakeyaml:1.29"
dependency "org.yaml:snakeyaml:1.30"
dependency "com.h2database:h2:1.4.200"
dependency "com.github.ben-manes.caffeine:caffeine:2.9.2"
dependency "com.h2database:h2:2.0.206"
dependency "com.github.ben-manes.caffeine:caffeine:2.9.3"
dependency "com.github.librepdf:openpdf:1.3.26"
dependency "com.rometools:rome:1.16.0"
dependency "commons-io:commons-io:2.5"
@@ -123,48 +123,48 @@ configure(allprojects) { project ->
dependency "net.sf.ehcache:ehcache:2.10.6"
dependency "org.ehcache:jcache:1.0.1"
dependency "org.ehcache:ehcache:3.4.0"
dependency "org.hibernate:hibernate-core:5.4.32.Final"
dependency "org.hibernate:hibernate-validator:6.2.0.Final"
dependency "org.hibernate:hibernate-core:5.4.33.Final"
dependency "org.hibernate:hibernate-validator:6.2.1.Final"
dependency "org.webjars:webjars-locator-core:0.48"
dependency "org.webjars:underscorejs:1.8.3"
dependencySet(group: 'org.apache.tomcat', version: '9.0.54') {
dependencySet(group: 'org.apache.tomcat', version: '9.0.56') {
entry 'tomcat-util'
entry('tomcat-websocket') {
exclude group: "org.apache.tomcat", name: "tomcat-websocket-api"
exclude group: "org.apache.tomcat", name: "tomcat-servlet-api"
exclude group: "org.apache.tomcat", name: "tomcat-websocket-api"
}
}
dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.54') {
dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.56') {
entry 'tomcat-embed-core'
entry 'tomcat-embed-websocket'
}
dependencySet(group: 'io.undertow', version: '2.2.12.Final') {
dependencySet(group: 'io.undertow', version: '2.2.14.Final') {
entry 'undertow-core'
entry('undertow-websockets-jsr') {
exclude group: "org.jboss.spec.javax.websocket", name: "jboss-websocket-api_1.1_spec"
}
entry('undertow-servlet') {
exclude group: "org.jboss.spec.javax.servlet", name: "jboss-servlet-api_4.0_spec"
exclude group: "org.jboss.spec.javax.annotation", name: "jboss-annotations-api_1.3_spec"
}
entry('undertow-websockets-jsr') {
exclude group: "org.jboss.spec.javax.websocket", name: "jboss-websocket-api_1.1_spec"
}
}
dependency "org.eclipse.jetty:jetty-reactive-httpclient:1.1.10"
dependency 'org.apache.httpcomponents.client5:httpclient5:5.1.2'
dependency 'org.apache.httpcomponents.core5:httpcore5-reactive:5.1.2'
dependency("org.apache.httpcomponents:httpclient:4.5.13") {
exclude group: "commons-logging", name: "commons-logging"
}
dependency("org.apache.httpcomponents:httpasyncclient:4.1.5") {
exclude group: "commons-logging", name: "commons-logging"
}
dependencySet(group: 'com.squareup.okhttp3', version: '3.14.9') {
entry 'okhttp'
entry 'mockwebserver'
}
dependency("org.apache.httpcomponents:httpclient:4.5.13") {
exclude group: "commons-logging", name: "commons-logging"
}
dependency("org.apache.httpcomponents:httpasyncclient:4.1.4") {
exclude group: "commons-logging", name: "commons-logging"
}
dependency 'org.apache.httpcomponents.client5:httpclient5:5.1'
dependency 'org.apache.httpcomponents.core5:httpcore5-reactive:5.1.1'
dependency "org.eclipse.jetty:jetty-reactive-httpclient:1.1.9"
dependency "org.jruby:jruby:9.2.19.0"
dependency "org.jruby:jruby:9.2.20.1"
dependency "org.python:jython-standalone:2.7.1"
dependency "org.mozilla:rhino:1.7.11"
@@ -191,25 +191,25 @@ configure(allprojects) { project ->
dependency "org.junit.support:testng-engine:1.0.1"
dependency "org.hamcrest:hamcrest:2.1"
dependency "org.awaitility:awaitility:3.1.6"
dependency "org.assertj:assertj-core:3.21.0"
dependencySet(group: 'org.xmlunit', version: '2.8.3') {
dependency "org.assertj:assertj-core:3.22.0"
dependencySet(group: 'org.xmlunit', version: '2.8.4') {
entry 'xmlunit-assertj'
entry('xmlunit-matchers') {
exclude group: "org.hamcrest", name: "hamcrest-core"
}
}
dependencySet(group: 'org.mockito', version: '4.0.0') {
dependencySet(group: 'org.mockito', version: '4.2.0') {
entry('mockito-core') {
exclude group: "org.hamcrest", name: "hamcrest-core"
}
entry 'mockito-junit-jupiter'
}
dependency "io.mockk:mockk:1.12.0"
dependency "io.mockk:mockk:1.12.1"
dependency("net.sourceforge.htmlunit:htmlunit:2.54.0") {
dependency("net.sourceforge.htmlunit:htmlunit:2.56.0") {
exclude group: "commons-logging", name: "commons-logging"
}
dependency("org.seleniumhq.selenium:htmlunit-driver:2.54.0") {
dependency("org.seleniumhq.selenium:htmlunit-driver:2.56.0") {
exclude group: "commons-logging", name: "commons-logging"
}
dependency("org.seleniumhq.selenium:selenium-java:3.141.59") {
@@ -237,7 +237,7 @@ configure(allprojects) { project ->
dependency "com.ibm.websphere:uow:6.0.2.17"
dependency "com.jamonapi:jamon:2.82"
dependency "joda-time:joda-time:2.10.10"
dependency "joda-time:joda-time:2.10.13"
dependency "org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.9"
dependency "org.javamoney:moneta:1.3"
@@ -340,7 +340,7 @@ configure([rootProject] + javaProjects) { project ->
}
checkstyle {
toolVersion = "9.0"
toolVersion = "9.2"
configDirectory.set(rootProject.file("src/checkstyle"))
}
@@ -353,12 +353,12 @@ configure([rootProject] + javaProjects) { project ->
testImplementation("io.mockk:mockk")
testImplementation("org.assertj:assertj-core")
// Pull in the latest JUnit 5 Launcher API to ensure proper support in IDEs.
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testRuntimeOnly("org.junit.platform:junit-platform-suite-engine")
testRuntimeOnly("org.apache.logging.log4j:log4j-core")
testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j-impl")
testRuntimeOnly("org.apache.logging.log4j:log4j-jul")
testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j-impl")
// JSR-305 only used for non-required meta-annotations
compileOnly("com.google.code.findbugs:jsr305")
testCompileOnly("com.google.code.findbugs:jsr305")
@@ -383,9 +383,9 @@ configure([rootProject] + javaProjects) { project ->
"https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/",
"https://projectreactor.io/docs/test/release/api/",
"https://junit.org/junit4/javadoc/4.13.2/",
// Disabling linking to JUnit 5.8.1, since the `package-list` file no longer exists due to
// Disabling linking to JUnit 5.8.2, since the `package-list` file no longer exists due to
// https://github.com/junit-team/junit5/commit/67ad4e545518b0ce2b0e7c96df31a669866d5003.
// "https://junit.org/junit5/docs/5.8.1/api/",
// "https://junit.org/junit5/docs/5.8.2/api/",
"https://www.reactive-streams.org/reactive-streams-1.0.3-javadoc/",
"https://javadoc.io/static/io.rsocket/rsocket-core/1.1.1/",
"https://r2dbc.io/spec/0.8.5.RELEASE/api/"
+1 -1
View File
@@ -1,4 +1,4 @@
version=5.3.13-SNAPSHOT
version=5.3.15
org.gradle.jvmargs=-Xmx1536M
org.gradle.caching=true
org.gradle.parallel=true
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,7 +74,7 @@ class ScheduledAndTransactionalAnnotationIntegrationTests {
MyRepository repository = ctx.getBean(MyRepository.class);
CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
assertThat(AopUtils.isCglibProxy(repository)).isEqualTo(true);
assertThat(AopUtils.isCglibProxy(repository)).isTrue();
assertThat(repository.getInvocationCount()).isGreaterThan(0);
assertThat(txManager.commits).isGreaterThan(0);
}
+1 -1
View File
@@ -6,7 +6,7 @@ pluginManagement {
}
plugins {
id "com.gradle.enterprise" version "3.6.1"
id "com.gradle.enterprise" version "3.7.2"
id "io.spring.ge.conventions" version "0.0.7"
}
@@ -45,9 +45,10 @@ import org.springframework.core.NativeDetector;
* @see AdvisedSupport#setProxyTargetClass
* @see AdvisedSupport#setInterfaces
*/
@SuppressWarnings("serial")
public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
private static final long serialVersionUID = 7930414337282325166L;
@Override
public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException {
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -421,11 +421,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
* are unaffected by such changes.
*/
private synchronized void initializeAdvisorChain() throws AopConfigException, BeansException {
if (this.advisorChainInitialized) {
return;
}
if (!ObjectUtils.isEmpty(this.interceptorNames)) {
if (!this.advisorChainInitialized && !ObjectUtils.isEmpty(this.interceptorNames)) {
if (this.beanFactory == null) {
throw new IllegalStateException("No BeanFactory available anymore (probably due to serialization) " +
"- cannot resolve interceptor names " + Arrays.asList(this.interceptorNames));
@@ -464,9 +460,9 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
addAdvisorOnChainCreation(advice);
}
}
}
this.advisorChainInitialized = true;
this.advisorChainInitialized = true;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,8 +25,8 @@ import org.springframework.aop.Advisor;
import org.springframework.aop.ThrowsAdvice;
/**
* Adapter to enable {@link org.springframework.aop.MethodBeforeAdvice}
* to be used in the Spring AOP framework.
* Adapter to enable {@link org.springframework.aop.ThrowsAdvice} to be used
* in the Spring AOP framework.
*
* @author Rod Johnson
* @author Juergen Hoeller
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -322,7 +322,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
int b = 12;
int c = 25;
String d = "d";
StringBuffer e = new StringBuffer("stringbuf");
StringBuilder e = new StringBuilder("stringbuf");
String expectedResult = a + b+ c + d + e;
assertThat(mva.mungeArgs(a, b, c, d, e)).isEqualTo(expectedResult);
}
@@ -728,12 +728,12 @@ abstract class AbstractAspectJAdvisorFactoryTests {
@Aspect
static class ManyValuedArgs {
String mungeArgs(String a, int b, int c, String d, StringBuffer e) {
String mungeArgs(String a, int b, int c, String d, StringBuilder e) {
return a + b + c + d + e;
}
@Around(value="execution(String mungeArgs(..)) && args(a, b, c, d, e)", argNames="b,c,d,e,a")
String reverseAdvice(ProceedingJoinPoint pjp, int b, int c, String d, StringBuffer e, String a) throws Throwable {
String reverseAdvice(ProceedingJoinPoint pjp, int b, int c, String d, StringBuilder e, String a) throws Throwable {
assertThat(pjp.proceed()).isEqualTo(a + b+ c+ d+ e);
return a + b + c + d + e;
}
@@ -16,9 +16,9 @@
</aop:aspect>
</aop:config>
<bean id="getNameCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="getNameCounter" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="getAgeCounter" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.beans.testfixture.beans.TestBean"/>
@@ -9,6 +9,6 @@
<aop:advisor advice-ref="countingAdvice" pointcut="within(org.springframework..*)"/>
</aop:config>
<bean id="countingAdvice" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="countingAdvice" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
</beans>
@@ -10,6 +10,6 @@
<aop:advisor advice-ref="countingAdvice" pointcut-ref="pc"/>
</aop:config>
<bean id="countingAdvice" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="countingAdvice" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
</beans>
@@ -12,7 +12,7 @@
</aop:aspect>
</aop:config>
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="getAgeCounter" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.beans.testfixture.beans.TestBean"/>
@@ -12,7 +12,7 @@
</aop:aspect>
</aop:config>
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="getAgeCounter" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.beans.testfixture.beans.TestBean"/>
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ package org.springframework.aop.testfixture.advice;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/**
* Abstract superclass for counting advices etc.
@@ -31,7 +32,7 @@ import java.util.HashMap;
public class MethodCounter implements Serializable {
/** Method name --> count, does not understand overloading */
private HashMap<String, Integer> map = new HashMap<>();
private Map<String, Integer> map = new HashMap<>();
private int allCount;
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
@@ -107,10 +106,7 @@ public class AspectJEnableCachingIsolatedTests {
try {
load(MultiCacheManagerConfigurer.class, EnableCachingConfig.class);
}
catch (BeanCreationException ex) {
Throwable root = ex.getRootCause();
boolean condition = root instanceof IllegalStateException;
assertThat(condition).isTrue();
catch (IllegalStateException ex) {
assertThat(ex.getMessage().contains("implementations of CachingConfigurer")).isTrue();
}
}
@@ -214,6 +214,7 @@ public interface BeanFactory {
/**
* Return a provider for the specified bean, allowing for lazy on-demand retrieval
* of instances, including availability and uniqueness options.
* <p>For matching a generic type, consider {@link #getBeanProvider(ResolvableType)}.
* @param requiredType type the bean must match; can be an interface or superclass
* @return a corresponding provider handle
* @since 5.1
@@ -223,13 +224,20 @@ public interface BeanFactory {
/**
* Return a provider for the specified bean, allowing for lazy on-demand retrieval
* of instances, including availability and uniqueness options.
* @param requiredType type the bean must match; can be a generic type declaration.
* Note that collection types are not supported here, in contrast to reflective
* of instances, including availability and uniqueness options. This variant allows
* for specifying a generic type to match, similar to reflective injection points
* with generic type declarations in method/constructor parameters.
* <p>Note that collections of beans are not supported here, in contrast to reflective
* injection points. For programmatically retrieving a list of beans matching a
* specific type, specify the actual bean type as an argument here and subsequently
* use {@link ObjectProvider#orderedStream()} or its lazy streaming/iteration options.
* <p>Also, generics matching is strict here, as per the Java assignment rules.
* For lenient fallback matching with unchecked semantics (similar to the ´unchecked´
* Java compiler warning), consider calling {@link #getBeanProvider(Class)} with the
* raw type as a second step if no full generic match is
* {@link ObjectProvider#getIfAvailable() available} with this variant.
* @return a corresponding provider handle
* @param requiredType type the bean must match; can be a generic type declaration
* @since 5.1
* @see ObjectProvider#iterator()
* @see ObjectProvider#stream()
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -353,9 +353,31 @@ public interface ListableBeanFactory extends BeanFactory {
* @since 3.0
* @see #getBeanNamesForAnnotation
* @see #getBeansWithAnnotation
* @see #getType(String)
*/
@Nullable
<A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
throws NoSuchBeanDefinitionException;
/**
* Find an {@link Annotation} of {@code annotationType} on the specified bean,
* traversing its interfaces and super classes if no annotation can be found on
* the given class itself, as well as checking the bean's factory method (if any).
* @param beanName the name of the bean to look for annotations on
* @param annotationType the type of annotation to look for
* (at class, interface or factory method level of the specified bean)
* @param allowFactoryBeanInit whether a {@code FactoryBean} may get initialized
* just for the purpose of determining its object type
* @return the annotation of the given type if found, or {@code null} otherwise
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
* @since 5.3.14
* @see #getBeanNamesForAnnotation
* @see #getBeansWithAnnotation
* @see #getType(String, boolean)
*/
@Nullable
<A extends Annotation> A findAnnotationOnBean(
String beanName, Class<A> annotationType, boolean allowFactoryBeanInit)
throws NoSuchBeanDefinitionException;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,9 +34,7 @@ import org.springframework.lang.Nullable;
*
* <p><b>NOTE:</b> This interface is a special purpose interface, mainly for
* internal use within the framework. It is recommended to implement the plain
* {@link BeanPostProcessor} interface as far as possible, or to derive from
* {@link InstantiationAwareBeanPostProcessorAdapter} in order to be shielded
* from extensions to this interface.
* {@link BeanPostProcessor} interface as far as possible.
*
* @author Juergen Hoeller
* @author Rod Johnson
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -103,6 +103,14 @@ public abstract class AbstractBeanDefinitionReader implements BeanDefinitionRead
}
/**
* Return the bean factory to register the bean definitions with.
* <p>The factory is exposed through the BeanDefinitionRegistry interface,
* encapsulating the methods that are relevant for bean definition handling.
* @deprecated as of Spring Framework 5.3.15 in favor of {@link #getRegistry()},
* to be removed in Spring Framework 6.0
*/
@Deprecated
public final BeanDefinitionRegistry getBeanFactory() {
return this.registry;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,15 +22,15 @@ import org.springframework.core.io.ResourceLoader;
import org.springframework.lang.Nullable;
/**
* Simple interface for bean definition readers.
* Specifies load methods with Resource and String location parameters.
* Simple interface for bean definition readers that specifies load methods with
* {@link Resource} and {@link String} location parameters.
*
* <p>Concrete bean definition readers can of course add additional
* load and register methods for bean definitions, specific to
* their bean definition format.
*
* <p>Note that a bean definition reader does not have to implement
* this interface. It only serves as suggestion for bean definition
* this interface. It only serves as a suggestion for bean definition
* readers that want to follow standard naming conventions.
*
* @author Juergen Hoeller
@@ -41,14 +41,14 @@ public interface BeanDefinitionReader {
/**
* Return the bean factory to register the bean definitions with.
* <p>The factory is exposed through the BeanDefinitionRegistry interface,
* <p>The factory is exposed through the {@link BeanDefinitionRegistry} interface,
* encapsulating the methods that are relevant for bean definition handling.
*/
BeanDefinitionRegistry getRegistry();
/**
* Return the resource loader to use for resource locations.
* Can be checked for the <b>ResourcePatternResolver</b> interface and cast
* Return the {@link ResourceLoader} to use for resource locations.
* <p>Can be checked for the {@code ResourcePatternResolver} interface and cast
* accordingly, for loading multiple resources for a given resource pattern.
* <p>A {@code null} return value suggests that absolute resource loading
* is not available for this bean definition reader.
@@ -56,10 +56,10 @@ public interface BeanDefinitionReader {
* from within a bean definition resource, for example via the "import"
* tag in XML bean definitions. It is recommended, however, to apply
* such imports relative to the defining resource; only explicit full
* resource locations will trigger absolute resource loading.
* resource locations will trigger absolute path based resource loading.
* <p>There is also a {@code loadBeanDefinitions(String)} method available,
* for loading bean definitions from a resource location (or location pattern).
* This is a convenience to avoid explicit ResourceLoader handling.
* This is a convenience to avoid explicit {@code ResourceLoader} handling.
* @see #loadBeanDefinitions(String)
* @see org.springframework.core.io.support.ResourcePatternResolver
*/
@@ -70,13 +70,13 @@ public interface BeanDefinitionReader {
* Return the class loader to use for bean classes.
* <p>{@code null} suggests to not load bean classes eagerly
* but rather to just register bean definitions with class names,
* with the corresponding Classes to be resolved later (or never).
* with the corresponding classes to be resolved later (or never).
*/
@Nullable
ClassLoader getBeanClassLoader();
/**
* Return the BeanNameGenerator to use for anonymous beans
* Return the {@link BeanNameGenerator} to use for anonymous beans
* (without explicit bean name specified).
*/
BeanNameGenerator getBeanNameGenerator();
@@ -101,9 +101,10 @@ public interface BeanDefinitionReader {
/**
* Load bean definitions from the specified resource location.
* <p>The location can also be a location pattern, provided that the
* ResourceLoader of this bean definition reader is a ResourcePatternResolver.
* @param location the resource location, to be loaded with the ResourceLoader
* (or ResourcePatternResolver) of this bean definition reader
* {@link ResourceLoader} of this bean definition reader is a
* {@code ResourcePatternResolver}.
* @param location the resource location, to be loaded with the {@code ResourceLoader}
* (or {@code ResourcePatternResolver}) of this bean definition reader
* @return the number of bean definitions found
* @throws BeanDefinitionStoreException in case of loading or parsing errors
* @see #getResourceLoader()
@@ -114,8 +115,8 @@ public interface BeanDefinitionReader {
/**
* Load bean definitions from the specified resource locations.
* @param locations the resource locations, to be loaded with the ResourceLoader
* (or ResourcePatternResolver) of this bean definition reader
* @param locations the resource locations, to be loaded with the {@code ResourceLoader}
* (or {@code ResourcePatternResolver}) of this bean definition reader
* @return the number of bean definitions found
* @throws BeanDefinitionStoreException in case of loading or parsing errors
*/
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -730,14 +730,23 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
throws NoSuchBeanDefinitionException {
return findMergedAnnotationOnBean(beanName, annotationType)
return findAnnotationOnBean(beanName, annotationType, true);
}
@Override
@Nullable
public <A extends Annotation> A findAnnotationOnBean(
String beanName, Class<A> annotationType, boolean allowFactoryBeanInit)
throws NoSuchBeanDefinitionException {
return findMergedAnnotationOnBean(beanName, annotationType, allowFactoryBeanInit)
.synthesize(MergedAnnotation::isPresent).orElse(null);
}
private <A extends Annotation> MergedAnnotation<A> findMergedAnnotationOnBean(
String beanName, Class<A> annotationType) {
String beanName, Class<A> annotationType, boolean allowFactoryBeanInit) {
Class<?> beanType = getType(beanName);
Class<?> beanType = getType(beanName, allowFactoryBeanInit);
if (beanType != null) {
MergedAnnotation<A> annotation =
MergedAnnotations.from(beanType, SearchStrategy.TYPE_HIERARCHY).get(annotationType);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -459,7 +459,16 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
throws NoSuchBeanDefinitionException {
Class<?> beanType = getType(beanName);
return findAnnotationOnBean(beanName, annotationType, true);
}
@Override
@Nullable
public <A extends Annotation> A findAnnotationOnBean(
String beanName, Class<A> annotationType, boolean allowFactoryBeanInit)
throws NoSuchBeanDefinitionException {
Class<?> beanType = getType(beanName, allowFactoryBeanInit);
return (beanType != null ? AnnotatedElementUtils.findMergedAnnotation(beanType, annotationType) : null);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ public class BeanWrapperEnumTests {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnum", null);
assertThat(gb.getCustomEnum()).isEqualTo(null);
assertThat(gb.getCustomEnum()).isNull();
}
@Test
@@ -54,7 +54,7 @@ public class BeanWrapperEnumTests {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnum", "");
assertThat(gb.getCustomEnum()).isEqualTo(null);
assertThat(gb.getCustomEnum()).isNull();
}
@Test
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -433,7 +433,7 @@ class DefaultListableBeanFactoryTests {
assertThat(lbf.isTypeMatch("x1", Object.class)).isTrue();
assertThat(lbf.isTypeMatch("&x1", Object.class)).isFalse();
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
assertThat(lbf.getType("&x1")).isEqualTo(null);
assertThat(lbf.getType("&x1")).isNull();
assertThat(TestBeanFactory.initialized).isFalse();
lbf.registerAlias("x1", "x2");
@@ -2622,8 +2622,8 @@ class DefaultListableBeanFactoryTests {
void containsBeanReturnsTrueEvenForAbstractBeanDefinition() {
lbf.registerBeanDefinition("abs", BeanDefinitionBuilder
.rootBeanDefinition(TestBean.class).setAbstract(true).getBeanDefinition());
assertThat(lbf.containsBean("abs")).isEqualTo(true);
assertThat(lbf.containsBean("bogus")).isEqualTo(false);
assertThat(lbf.containsBean("abs")).isTrue();
assertThat(lbf.containsBean("bogus")).isFalse();
}
@Test
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -111,7 +111,7 @@ public class PropertyResourceConfigurerTests {
assertThat(tb1.getAge()).isEqualTo(99);
assertThat(tb2.getAge()).isEqualTo(99);
assertThat(tb1.getName()).isEqualTo(null);
assertThat(tb1.getName()).isNull();
assertThat(tb2.getName()).isEqualTo("test");
}
@@ -310,7 +310,7 @@ public class PropertyResourceConfigurerTests {
TestBean tb2 = (TestBean) factory.getBean("tb2");
assertThat(tb1.getAge()).isEqualTo(99);
assertThat(tb2.getAge()).isEqualTo(99);
assertThat(tb1.getName()).isEqualTo(null);
assertThat(tb1.getName()).isNull();
assertThat(tb2.getName()).isEqualTo("test");
}
@@ -423,7 +423,7 @@ public class PropertyResourceConfigurerTests {
TestBean inner1 = (TestBean) tb2.getSomeMap().get("key3");
TestBean inner2 = (TestBean) tb2.getSomeMap().get("mykey4");
assertThat(inner1.getAge()).isEqualTo(0);
assertThat(inner1.getName()).isEqualTo(null);
assertThat(inner1.getName()).isNull();
assertThat(inner1.getCountry()).isEqualTo(System.getProperty("os.name"));
assertThat(inner2.getAge()).isEqualTo(98);
assertThat(inner2.getName()).isEqualTo("namemyvarmyvar${");
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -449,7 +449,7 @@ public class CallbacksSecurityTests {
public Object run() {
// sanity check
assertThat(getCurrentSubjectName()).isEqualTo("user1");
assertThat(NonPrivilegedBean.destroyed).isEqualTo(false);
assertThat(NonPrivilegedBean.destroyed).isFalse();
beanFactory.getBean("trusted-spring-callbacks");
beanFactory.getBean("trusted-custom-init-destroy");
@@ -465,7 +465,7 @@ public class CallbacksSecurityTests {
beanFactory.getBean("trusted-working-property-injection");
beanFactory.destroySingletons();
assertThat(NonPrivilegedBean.destroyed).isEqualTo(true);
assertThat(NonPrivilegedBean.destroyed).isTrue();
return null;
}
}, provider.getAccessControlContext());
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -100,17 +100,17 @@ public class FactoryMethodTests {
FactoryMethods fm = (FactoryMethods) xbf.getBean("fullWithNull");
assertThat(fm.getNum()).isEqualTo(27);
assertThat(fm.getName()).isEqualTo(null);
assertThat(fm.getName()).isNull();
assertThat(fm.getTestBean().getName()).isEqualTo("Juergen");
fm = (FactoryMethods) xbf.getBean("fullWithGenericNull");
assertThat(fm.getNum()).isEqualTo(27);
assertThat(fm.getName()).isEqualTo(null);
assertThat(fm.getName()).isNull();
assertThat(fm.getTestBean().getName()).isEqualTo("Juergen");
fm = (FactoryMethods) xbf.getBean("fullWithNamedNull");
assertThat(fm.getNum()).isEqualTo(27);
assertThat(fm.getName()).isEqualTo(null);
assertThat(fm.getName()).isNull();
assertThat(fm.getTestBean().getName()).isEqualTo("Juergen");
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -342,7 +342,7 @@ public class UtilNamespaceHandlerTests {
public void testLoadProperties() {
Properties props = (Properties) this.beanFactory.getBean("myProperties");
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar");
assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo(null);
assertThat(props.get("foo2")).as("Incorrect property value").isNull();
Properties props2 = (Properties) this.beanFactory.getBean("myProperties");
assertThat(props == props2).isTrue();
}
@@ -351,17 +351,17 @@ public class UtilNamespaceHandlerTests {
public void testScopedProperties() {
Properties props = (Properties) this.beanFactory.getBean("myScopedProperties");
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar");
assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo(null);
assertThat(props.get("foo2")).as("Incorrect property value").isNull();
Properties props2 = (Properties) this.beanFactory.getBean("myScopedProperties");
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar");
assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo(null);
assertThat(props.get("foo2")).as("Incorrect property value").isNull();
assertThat(props != props2).isTrue();
}
@Test
public void testLocalProperties() {
Properties props = (Properties) this.beanFactory.getBean("myLocalProperties");
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo(null);
assertThat(props.get("foo")).as("Incorrect property value").isNull();
assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo("bar2");
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -283,7 +283,7 @@ public class XmlBeanCollectionTests {
Iterator it = hasMap.getSet().iterator();
assertThat(it.next()).isEqualTo("bar");
assertThat(it.next()).isEqualTo(jenny);
assertThat(it.next()).isEqualTo(null);
assertThat(it.next()).isNull();
}
@Test
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -181,7 +181,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
assertThat(beanNames.contains("aliasWithoutId3")).isFalse();
TestBean tb4 = (TestBean) getBeanFactory().getBean(TestBean.class.getName() + "#0");
assertThat(tb4.getName()).isEqualTo(null);
assertThat(tb4.getName()).isNull();
Map drs = getListableBeanFactory().getBeansOfType(DummyReferencer.class, false, false);
assertThat(drs.size()).isEqualTo(5);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@ import java.util.function.Supplier;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.cache.annotation.AbstractCachingConfiguration;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.interceptor.CacheResolver;
import org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource;
import org.springframework.cache.jcache.interceptor.JCacheOperationSource;
@@ -46,11 +45,14 @@ public abstract class AbstractJCacheConfiguration extends AbstractCachingConfigu
@Override
protected void useCachingConfigurer(CachingConfigurer config) {
super.useCachingConfigurer(config);
if (config instanceof JCacheConfigurer) {
this.exceptionCacheResolver = ((JCacheConfigurer) config)::exceptionCacheResolver;
}
protected void useCachingConfigurer(CachingConfigurerSupplier cachingConfigurerSupplier) {
super.useCachingConfigurer(cachingConfigurerSupplier);
this.exceptionCacheResolver = cachingConfigurerSupplier.adapt(config -> {
if (config instanceof JCacheConfigurer) {
return ((JCacheConfigurer) config).exceptionCacheResolver();
}
return null;
});
}
@Bean(name = "jCacheOperationSource")
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,8 +26,7 @@ import org.springframework.lang.Nullable;
* <p>To be implemented by classes annotated with
* {@link org.springframework.cache.annotation.EnableCaching} that wish
* or need to specify explicitly how exception caches are resolved for
* annotation-driven cache management. Consider extending {@link JCacheConfigurerSupport},
* which provides a stub implementation of all interface methods.
* annotation-driven cache management.
*
* <p>See {@link org.springframework.cache.annotation.EnableCaching} for
* general examples and context; see {@link #exceptionCacheResolver()} for
@@ -36,7 +35,6 @@ import org.springframework.lang.Nullable;
* @author Stephane Nicoll
* @since 4.1
* @see CachingConfigurer
* @see JCacheConfigurerSupport
* @see org.springframework.cache.annotation.EnableCaching
*/
public interface JCacheConfigurer extends CachingConfigurer {
@@ -60,6 +58,8 @@ public interface JCacheConfigurer extends CachingConfigurer {
* See {@link org.springframework.cache.annotation.EnableCaching} for more complete examples.
*/
@Nullable
CacheResolver exceptionCacheResolver();
default CacheResolver exceptionCacheResolver() {
return null;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -79,7 +79,7 @@ public abstract class AbstractFallbackJCacheOperationSource implements JCacheOpe
@Nullable
private JCacheOperation<?> computeCacheOperation(Method method, @Nullable Class<?> targetClass) {
// Don't allow no-public methods as required.
// Don't allow non-public methods, as configured.
if (allowPublicMethodsOnly() && !Modifier.isPublic(method.getModifiers())) {
return null;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,6 +39,8 @@ import org.springframework.lang.Nullable;
* Subclass of Quartz's {@link JobStoreCMT} class that delegates to a Spring-managed
* {@link DataSource} instead of using a Quartz-managed JDBC connection pool.
* This JobStore will be used if SchedulerFactoryBean's "dataSource" property is set.
* You may also configure it explicitly, possibly as a custom subclass of this
* {@code LocalDataSourceJobStore} or as an equivalent {@code JobStoreCMT} variant.
*
* <p>Supports both transactional and non-transactional DataSource access.
* With a non-XA DataSource and local Spring transactions, a single DataSource
@@ -58,6 +60,8 @@ import org.springframework.lang.Nullable;
* @since 1.1
* @see SchedulerFactoryBean#setDataSource
* @see SchedulerFactoryBean#setNonTransactionalDataSource
* @see SchedulerFactoryBean#getConfigTimeDataSource()
* @see SchedulerFactoryBean#getConfigTimeNonTransactionalDataSource()
* @see org.springframework.jdbc.datasource.DataSourceUtils#doGetConnection
* @see org.springframework.jdbc.datasource.DataSourceUtils#releaseConnection
*/
@@ -310,9 +310,11 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
/**
* Set the default {@link DataSource} to be used by the Scheduler.
* If set, this will override corresponding settings in Quartz properties.
* <p>Note: If this is set, the Quartz settings should not define
* a job store "dataSource" to avoid meaningless double configuration.
* Also, do not define a "org.quartz.jobStore.class" property at all.
* (You may explicitly define Spring's {@link LocalDataSourceJobStore}
* but that's the default when using this method anyway.)
* <p>A Spring-specific subclass of Quartz' JobStoreCMT will be used.
* It is therefore strongly recommended to perform all operations on
* the Scheduler within Spring-managed (or plain JTA) transactions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -106,7 +106,7 @@ class CaffeineCacheTests extends AbstractValueAdaptingCacheTests<CaffeineCache>
Cache.ValueWrapper wrapper = cache.putIfAbsent(key, "anotherValue");
// A value is set but is 'null'
assertThat(wrapper).isNotNull();
assertThat(wrapper.get()).isEqualTo(null);
assertThat(wrapper.get()).isNull();
// not changed
assertThat(cache.get(key).get()).isEqualTo(value);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.cache.interceptor.SimpleKeyGenerator;
@@ -104,7 +104,7 @@ public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests {
@Configuration
@EnableCaching
static class EnableCachingConfig extends CachingConfigurerSupport {
static class EnableCachingConfig implements CachingConfigurer {
@Autowired
CachingProvider cachingProvider;
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -180,7 +180,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests {
@Configuration
@EnableCaching
public static class EmptyConfigSupportConfig extends JCacheConfigurerSupport {
public static class EmptyConfigSupportConfig implements JCacheConfigurer {
@Bean
public CacheManager cm() {
return new NoOpCacheManager();
@@ -190,7 +190,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests {
@Configuration
@EnableCaching
static class FullCachingConfigSupport extends JCacheConfigurerSupport {
static class FullCachingConfigSupport implements JCacheConfigurer {
@Override
@Bean
@@ -220,7 +220,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests {
@Configuration
@EnableCaching
static class NoExceptionCacheResolverConfig extends JCacheConfigurerSupport {
static class NoExceptionCacheResolverConfig implements JCacheConfigurer {
@Override
@Bean
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.SimpleKeyGenerator;
import org.springframework.cache.jcache.config.JCacheConfigurerSupport;
import org.springframework.cache.jcache.config.JCacheConfigurer;
import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -141,7 +141,7 @@ public class JCacheErrorHandlerTests {
@Configuration
@EnableCaching
static class Config extends JCacheConfigurerSupport {
static class Config implements JCacheConfigurer {
@Bean
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.cache.interceptor.SimpleKey;
import org.springframework.cache.interceptor.SimpleKeyGenerator;
import org.springframework.cache.jcache.config.JCacheConfigurerSupport;
import org.springframework.cache.jcache.config.JCacheConfigurer;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -97,7 +97,7 @@ public class JCacheKeyGeneratorTests {
@Configuration
@EnableCaching
static class Config extends JCacheConfigurerSupport {
static class Config implements JCacheConfigurer {
@Bean
@Override
@@ -151,7 +151,7 @@ public class JCacheKeyGeneratorTests {
@Override
public Object generate(Object target, Method method, Object... params) {
assertThat(Arrays.equals(expectedParams, params)).as("Unexpected parameters: expected: "
+ Arrays.toString(this.expectedParams) + " but got: " + Arrays.toString(params)).isTrue();
+ Arrays.toString(this.expectedParams) + " but got: " + Arrays.toString(params)).isTrue();
return new SimpleKey(params);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,12 @@
package org.springframework.cache.annotation;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.cache.interceptor.CacheErrorHandler;
@@ -30,6 +33,7 @@ import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
import org.springframework.util.function.SingletonSupplier;
/**
* Abstract base {@code @Configuration} class providing common structure
@@ -63,36 +67,67 @@ public abstract class AbstractCachingConfiguration implements ImportAware {
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
this.enableCaching = AnnotationAttributes.fromMap(
importMetadata.getAnnotationAttributes(EnableCaching.class.getName(), false));
importMetadata.getAnnotationAttributes(EnableCaching.class.getName()));
if (this.enableCaching == null) {
throw new IllegalArgumentException(
"@EnableCaching is not present on importing class " + importMetadata.getClassName());
}
}
@Autowired(required = false)
void setConfigurers(Collection<CachingConfigurer> configurers) {
if (CollectionUtils.isEmpty(configurers)) {
return;
}
if (configurers.size() > 1) {
throw new IllegalStateException(configurers.size() + " implementations of " +
"CachingConfigurer were found when only 1 was expected. " +
"Refactor the configuration such that CachingConfigurer is " +
"implemented only once or not at all.");
}
CachingConfigurer configurer = configurers.iterator().next();
useCachingConfigurer(configurer);
@Autowired
void setConfigurers(ObjectProvider<CachingConfigurer> configurers) {
Supplier<CachingConfigurer> configurer = () -> {
List<CachingConfigurer> candidates = configurers.stream().collect(Collectors.toList());
if (CollectionUtils.isEmpty(candidates)) {
return null;
}
if (candidates.size() > 1) {
throw new IllegalStateException(candidates.size() + " implementations of " +
"CachingConfigurer were found when only 1 was expected. " +
"Refactor the configuration such that CachingConfigurer is " +
"implemented only once or not at all.");
}
return candidates.get(0);
};
useCachingConfigurer(new CachingConfigurerSupplier(configurer));
}
/**
* Extract the configuration from the nominated {@link CachingConfigurer}.
*/
protected void useCachingConfigurer(CachingConfigurer config) {
this.cacheManager = config::cacheManager;
this.cacheResolver = config::cacheResolver;
this.keyGenerator = config::keyGenerator;
this.errorHandler = config::errorHandler;
protected void useCachingConfigurer(CachingConfigurerSupplier cachingConfigurerSupplier) {
this.cacheManager = cachingConfigurerSupplier.adapt(CachingConfigurer::cacheManager);
this.cacheResolver = cachingConfigurerSupplier.adapt(CachingConfigurer::cacheResolver);
this.keyGenerator = cachingConfigurerSupplier.adapt(CachingConfigurer::keyGenerator);
this.errorHandler = cachingConfigurerSupplier.adapt(CachingConfigurer::errorHandler);
}
protected static class CachingConfigurerSupplier {
private final Supplier<CachingConfigurer> supplier;
public CachingConfigurerSupplier(Supplier<CachingConfigurer> supplier) {
this.supplier = SingletonSupplier.of(supplier);
}
/**
* Adapt the {@link CachingConfigurer} supplier to another supplier
* provided by the specified mapping function. If the underlying
* {@link CachingConfigurer} is {@code null}, {@code null} is returned
* and the mapping function is not invoked.
* @param provider the provider to use to adapt the supplier
* @param <T> the type of the supplier
* @return another supplier mapped by the specified function
*/
@Nullable
public <T> Supplier<T> adapt(Function<CachingConfigurer, T> provider) {
return () -> {
CachingConfigurer cachingConfigurer = this.supplier.get();
return (cachingConfigurer != null ? provider.apply(cachingConfigurer) : null);
};
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,8 +26,7 @@ import org.springframework.lang.Nullable;
* Interface to be implemented by @{@link org.springframework.context.annotation.Configuration
* Configuration} classes annotated with @{@link EnableCaching} that wish or need to
* specify explicitly how caches are resolved and how keys are generated for annotation-driven
* cache management. Consider extending {@link CachingConfigurerSupport}, which provides a
* stub implementation of all interface methods.
* cache management.
*
* <p>See @{@link EnableCaching} for general examples and context; see
* {@link #cacheManager()}, {@link #cacheResolver()} and {@link #keyGenerator()}
@@ -37,7 +36,6 @@ import org.springframework.lang.Nullable;
* @author Stephane Nicoll
* @since 3.1
* @see EnableCaching
* @see CachingConfigurerSupport
*/
public interface CachingConfigurer {
@@ -64,7 +62,9 @@ public interface CachingConfigurer {
* See @{@link EnableCaching} for more complete examples.
*/
@Nullable
CacheManager cacheManager();
default CacheManager cacheManager() {
return null;
}
/**
* Return the {@link CacheResolver} bean to use to resolve regular caches for
@@ -89,7 +89,9 @@ public interface CachingConfigurer {
* See {@link EnableCaching} for more complete examples.
*/
@Nullable
CacheResolver cacheResolver();
default CacheResolver cacheResolver() {
return null;
}
/**
* Return the key generator bean to use for annotation-driven cache management.
@@ -110,7 +112,9 @@ public interface CachingConfigurer {
* See @{@link EnableCaching} for more complete examples.
*/
@Nullable
KeyGenerator keyGenerator();
default KeyGenerator keyGenerator() {
return null;
}
/**
* Return the {@link CacheErrorHandler} to use to handle cache-related errors.
@@ -133,6 +137,8 @@ public interface CachingConfigurer {
* See @{@link EnableCaching} for more complete examples.
*/
@Nullable
CacheErrorHandler errorHandler();
default CacheErrorHandler errorHandler() {
return null;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -124,7 +124,7 @@ public abstract class AbstractFallbackCacheOperationSource implements CacheOpera
@Nullable
private Collection<CacheOperation> computeCacheOperations(Method method, @Nullable Class<?> targetClass) {
// Don't allow no-public methods as required.
// Don't allow non-public methods, as configured.
if (allowPublicMethodsOnly() && !Modifier.isPublic(method.getModifiers())) {
return null;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,9 +47,10 @@ import org.springframework.util.StringUtils;
*
* <p>If the annotation's value doesn't indicate a bean name, an appropriate
* name will be built based on the short name of the class (with the first
* letter lower-cased). For example:
* letter lower-cased), unless the two first letters are uppercase. For example:
*
* <pre class="code">com.xyz.FooServiceImpl -&gt; fooServiceImpl</pre>
* <pre class="code">com.xyz.URLFooServiceImpl -&gt; URLFooServiceImpl</pre>
*
* @author Juergen Hoeller
* @author Mark Fisher
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -282,7 +282,7 @@ public abstract class AnnotationConfigUtils {
@Nullable
static AnnotationAttributes attributesFor(AnnotatedTypeMetadata metadata, String annotationClassName) {
return AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(annotationClassName, false));
return AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(annotationClassName));
}
static Set<AnnotationAttributes> attributesForRepeatable(AnnotationMetadata metadata,
@@ -298,10 +298,10 @@ public abstract class AnnotationConfigUtils {
Set<AnnotationAttributes> result = new LinkedHashSet<>();
// Direct annotation present?
addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationClassName, false));
addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationClassName));
// Container annotation present?
Map<String, Object> container = metadata.getAnnotationAttributes(containerClassName, false);
Map<String, Object> container = metadata.getAnnotationAttributes(containerClassName);
if (container != null && container.containsKey("value")) {
for (Map<String, Object> containedAttributes : (Map<String, Object>[]) container.get("value")) {
addAttributesIfNotNull(result, containedAttributes);
@@ -1331,6 +1331,16 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
return getBeanFactory().findAnnotationOnBean(beanName, annotationType);
}
@Override
@Nullable
public <A extends Annotation> A findAnnotationOnBean(
String beanName, Class<A> annotationType, boolean allowFactoryBeanInit)
throws NoSuchBeanDefinitionException {
assertBeanFactoryActive();
return getBeanFactory().findAnnotationOnBean(beanName, annotationType, allowFactoryBeanInit);
}
//---------------------------------------------------------------------
// Implementation of HierarchicalBeanFactory interface
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,11 +16,14 @@
package org.springframework.scheduling.annotation;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportAware;
@@ -28,6 +31,7 @@ import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.Nullable;
import org.springframework.util.CollectionUtils;
import org.springframework.util.function.SingletonSupplier;
/**
* Abstract base {@code Configuration} class providing common structure for enabling
@@ -55,7 +59,7 @@ public abstract class AbstractAsyncConfiguration implements ImportAware {
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
this.enableAsync = AnnotationAttributes.fromMap(
importMetadata.getAnnotationAttributes(EnableAsync.class.getName(), false));
importMetadata.getAnnotationAttributes(EnableAsync.class.getName()));
if (this.enableAsync == null) {
throw new IllegalArgumentException(
"@EnableAsync is not present on importing class " + importMetadata.getClassName());
@@ -65,17 +69,27 @@ public abstract class AbstractAsyncConfiguration implements ImportAware {
/**
* Collect any {@link AsyncConfigurer} beans through autowiring.
*/
@Autowired(required = false)
void setConfigurers(Collection<AsyncConfigurer> configurers) {
if (CollectionUtils.isEmpty(configurers)) {
return;
}
if (configurers.size() > 1) {
throw new IllegalStateException("Only one AsyncConfigurer may exist");
}
AsyncConfigurer configurer = configurers.iterator().next();
this.executor = configurer::getAsyncExecutor;
this.exceptionHandler = configurer::getAsyncUncaughtExceptionHandler;
@Autowired
void setConfigurers(ObjectProvider<AsyncConfigurer> configurers) {
Supplier<AsyncConfigurer> configurer = SingletonSupplier.of(() -> {
List<AsyncConfigurer> candidates = configurers.stream().collect(Collectors.toList());
if (CollectionUtils.isEmpty(candidates)) {
return null;
}
if (candidates.size() > 1) {
throw new IllegalStateException("Only one AsyncConfigurer may exist");
}
return candidates.get(0);
});
this.executor = adapt(configurer, AsyncConfigurer::getAsyncExecutor);
this.exceptionHandler = adapt(configurer, AsyncConfigurer::getAsyncUncaughtExceptionHandler);
}
private <T> Supplier<T> adapt(Supplier<AsyncConfigurer> supplier, Function<AsyncConfigurer, T> provider) {
return () -> {
AsyncConfigurer configurer = supplier.get();
return (configurer != null ? provider.apply(configurer) : null);
};
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,11 +28,6 @@ import org.springframework.lang.Nullable;
* {@link AsyncUncaughtExceptionHandler} instance used to process exception thrown from
* async method with {@code void} return type.
*
* <p>Consider using {@link AsyncConfigurerSupport} providing default implementations for
* both methods if only one element needs to be customized. Furthermore, backward compatibility
* of this interface will be insured in case new customization options are introduced
* in the future.
*
* <p>See @{@link EnableAsync} for usage examples.
*
* @author Chris Beams
@@ -40,7 +35,6 @@ import org.springframework.lang.Nullable;
* @since 3.1
* @see AbstractAsyncConfiguration
* @see EnableAsync
* @see AsyncConfigurerSupport
*/
public interface AsyncConfigurer {
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,9 +26,7 @@ import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.lang.Nullable;
/**
@@ -65,7 +63,7 @@ import org.springframework.lang.Nullable;
*/
@SuppressWarnings("serial")
public class ThreadPoolExecutorFactoryBean extends ExecutorConfigurationSupport
implements FactoryBean<ExecutorService>, InitializingBean, DisposableBean {
implements FactoryBean<ExecutorService> {
private int corePoolSize = 1;
@@ -75,6 +73,8 @@ public class ThreadPoolExecutorFactoryBean extends ExecutorConfigurationSupport
private boolean allowCoreThreadTimeOut = false;
private boolean prestartAllCoreThreads = false;
private int queueCapacity = Integer.MAX_VALUE;
private boolean exposeUnconfigurableExecutor = false;
@@ -118,6 +118,16 @@ public class ThreadPoolExecutorFactoryBean extends ExecutorConfigurationSupport
this.allowCoreThreadTimeOut = allowCoreThreadTimeOut;
}
/**
* Specify whether to start all core threads, causing them to idly wait for work.
* <p>Default is "false".
* @since 5.3.14
* @see java.util.concurrent.ThreadPoolExecutor#prestartAllCoreThreads
*/
public void setPrestartAllCoreThreads(boolean prestartAllCoreThreads) {
this.prestartAllCoreThreads = prestartAllCoreThreads;
}
/**
* Set the capacity for the ThreadPoolExecutor's BlockingQueue.
* Default is {@code Integer.MAX_VALUE}.
@@ -153,6 +163,9 @@ public class ThreadPoolExecutorFactoryBean extends ExecutorConfigurationSupport
if (this.allowCoreThreadTimeOut) {
executor.allowCoreThreadTimeOut(true);
}
if (this.prestartAllCoreThreads) {
executor.prestartAllCoreThreads();
}
// Wrap executor with an unconfigurable decorator.
this.exposedExecutor = (this.exposeUnconfigurableExecutor ?
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -94,6 +94,8 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
private boolean allowCoreThreadTimeOut = false;
private boolean prestartAllCoreThreads = false;
@Nullable
private TaskDecorator taskDecorator;
@@ -197,6 +199,16 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
this.allowCoreThreadTimeOut = allowCoreThreadTimeOut;
}
/**
* Specify whether to start all core threads, causing them to idly wait for work.
* <p>Default is "false".
* @since 5.3.14
* @see java.util.concurrent.ThreadPoolExecutor#prestartAllCoreThreads
*/
public void setPrestartAllCoreThreads(boolean prestartAllCoreThreads) {
this.prestartAllCoreThreads = prestartAllCoreThreads;
}
/**
* Specify a custom {@link TaskDecorator} to be applied to any {@link Runnable}
* about to be executed.
@@ -256,6 +268,9 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
if (this.allowCoreThreadTimeOut) {
executor.allowCoreThreadTimeOut(true);
}
if (this.prestartAllCoreThreads) {
executor.prestartAllCoreThreads();
}
this.threadPoolExecutor = executor;
return executor;
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -418,11 +418,13 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
}
/**
* Register fields that should be allowed for binding. Default is all
* fields. Restrict this for example to avoid unwanted modifications
* by malicious users when binding HTTP request parameters.
* <p>Supports "xxx*", "*xxx" and "*xxx*" patterns. More sophisticated matching
* can be implemented by overriding the {@code isAllowed} method.
* Register fields that should be allowed for binding. Default is all fields.
* Restrict this for example to avoid unwanted modifications by malicious
* users when binding HTTP request parameters.
* <p>Supports "xxx*", "*xxx", "*xxx*" and "xxx*yyy" matches (with an
* arbitrary number of pattern parts), as well as direct equality. More
* sophisticated matching can be implemented by overriding the
* {@code isAllowed} method.
* <p>Alternatively, specify a list of <i>disallowed</i> fields.
* @param allowedFields array of field names
* @see #setDisallowedFields
@@ -442,11 +444,13 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
}
/**
* Register fields that should <i>not</i> be allowed for binding. Default is none.
* Mark fields as disallowed for example to avoid unwanted modifications
* by malicious users when binding HTTP request parameters.
* <p>Supports "xxx*", "*xxx" and "*xxx*" patterns. More sophisticated matching
* can be implemented by overriding the {@code isAllowed} method.
* Register fields that should <i>not</i> be allowed for binding. Default
* is none. Mark fields as disallowed for example to avoid unwanted
* modifications by malicious users when binding HTTP request parameters.
* <p>Supports "xxx*", "*xxx", "*xxx*" and "xxx*yyy" matches (with an
* arbitrary number of pattern parts), as well as direct equality.
* More sophisticated matching can be implemented by overriding the
* {@code isAllowed} method.
* <p>Alternatively, specify a list of <i>allowed</i> fields.
* @param disallowedFields array of field names
* @see #setAllowedFields
@@ -772,10 +776,11 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
/**
* Return if the given field is allowed for binding.
* Invoked for each passed-in property value.
* <p>The default implementation checks for "xxx*", "*xxx" and "*xxx*" matches,
* as well as direct equality, in the specified lists of allowed fields and
* disallowed fields. A field matching a disallowed pattern will not be accepted
* even if it also happens to match a pattern in the allowed list.
* <p>The default implementation checks for "xxx*", "*xxx", "*xxx*" and "xxx*yyy"
* matches (with an arbitrary number of pattern parts), as well as direct equality,
* in the specified lists of allowed fields and disallowed fields. A field matching
* a disallowed pattern will not be accepted even if it also happens to match a
* pattern in the allowed list.
* <p>Can be overridden in subclasses.
* @param field the field to check
* @return if the field is allowed
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,10 +65,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIOException;
/**
* @since 13.03.2003
* @author Rod Johnson
* @author Juergen Hoeller
* @author Chris Beams
* @since 13.03.2003
*/
public class ProxyFactoryBeanTests {
@@ -633,20 +633,50 @@ public class ProxyFactoryBeanTests {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(FROZEN_CONTEXT, CLASS));
Advised advised = (Advised)bf.getBean("frozen");
Advised advised = (Advised) bf.getBean("frozen");
assertThat(advised.isFrozen()).as("The proxy should be frozen").isTrue();
}
@Test
public void testDetectsInterfaces() throws Exception {
public void testDetectsInterfaces() {
ProxyFactoryBean fb = new ProxyFactoryBean();
fb.setTarget(new TestBean());
fb.addAdvice(new DebugInterceptor());
fb.setBeanFactory(new DefaultListableBeanFactory());
ITestBean proxy = (ITestBean) fb.getObject();
assertThat(AopUtils.isJdkDynamicProxy(proxy)).isTrue();
}
@Test
public void testWithInterceptorNames() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.registerSingleton("debug", new DebugInterceptor());
ProxyFactoryBean fb = new ProxyFactoryBean();
fb.setTarget(new TestBean());
fb.setInterceptorNames("debug");
fb.setBeanFactory(bf);
Advised proxy = (Advised) fb.getObject();
assertThat(proxy.getAdvisorCount()).isEqualTo(1);
}
@Test
public void testWithLateInterceptorNames() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.registerSingleton("debug", new DebugInterceptor());
ProxyFactoryBean fb = new ProxyFactoryBean();
fb.setTarget(new TestBean());
fb.setBeanFactory(bf);
fb.getObject();
fb.setInterceptorNames("debug");
Advised proxy = (Advised) fb.getObject();
assertThat(proxy.getAdvisorCount()).isEqualTo(1);
}
/**
* Fires only on void methods. Saves list of methods intercepted.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -196,7 +196,7 @@ class CommonsPool2TargetSourceTests {
void testSetWhenExhaustedAction() {
CommonsPool2TargetSource targetSource = new CommonsPool2TargetSource();
targetSource.setBlockWhenExhausted(true);
assertThat(targetSource.isBlockWhenExhausted()).isEqualTo(true);
assertThat(targetSource.isBlockWhenExhausted()).isTrue();
}
@Test
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -876,7 +876,7 @@ class XmlBeanFactoryTests {
// should have been autowired
assertThat(rod1.getSpouse1()).isEqualTo(kerry);
assertThat(rod1.getAge()).isEqualTo(0);
assertThat(rod1.getName()).isEqualTo(null);
assertThat(rod1.getName()).isNull();
ConstructorDependenciesBean rod2 = (ConstructorDependenciesBean) xbf.getBean("rod2");
TestBean kerry1 = (TestBean) xbf.getBean("kerry1");
@@ -885,7 +885,7 @@ class XmlBeanFactoryTests {
assertThat(rod2.getSpouse1()).isEqualTo(kerry2);
assertThat(rod2.getSpouse2()).isEqualTo(kerry1);
assertThat(rod2.getAge()).isEqualTo(0);
assertThat(rod2.getName()).isEqualTo(null);
assertThat(rod2.getName()).isNull();
ConstructorDependenciesBean rod = (ConstructorDependenciesBean) xbf.getBean("rod3");
IndexedTestBean other = (IndexedTestBean) xbf.getBean("other");
@@ -894,7 +894,7 @@ class XmlBeanFactoryTests {
assertThat(rod.getSpouse2()).isEqualTo(kerry);
assertThat(rod.getOther()).isEqualTo(other);
assertThat(rod.getAge()).isEqualTo(0);
assertThat(rod.getName()).isEqualTo(null);
assertThat(rod.getName()).isNull();
xbf.getBean("rod4", ConstructorDependenciesBean.class);
// should have been autowired
@@ -902,7 +902,7 @@ class XmlBeanFactoryTests {
assertThat(rod.getSpouse2()).isEqualTo(kerry);
assertThat(rod.getOther()).isEqualTo(other);
assertThat(rod.getAge()).isEqualTo(0);
assertThat(rod.getName()).isEqualTo(null);
assertThat(rod.getName()).isNull();
}
@Test
@@ -929,7 +929,7 @@ class XmlBeanFactoryTests {
assertThat(rod6.getSpouse2()).isEqualTo(kerry1);
assertThat(rod6.getOther()).isEqualTo(other);
assertThat(rod6.getAge()).isEqualTo(0);
assertThat(rod6.getName()).isEqualTo(null);
assertThat(rod6.getName()).isNull();
xbf.destroySingletons();
assertThat(rod6.destroyed).isTrue();
@@ -967,7 +967,7 @@ class XmlBeanFactoryTests {
assertThat(rod9c.getAge()).isEqualTo(97);
ConstructorDependenciesBean rod10 = (ConstructorDependenciesBean) xbf.getBean("rod10");
assertThat(rod10.getName()).isEqualTo(null);
assertThat(rod10.getName()).isNull();
ConstructorDependenciesBean rod11 = (ConstructorDependenciesBean) xbf.getBean("rod11");
assertThat(rod11.getSpouse1()).isEqualTo(kerry2);
@@ -1331,7 +1331,7 @@ class XmlBeanFactoryTests {
OverrideOneMethodSubclass ooms = (OverrideOneMethodSubclass) xbf.getBean("replaceVoidMethod");
DoSomethingReplacer dos = (DoSomethingReplacer) xbf.getBean("doSomethingReplacer");
assertThat(dos.lastArg).isEqualTo(null);
assertThat(dos.lastArg).isNull();
String s1 = "";
String s2 = "foo bar black sheep";
ooms.doSomething(s1);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCache;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
@@ -306,7 +306,7 @@ public class CacheReproTests {
@Configuration
@EnableCaching
public static class Spr13081Config extends CachingConfigurerSupport {
public static class Spr13081Config implements CachingConfigurer {
@Bean
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -83,6 +83,19 @@ public class EnableCachingIntegrationTests {
assertCacheHit(key, value, cache);
}
@Test
public void barServiceWithCacheableInterfaceCglib() {
this.context = new AnnotationConfigApplicationContext(BarConfigCglib.class);
BarService service = this.context.getBean(BarService.class);
Cache cache = getCache();
Object key = new Object();
assertCacheMiss(key, cache);
Object value = service.getSimple(key);
assertCacheHit(key, value, cache);
}
@Test
public void beanConditionOff() {
this.context = new AnnotationConfigApplicationContext(BeanConditionConfig.class);
@@ -124,7 +137,7 @@ public class EnableCachingIntegrationTests {
@Configuration
static class SharedConfig extends CachingConfigurerSupport {
static class SharedConfig implements CachingConfigurer {
@Override
@Bean
@@ -185,6 +198,36 @@ public class EnableCachingIntegrationTests {
}
@Configuration
@Import(SharedConfig.class)
@EnableCaching(proxyTargetClass = true)
static class BarConfigCglib {
@Bean
public BarService barService() {
return new BarServiceImpl();
}
}
interface BarService {
@Cacheable(cacheNames = "testCache")
Object getSimple(Object key);
}
static class BarServiceImpl implements BarService {
private final AtomicLong counter = new AtomicLong();
@Override
public Object getSimple(Object key) {
return this.counter.getAndIncrement();
}
}
@Configuration
@Import(FooConfig.class)
@EnableCaching
@@ -18,11 +18,10 @@ package org.springframework.cache.config;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.CacheInterceptor;
@@ -107,11 +106,8 @@ public class EnableCachingTests extends AbstractCacheAnnotationTests {
try {
ctx.refresh();
}
catch (BeanCreationException ex) {
Throwable root = ex.getRootCause();
boolean condition = root instanceof IllegalStateException;
assertThat(condition).isTrue();
assertThat(root.getMessage().contains("implementations of CachingConfigurer")).isTrue();
catch (IllegalStateException ex) {
assertThat(ex.getMessage().contains("implementations of CachingConfigurer")).isTrue();
}
}
@@ -150,7 +146,7 @@ public class EnableCachingTests extends AbstractCacheAnnotationTests {
@Configuration
@EnableCaching
static class EnableCachingConfig extends CachingConfigurerSupport {
static class EnableCachingConfig implements CachingConfigurer {
@Override
@Bean
@@ -227,7 +223,7 @@ public class EnableCachingTests extends AbstractCacheAnnotationTests {
@Configuration
@EnableCaching
static class MultiCacheManagerConfigurer extends CachingConfigurerSupport {
static class MultiCacheManagerConfigurer implements CachingConfigurer {
@Bean
public CacheManager cm1() {
@@ -253,7 +249,7 @@ public class EnableCachingTests extends AbstractCacheAnnotationTests {
@Configuration
@EnableCaching
static class EmptyConfigSupportConfig extends CachingConfigurerSupport {
static class EmptyConfigSupportConfig implements CachingConfigurer {
@Bean
public CacheManager cm() {
@@ -264,7 +260,7 @@ public class EnableCachingTests extends AbstractCacheAnnotationTests {
@Configuration
@EnableCaching
static class FullCachingConfig extends CachingConfigurerSupport {
static class FullCachingConfig implements CachingConfigurer {
@Override
@Bean
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.context.ConfigurableApplicationContext;
@@ -122,7 +122,7 @@ public class ExpressionCachingIntegrationTests {
@Configuration
@EnableCaching
static class SharedConfig extends CachingConfigurerSupport {
static class SharedConfig implements CachingConfigurer {
@Override
@Bean
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.cache.support.SimpleValueWrapper;
@@ -170,7 +170,7 @@ public class CacheErrorHandlerTests {
@Configuration
@EnableCaching
static class Config extends CachingConfigurerSupport {
static class Config implements CachingConfigurer {
@Bean
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.context.ConfigurableApplicationContext;
@@ -106,7 +106,7 @@ public class CachePutEvaluationTests {
@Configuration
@EnableCaching
static class Config extends CachingConfigurerSupport {
static class Config implements CachingConfigurer {
@Bean
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -149,7 +149,7 @@ public class CacheResolverCustomizationTests {
@Configuration
@EnableCaching
static class Config extends CachingConfigurerSupport {
static class Config implements CachingConfigurer {
@Override
@Bean
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -133,7 +133,7 @@ public class CacheSyncFailureTests {
@Configuration
@EnableCaching
static class Config extends CachingConfigurerSupport {
static class Config implements CachingConfigurer {
@Override
@Bean
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ public class PrimitiveBeanLookupAndAutowiringTests {
public void primitiveLookupByName() {
ApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class);
boolean b = ctx.getBean("b", boolean.class);
assertThat(b).isEqualTo(true);
assertThat(b).isTrue();
int i = ctx.getBean("i", int.class);
assertThat(i).isEqualTo(42);
}
@@ -56,7 +56,7 @@ public class PrimitiveBeanLookupAndAutowiringTests {
public void primitiveLookupByType() {
ApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class);
boolean b = ctx.getBean(boolean.class);
assertThat(b).isEqualTo(true);
assertThat(b).isTrue();
int i = ctx.getBean(int.class);
assertThat(i).isEqualTo(42);
}
@@ -65,7 +65,7 @@ public class PrimitiveBeanLookupAndAutowiringTests {
public void primitiveAutowiredInjection() {
ApplicationContext ctx =
new AnnotationConfigApplicationContext(Config.class, AutowiredComponent.class);
assertThat(ctx.getBean(AutowiredComponent.class).b).isEqualTo(true);
assertThat(ctx.getBean(AutowiredComponent.class).b).isTrue();
assertThat(ctx.getBean(AutowiredComponent.class).i).isEqualTo(42);
}
@@ -73,7 +73,7 @@ public class PrimitiveBeanLookupAndAutowiringTests {
public void primitiveResourceInjection() {
ApplicationContext ctx =
new AnnotationConfigApplicationContext(Config.class, ResourceComponent.class);
assertThat(ctx.getBean(ResourceComponent.class).b).isEqualTo(true);
assertThat(ctx.getBean(ResourceComponent.class).b).isTrue();
assertThat(ctx.getBean(ResourceComponent.class).i).isEqualTo(42);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.util.ReflectionUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -43,7 +44,7 @@ public class CachedExpressionEvaluatorTests {
Method method = ReflectionUtils.findMethod(getClass(), "toString");
Expression expression = expressionEvaluator.getTestExpression("true", method, getClass());
hasParsedExpression("true");
assertThat(expression.getValue()).isEqualTo(true);
assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue();
assertThat(expressionEvaluator.testCache.size()).as("Expression should be in cache").isEqualTo(1);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.util.ReflectionUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN;
/**
* Unit tests for {@link MethodBasedEvaluationContext}.
@@ -47,9 +48,9 @@ public class MethodBasedEvaluationContextTests {
assertThat(context.lookupVariable("p0")).isEqualTo("test");
assertThat(context.lookupVariable("foo")).isEqualTo("test");
assertThat(context.lookupVariable("a1")).isEqualTo(true);
assertThat(context.lookupVariable("p1")).isEqualTo(true);
assertThat(context.lookupVariable("flag")).isEqualTo(true);
assertThat(context.lookupVariable("a1")).asInstanceOf(BOOLEAN).isTrue();
assertThat(context.lookupVariable("p1")).asInstanceOf(BOOLEAN).isTrue();
assertThat(context.lookupVariable("flag")).asInstanceOf(BOOLEAN).isTrue();
assertThat(context.lookupVariable("a2")).isNull();
assertThat(context.lookupVariable("p2")).isNull();
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -345,7 +345,7 @@ public class PropertySourcesPlaceholderConfigurerTests {
.addPropertyValue("jedi", "${jedi:false}")
.getBeanDefinition());
ppc.postProcessBeanFactory(bf);
assertThat(bf.getBean(TestBean.class).isJedi()).isEqualTo(true);
assertThat(bf.getBean(TestBean.class).isJedi()).isTrue();
}
@Test
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -281,7 +281,7 @@ public class FormattingConversionServiceTests {
@Test
public void printNullDefault() {
assertThat(formattingService
.convert(null, TypeDescriptor.valueOf(Integer.class), TypeDescriptor.valueOf(String.class))).isEqualTo(null);
.convert(null, TypeDescriptor.valueOf(Integer.class), TypeDescriptor.valueOf(String.class))).isNull();
}
@Test
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ public class JndiLocatorDelegateTests {
builderField.set(null, null);
try {
assertThat(JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()).isEqualTo(false);
assertThat(JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()).isFalse();
}
finally {
builderField.set(null, oldBuilder);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -218,8 +218,8 @@ public class AsyncAnnotationBeanPostProcessorTests {
private void assertFutureWithException(Future<Object> result,
TestableAsyncUncaughtExceptionHandler exceptionHandler) {
assertThatExceptionOfType(ExecutionException.class).isThrownBy(
result::get)
.withCauseExactlyInstanceOf(UnsupportedOperationException.class);
result::get)
.withCauseExactlyInstanceOf(UnsupportedOperationException.class);
assertThat(exceptionHandler.isCalled()).as("handler should never be called with Future return type").isFalse();
}
@@ -343,7 +343,7 @@ public class AsyncAnnotationBeanPostProcessorTests {
@Configuration
@EnableAsync
static class ConfigWithExceptionHandler extends AsyncConfigurerSupport {
static class ConfigWithExceptionHandler implements AsyncConfigurer {
@Bean
public ITestBean target() {
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,12 @@
package org.springframework.scheduling.concurrent;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.FutureTask;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import org.junit.jupiter.api.Test;
@@ -25,10 +29,16 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.GenericApplicationContext;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link ThreadPoolExecutorFactoryBean}.
*
* @author Juergen Hoeller
*/
class ThreadPoolExecutorFactoryBeanTests {
@@ -44,6 +54,28 @@ class ThreadPoolExecutorFactoryBeanTests {
context.close();
}
@Test
void executorWithDefaultSettingsDoesNotPrestartAllCoreThreads() {
GenericApplicationContext context = new GenericApplicationContext();
context.registerBean("taskExecutor", ThreadPoolExecutorFactoryBean.class, TestThreadPoolExecutorFactoryBean::new);
context.refresh();
ThreadPoolExecutor threadPoolExecutor = context.getBean(ThreadPoolExecutor.class);
verify(threadPoolExecutor, never()).prestartAllCoreThreads();
}
@Test
void executorWithPrestartAllCoreThreads() {
GenericApplicationContext context = new GenericApplicationContext();
context.registerBean("taskExecutor", ThreadPoolExecutorFactoryBean.class, () -> {
TestThreadPoolExecutorFactoryBean factoryBean = new TestThreadPoolExecutorFactoryBean();
factoryBean.setPrestartAllCoreThreads(true);
return factoryBean;
});
context.refresh();
ThreadPoolExecutor threadPoolExecutor = context.getBean(ThreadPoolExecutor.class);
verify(threadPoolExecutor).prestartAllCoreThreads();
}
@Configuration
static class ExecutorConfig {
@@ -52,7 +84,19 @@ class ThreadPoolExecutorFactoryBeanTests {
ThreadPoolExecutorFactoryBean executor() {
return new ThreadPoolExecutorFactoryBean();
}
}
@SuppressWarnings("serial")
private static class TestThreadPoolExecutorFactoryBean extends ThreadPoolExecutorFactoryBean {
@Override
protected ThreadPoolExecutor createExecutor(
int corePoolSize, int maxPoolSize, int keepAliveSeconds, BlockingQueue<Runnable> queue,
ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
return mock(ThreadPoolExecutor.class);
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ public class ExecutorBeanDefinitionParserTests {
assertThat(getMaxPoolSize(executor)).isEqualTo(Integer.MAX_VALUE);
assertThat(getQueueCapacity(executor)).isEqualTo(Integer.MAX_VALUE);
assertThat(getKeepAliveSeconds(executor)).isEqualTo(60);
assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(false);
assertThat(getAllowCoreThreadTimeOut(executor)).isFalse();
FutureTask<String> task = new FutureTask<>(new Callable<String>() {
@Override
@@ -96,7 +96,7 @@ public class ExecutorBeanDefinitionParserTests {
assertThat(getCorePoolSize(executor)).isEqualTo(9);
assertThat(getMaxPoolSize(executor)).isEqualTo(9);
assertThat(getKeepAliveSeconds(executor)).isEqualTo(37);
assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(true);
assertThat(getAllowCoreThreadTimeOut(executor)).isTrue();
assertThat(getQueueCapacity(executor)).isEqualTo(Integer.MAX_VALUE);
}
@@ -106,7 +106,7 @@ public class ExecutorBeanDefinitionParserTests {
assertThat(getCorePoolSize(executor)).isEqualTo(123);
assertThat(getMaxPoolSize(executor)).isEqualTo(123);
assertThat(getKeepAliveSeconds(executor)).isEqualTo(60);
assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(false);
assertThat(getAllowCoreThreadTimeOut(executor)).isFalse();
assertThat(getQueueCapacity(executor)).isEqualTo(Integer.MAX_VALUE);
}
@@ -115,7 +115,7 @@ public class ExecutorBeanDefinitionParserTests {
Object executor = this.context.getBean("propertyPlaceholderWithRange");
assertThat(getCorePoolSize(executor)).isEqualTo(5);
assertThat(getMaxPoolSize(executor)).isEqualTo(25);
assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(false);
assertThat(getAllowCoreThreadTimeOut(executor)).isFalse();
assertThat(getQueueCapacity(executor)).isEqualTo(10);
}
@@ -124,7 +124,7 @@ public class ExecutorBeanDefinitionParserTests {
Object executor = this.context.getBean("propertyPlaceholderWithRangeAndCoreThreadTimeout");
assertThat(getCorePoolSize(executor)).isEqualTo(99);
assertThat(getMaxPoolSize(executor)).isEqualTo(99);
assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(true);
assertThat(getAllowCoreThreadTimeOut(executor)).isTrue();
}
@Test
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1242,7 +1242,7 @@ class DataBinderTests {
assertThat(errors.getFieldError("name").getCodes()[2]).isEqualTo("NOT_ROD.java.lang.String");
assertThat(errors.getFieldError("name").getCodes()[3]).isEqualTo("NOT_ROD");
assertThat((errors.getFieldErrors("name").get(0)).getField()).isEqualTo("name");
assertThat((errors.getFieldErrors("name").get(0)).getRejectedValue()).isEqualTo(null);
assertThat((errors.getFieldErrors("name").get(0)).getRejectedValue()).isNull();
assertThat(errors.hasFieldErrors("spouse.age")).isTrue();
assertThat(errors.getFieldErrorCount("spouse.age")).isEqualTo(1);
@@ -1314,7 +1314,7 @@ class DataBinderTests {
assertThat(errors.getFieldError("name").getCodes()[2]).isEqualTo("validation.NOT_ROD.java.lang.String");
assertThat(errors.getFieldError("name").getCodes()[3]).isEqualTo("validation.NOT_ROD");
assertThat((errors.getFieldErrors("name").get(0)).getField()).isEqualTo("name");
assertThat((errors.getFieldErrors("name").get(0)).getRejectedValue()).isEqualTo(null);
assertThat((errors.getFieldErrors("name").get(0)).getRejectedValue()).isNull();
assertThat(errors.hasFieldErrors("spouse.age")).isTrue();
assertThat(errors.getFieldErrorCount("spouse.age")).isEqualTo(1);
@@ -1339,7 +1339,7 @@ class DataBinderTests {
assertThat(errors.getFieldErrorCount("spouse")).isEqualTo(1);
assertThat(errors.getFieldError("spouse").getCode()).isEqualTo("SPOUSE_NOT_AVAILABLE");
assertThat((errors.getFieldErrors("spouse").get(0)).getObjectName()).isEqualTo("tb");
assertThat((errors.getFieldErrors("spouse").get(0)).getRejectedValue()).isEqualTo(null);
assertThat((errors.getFieldErrors("spouse").get(0)).getRejectedValue()).isNull();
}
@Test
@@ -194,7 +194,7 @@ public class ClassReader {
this.b = classFileBuffer;
// Check the class' major_version. This field is after the magic and minor_version fields, which
// use 4 and 2 bytes respectively.
if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V18) {
if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V19) {
throw new IllegalArgumentException(
"Unsupported class file major version " + readShort(classFileOffset + 6));
}
@@ -283,6 +283,7 @@ public interface Opcodes {
int V16 = 0 << 16 | 60;
int V17 = 0 << 16 | 61;
int V18 = 0 << 16 | 62;
int V19 = 0 << 16 | 63;
/**
* Version flag indicating that the class is using 'preview' features.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -101,6 +101,8 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
}
return NO_DEBUG_INFO_MAP;
}
// We cannot use try-with-resources here for the InputStream, since we have
// custom handling of the close() method in a finally-block.
try {
ClassReader classReader = new ClassReader(is);
Map<Executable, String[]> map = new ConcurrentHashMap<>(32);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,11 +48,11 @@ import org.springframework.util.StringUtils;
* {@link #getGeneric(int...) generic parameters} along with the ability to ultimately
* {@link #resolve() resolve} to a {@link java.lang.Class}.
*
* <p>{@code ResolvableTypes} may be obtained from {@link #forField(Field) fields},
* {@link #forMethodParameter(Method, int) method parameters},
* {@link #forMethodReturnType(Method) method returns} or
* {@link #forClass(Class) classes}. Most methods on this class will themselves return
* {@link ResolvableType ResolvableTypes}, allowing easy navigation. For example:
* <p>A {@code ResolvableType} may be obtained from a {@linkplain #forField(Field) field},
* a {@linkplain #forMethodParameter(Method, int) method parameter},
* a {@linkplain #forMethodReturnType(Method) method return type}, or a
* {@linkplain #forClass(Class) class}. Most methods on this class will themselves return
* a {@code ResolvableType}, allowing for easy navigation. For example:
* <pre class="code">
* private HashMap&lt;Integer, List&lt;String&gt;&gt; myMap;
*
@@ -182,7 +182,7 @@ public class ResolvableType implements Serializable {
/**
* Private constructor used to create a new {@link ResolvableType} on a {@link Class} basis.
* Avoids all {@code instanceof} checks in order to create a straight {@link Class} wrapper.
* <p>Avoids all {@code instanceof} checks in order to create a straight {@link Class} wrapper.
* @since 4.2
*/
private ResolvableType(@Nullable Class<?> clazz) {
@@ -406,7 +406,7 @@ public class ResolvableType implements Serializable {
/**
* Convenience method to return this type as a resolvable {@link Collection} type.
* Returns {@link #NONE} if this type does not implement or extend
* <p>Returns {@link #NONE} if this type does not implement or extend
* {@link Collection}.
* @see #as(Class)
* @see #asMap()
@@ -417,7 +417,7 @@ public class ResolvableType implements Serializable {
/**
* Convenience method to return this type as a resolvable {@link Map} type.
* Returns {@link #NONE} if this type does not implement or extend
* <p>Returns {@link #NONE} if this type does not implement or extend
* {@link Map}.
* @see #as(Class)
* @see #asCollection()
@@ -458,7 +458,7 @@ public class ResolvableType implements Serializable {
/**
* Return a {@link ResolvableType} representing the direct supertype of this type.
* If no supertype is available this method returns {@link #NONE}.
* <p>If no supertype is available this method returns {@link #NONE}.
* <p>Note: The resulting {@link ResolvableType} instance may not be {@link Serializable}.
* @see #getInterfaces()
*/
@@ -608,7 +608,7 @@ public class ResolvableType implements Serializable {
/**
* Return a {@link ResolvableType} for the specified nesting level.
* See {@link #getNested(int, Map)} for details.
* <p>See {@link #getNested(int, Map)} for details.
* @param nestingLevel the nesting level
* @return the {@link ResolvableType} type, or {@code #NONE}
*/
@@ -999,7 +999,7 @@ public class ResolvableType implements Serializable {
/**
* Return a {@link ResolvableType} for the specified {@link Class},
* using the full generic type information for assignability checks.
* For example: {@code ResolvableType.forClass(MyArrayList.class)}.
* <p>For example: {@code ResolvableType.forClass(MyArrayList.class)}.
* @param clazz the class to introspect ({@code null} is semantically
* equivalent to {@code Object.class} for typical use cases here)
* @return a {@link ResolvableType} for the specified class
@@ -1014,7 +1014,7 @@ public class ResolvableType implements Serializable {
* Return a {@link ResolvableType} for the specified {@link Class},
* doing assignability checks against the raw class only (analogous to
* {@link Class#isAssignableFrom}, which this serves as a wrapper for.
* For example: {@code ResolvableType.forRawClass(List.class)}.
* <p>For example: {@code ResolvableType.forRawClass(List.class)}.
* @param clazz the class to introspect ({@code null} is semantically
* equivalent to {@code Object.class} for typical use cases here)
* @return a {@link ResolvableType} for the specified class
@@ -1043,7 +1043,7 @@ public class ResolvableType implements Serializable {
/**
* Return a {@link ResolvableType} for the specified base type
* (interface or base class) with a given implementation class.
* For example: {@code ResolvableType.forClass(List.class, MyArrayList.class)}.
* <p>For example: {@code ResolvableType.forClass(List.class, MyArrayList.class)}.
* @param baseType the base type (must not be {@code null})
* @param implementationClass the implementation class
* @return a {@link ResolvableType} for the specified base type backed by the
@@ -1085,7 +1085,7 @@ public class ResolvableType implements Serializable {
Assert.notNull(clazz, "Class must not be null");
Assert.notNull(generics, "Generics array must not be null");
TypeVariable<?>[] variables = clazz.getTypeParameters();
Assert.isTrue(variables.length == generics.length, "Mismatched number of generics specified");
Assert.isTrue(variables.length == generics.length, () -> "Mismatched number of generics specified for " + clazz.toGenericString());
Type[] arguments = new Type[generics.length];
for (int i = 0; i < generics.length; i++) {
@@ -1238,7 +1238,7 @@ public class ResolvableType implements Serializable {
/**
* Return a {@link ResolvableType} for the specified {@link Method} return type.
* Use this variant when the class that declares the method includes generic
* <p>Use this variant when the class that declares the method includes generic
* parameter variables that are satisfied by the implementation class.
* @param method the source for the method return type
* @param implementationClass the implementation class
@@ -17,10 +17,12 @@
package org.springframework.core.log;
import java.util.function.Function;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
* Utility methods for formatting and logging messages.
@@ -35,10 +37,15 @@ import org.springframework.lang.Nullable;
*/
public abstract class LogFormatUtils {
private static final Pattern NEWLINE_PATTERN = Pattern.compile("[\n\r]");
private static final Pattern CONTROL_CHARACTER_PATTERN = Pattern.compile("\\p{Cc}");
/**
* Convenience variant of {@link #formatValue(Object, int, boolean)} that
* limits the length of a log message to 100 characters and also replaces
* newline characters if {@code limitLength} is set to "true".
* newline and control characters if {@code limitLength} is set to "true".
* @param value the value to format
* @param limitLength whether to truncate the value at a length of 100
* @return the formatted value
@@ -53,25 +60,29 @@ public abstract class LogFormatUtils {
* compacting it into a single line when {@code replaceNewLines} is set.
* @param value the value to be formatted
* @param maxLength the max length, after which to truncate, or -1 for unlimited
* @param replaceNewlines whether to replace newline characters with placeholders
* @param replaceNewlinesAndControlCharacters whether to replace newline and
* control characters with placeholders
* @return the formatted value
*/
public static String formatValue(@Nullable Object value, int maxLength, boolean replaceNewlines) {
public static String formatValue(
@Nullable Object value, int maxLength, boolean replaceNewlinesAndControlCharacters) {
if (value == null) {
return "";
}
String result;
try {
result = value.toString();
result = ObjectUtils.nullSafeToString(value);
}
catch (Throwable ex) {
result = ex.toString();
result = ObjectUtils.nullSafeToString(ex);
}
if (maxLength != -1) {
result = (result.length() > maxLength ? result.substring(0, maxLength) + " (truncated)..." : result);
}
if (replaceNewlines) {
result = result.replace("\n", "<LF>").replace("\r", "<CR>");
if (replaceNewlinesAndControlCharacters) {
result = NEWLINE_PATTERN.matcher(result).replaceAll("<EOL>");
result = CONTROL_CHARACTER_PATTERN.matcher(result).replaceAll("?");
}
if (value instanceof CharSequence) {
result = "\"" + result + "\"";
@@ -162,7 +162,7 @@ public class StandardAnnotationMetadata extends StandardClassMetadata implements
throw new IllegalStateException("Failed to introspect annotated methods on " + getIntrospectedClass(), ex);
}
}
return annotatedMethods != null ? annotatedMethods : Collections.emptySet();
return (annotatedMethods != null ? annotatedMethods : Collections.emptySet());
}
@@ -127,6 +127,11 @@ final class SimpleAnnotationMetadata implements AnnotationMetadata {
return this.memberClassNames.clone();
}
@Override
public MergedAnnotations getAnnotations() {
return this.annotations;
}
@Override
public Set<String> getAnnotationTypes() {
Set<String> annotationTypes = this.annotationTypes;
@@ -149,13 +154,9 @@ final class SimpleAnnotationMetadata implements AnnotationMetadata {
annotatedMethods.add(annotatedMethod);
}
}
return annotatedMethods != null ? annotatedMethods : Collections.emptySet();
return (annotatedMethods != null ? annotatedMethods : Collections.emptySet());
}
@Override
public MergedAnnotations getAnnotations() {
return this.annotations;
}
@Override
public boolean equals(@Nullable Object obj) {
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -99,8 +99,7 @@ final class SimpleAnnotationMetadataReadingVisitor extends ClassVisitor {
}
@Override
public void visitInnerClass(String name, @Nullable String outerName, String innerName,
int access) {
public void visitInnerClass(String name, @Nullable String outerName, String innerName, int access) {
if (outerName != null) {
String className = toClassName(name);
String outerClassName = toClassName(outerName);
@@ -733,6 +733,10 @@ public class AntPathMatcher implements PathMatcher {
}
for (int i = 1; i <= matcher.groupCount(); i++) {
String name = this.variableNames.get(i - 1);
if (name.startsWith("*")) {
throw new IllegalArgumentException("Capturing patterns (" + name + ") are not " +
"supported by the AntPathMatcher. Use the PathPatternParser instead.");
}
String value = matcher.group(i);
uriTemplateVariables.put(name, value);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,8 +71,8 @@ class GenericTypeResolverTests {
void methodReturnTypes() {
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "integer"), MyInterfaceType.class)).isEqualTo(Integer.class);
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "string"), MyInterfaceType.class)).isEqualTo(String.class);
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "raw"), MyInterfaceType.class)).isEqualTo(null);
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "object"), MyInterfaceType.class)).isEqualTo(null);
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "raw"), MyInterfaceType.class)).isNull();
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "object"), MyInterfaceType.class)).isNull();
}
@Test
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -370,9 +370,9 @@ class ReactiveAdapterRegistryTests {
@Test
void deferred() {
assertThat(getAdapter(CompletableFuture.class).getDescriptor().isDeferred()).isEqualTo(false);
assertThat(getAdapter(Deferred.class).getDescriptor().isDeferred()).isEqualTo(true);
assertThat(getAdapter(kotlinx.coroutines.flow.Flow.class).getDescriptor().isDeferred()).isEqualTo(true);
assertThat(getAdapter(CompletableFuture.class).getDescriptor().isDeferred()).isFalse();
assertThat(getAdapter(Deferred.class).getDescriptor().isDeferred()).isTrue();
assertThat(getAdapter(kotlinx.coroutines.flow.Flow.class).getDescriptor().isDeferred()).isTrue();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -83,19 +83,19 @@ class ResolvableTypeTests {
assertThat(none.asMap()).isEqualTo(ResolvableType.NONE);
assertThat(none.getComponentType()).isEqualTo(ResolvableType.NONE);
assertThat(none.getGeneric(0)).isEqualTo(ResolvableType.NONE);
assertThat(none.getGenerics().length).isEqualTo(0);
assertThat(none.getInterfaces().length).isEqualTo(0);
assertThat(none.getGenerics()).isEmpty();
assertThat(none.getInterfaces()).isEmpty();
assertThat(none.getSuperType()).isEqualTo(ResolvableType.NONE);
assertThat(none.getType()).isEqualTo(ResolvableType.EmptyType.INSTANCE);
assertThat(none.hasGenerics()).isEqualTo(false);
assertThat(none.isArray()).isEqualTo(false);
assertThat(none.hasGenerics()).isFalse();
assertThat(none.isArray()).isFalse();
assertThat(none.resolve()).isNull();
assertThat(none.resolve(String.class)).isEqualTo(String.class);
assertThat(none.resolveGeneric(0)).isNull();
assertThat(none.resolveGenerics().length).isEqualTo(0);
assertThat(none.resolveGenerics()).isEmpty();
assertThat(none.toString()).isEqualTo("?");
assertThat(none.hasUnresolvableGenerics()).isEqualTo(false);
assertThat(none.isAssignableFrom(ResolvableType.forClass(Object.class))).isEqualTo(false);
assertThat(none.hasUnresolvableGenerics()).isFalse();
assertThat(none.isAssignableFrom(ResolvableType.forClass(Object.class))).isFalse();
}
@Test
@@ -148,9 +148,9 @@ class ResolvableTypeTests {
@Test
void forInstanceMustNotBeNull() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
ResolvableType.forInstance(null))
.withMessageContaining("Instance must not be null");
assertThatIllegalArgumentException()
.isThrownBy(() -> ResolvableType.forInstance(null))
.withMessage("Instance must not be null");
}
@Test
@@ -201,9 +201,9 @@ class ResolvableTypeTests {
@Test
void forFieldMustNotBeNull() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
ResolvableType.forField(null))
.withMessageContaining("Field must not be null");
assertThatIllegalArgumentException()
.isThrownBy(() -> ResolvableType.forField(null))
.withMessage("Field must not be null");
}
@Test
@@ -215,9 +215,9 @@ class ResolvableTypeTests {
@Test
void forConstructorParameterMustNotBeNull() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
ResolvableType.forConstructorParameter(null, 0))
.withMessageContaining("Constructor must not be null");
assertThatIllegalArgumentException()
.isThrownBy(() -> ResolvableType.forConstructorParameter(null, 0))
.withMessage("Constructor must not be null");
}
@Test
@@ -229,9 +229,9 @@ class ResolvableTypeTests {
@Test
void forMethodParameterByIndexMustNotBeNull() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
ResolvableType.forMethodParameter(null, 0))
.withMessageContaining("Method must not be null");
assertThatIllegalArgumentException()
.isThrownBy(() -> ResolvableType.forMethodParameter(null, 0))
.withMessage("Method must not be null");
}
@Test
@@ -269,9 +269,9 @@ class ResolvableTypeTests {
@Test
void forMethodParameterMustNotBeNull() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
ResolvableType.forMethodParameter(null))
.withMessageContaining("MethodParameter must not be null");
assertThatIllegalArgumentException()
.isThrownBy(() -> ResolvableType.forMethodParameter(null))
.withMessage("MethodParameter must not be null");
}
@Test // SPR-16210
@@ -296,9 +296,9 @@ class ResolvableTypeTests {
@Test
void forMethodReturnMustNotBeNull() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
ResolvableType.forMethodReturnType(null))
.withMessageContaining("Method must not be null");
assertThatIllegalArgumentException()
.isThrownBy(() -> ResolvableType.forMethodReturnType(null))
.withMessage("Method must not be null");
}
@Test
@@ -317,7 +317,7 @@ class ResolvableTypeTests {
void arrayClassType() throws Exception {
ResolvableType type = ResolvableType.forField(Fields.class.getField("arrayClassType"));
assertThat(type.getType()).isInstanceOf(Class.class);
assertThat(((Class) type.getType()).isArray()).isEqualTo(true);
assertThat(((Class) type.getType()).isArray()).isTrue();
}
@Test
@@ -343,7 +343,7 @@ class ResolvableTypeTests {
void getComponentTypeForClassArray() throws Exception {
Field field = Fields.class.getField("arrayClassType");
ResolvableType type = ResolvableType.forField(field);
assertThat(type.isArray()).isEqualTo(true);
assertThat(type.isArray()).isTrue();
assertThat(type.getComponentType().getType())
.isEqualTo(((Class) field.getGenericType()).getComponentType());
}
@@ -351,7 +351,7 @@ class ResolvableTypeTests {
@Test
void getComponentTypeForGenericArrayType() throws Exception {
ResolvableType type = ResolvableType.forField(Fields.class.getField("genericArrayType"));
assertThat(type.isArray()).isEqualTo(true);
assertThat(type.isArray()).isTrue();
assertThat(type.getComponentType().getType()).isEqualTo(
((GenericArrayType) type.getType()).getGenericComponentType());
}
@@ -359,7 +359,7 @@ class ResolvableTypeTests {
@Test
void getComponentTypeForVariableThatResolvesToGenericArray() throws Exception {
ResolvableType type = ResolvableType.forClass(ListOfGenericArray.class).asCollection().getGeneric();
assertThat(type.isArray()).isEqualTo(true);
assertThat(type.isArray()).isTrue();
assertThat(type.getType()).isInstanceOf(TypeVariable.class);
assertThat(type.getComponentType().getType().toString()).isEqualTo(
"java.util.List<java.lang.String>");
@@ -368,7 +368,7 @@ class ResolvableTypeTests {
@Test
void getComponentTypeForNonArray() throws Exception {
ResolvableType type = ResolvableType.forClass(String.class);
assertThat(type.isArray()).isEqualTo(false);
assertThat(type.isArray()).isFalse();
assertThat(type.getComponentType()).isEqualTo(ResolvableType.NONE);
}
@@ -438,7 +438,7 @@ class ResolvableTypeTests {
@Test
void getInterfaces() throws Exception {
ResolvableType type = ResolvableType.forClass(ExtendsList.class);
assertThat(type.getInterfaces().length).isEqualTo(0);
assertThat(type.getInterfaces()).isEmpty();
SortedSet<String> interfaces = new TreeSet<>();
for (ResolvableType interfaceType : type.getSuperType().getInterfaces()) {
interfaces.add(interfaceType.toString());
@@ -529,8 +529,8 @@ class ResolvableTypeTests {
@Test
void hasGenerics() throws Exception {
ResolvableType type = ResolvableType.forClass(ExtendsList.class);
assertThat(type.hasGenerics()).isEqualTo(false);
assertThat(type.asCollection().hasGenerics()).isEqualTo(true);
assertThat(type.hasGenerics()).isFalse();
assertThat(type.asCollection().hasGenerics()).isTrue();
}
@Test
@@ -553,7 +553,7 @@ class ResolvableTypeTests {
void noGetGenerics() throws Exception {
ResolvableType type = ResolvableType.forClass(ExtendsList.class);
ResolvableType[] generics = type.getGenerics();
assertThat(generics.length).isEqualTo(0);
assertThat(generics).isEmpty();
}
@Test
@@ -602,7 +602,7 @@ class ResolvableTypeTests {
ResolvableType type = ResolvableType.forField(Fields.class.getField("stringArrayList"));
ResolvableType generic = type.asCollection().getGeneric();
assertThat(generic.getType().toString()).isEqualTo("E");
assertThat(generic.isArray()).isEqualTo(true);
assertThat(generic.isArray()).isTrue();
assertThat(generic.resolve()).isEqualTo(String[].class);
}
@@ -610,7 +610,7 @@ class ResolvableTypeTests {
void resolveVariableGenericArray() throws Exception {
ResolvableType type = ResolvableType.forField(Fields.class.getField("variableTypeGenericArray"), TypedFields.class);
assertThat(type.getType().toString()).isEqualTo("T[]");
assertThat(type.isArray()).isEqualTo(true);
assertThat(type.isArray()).isTrue();
assertThat(type.resolve()).isEqualTo(String[].class);
}
@@ -618,7 +618,7 @@ class ResolvableTypeTests {
void resolveVariableGenericArrayUnknown() throws Exception {
ResolvableType type = ResolvableType.forField(Fields.class.getField("variableTypeGenericArray"));
assertThat(type.getType().toString()).isEqualTo("T[]");
assertThat(type.isArray()).isEqualTo(true);
assertThat(type.isArray()).isTrue();
assertThat(type.resolve()).isNull();
}
@@ -626,7 +626,7 @@ class ResolvableTypeTests {
void resolveVariableGenericArrayUnknownWithFallback() throws Exception {
ResolvableType type = ResolvableType.forField(Fields.class.getField("variableTypeGenericArray"));
assertThat(type.getType().toString()).isEqualTo("T[]");
assertThat(type.isArray()).isEqualTo(true);
assertThat(type.isArray()).isTrue();
assertThat(type.toClass()).isEqualTo(Object.class);
}
@@ -965,16 +965,16 @@ class ResolvableTypeTests {
@Test
void isAssignableFromMustNotBeNull() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
ResolvableType.forClass(Object.class).isAssignableFrom((ResolvableType) null))
.withMessageContaining("Type must not be null");
assertThatIllegalArgumentException()
.isThrownBy(() -> ResolvableType.forClass(Object.class).isAssignableFrom((ResolvableType) null))
.withMessage("ResolvableType must not be null");
}
@Test
void isAssignableFromForNone() throws Exception {
ResolvableType objectType = ResolvableType.forClass(Object.class);
assertThat(objectType.isAssignableFrom(ResolvableType.NONE)).isEqualTo(false);
assertThat(ResolvableType.NONE.isAssignableFrom(objectType)).isEqualTo(false);
assertThat(objectType.isAssignableFrom(ResolvableType.NONE)).isFalse();
assertThat(ResolvableType.NONE.isAssignableFrom(objectType)).isFalse();
}
@Test
@@ -1159,6 +1159,20 @@ class ResolvableTypeTests {
assertThatResolvableType(complex4).isNotAssignableFrom(complex3);
}
@Test
void identifyTypeVariable() throws Exception {
Method method = ClassArguments.class.getMethod("typedArgumentFirst", Class.class, Class.class, Class.class);
ResolvableType returnType = ResolvableType.forMethodReturnType(method, ClassArguments.class);
ResolvableType arg0 = ResolvableType.forMethodParameter(method, 0, ClassArguments.class);
ResolvableType arg1 = ResolvableType.forMethodParameter(method, 1, ClassArguments.class);
ResolvableType arg2 = ResolvableType.forMethodParameter(method, 2, ClassArguments.class);
assertThat(returnType.getType().equals(arg0.as(Class.class).getGeneric(0).getType())).isTrue();
assertThat(returnType.getType().equals(arg1.as(Class.class).getGeneric(0).getType())).isFalse();
assertThat(returnType.getType().equals(arg2.as(Class.class).getGeneric(0).getType())).isFalse();
}
@Test
void hashCodeAndEquals() throws Exception {
ResolvableType forClass = ResolvableType.forClass(List.class);
@@ -1207,9 +1221,10 @@ class ResolvableTypeTests {
@Test
void forClassWithMismatchedGenerics() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
ResolvableType.forClassWithGenerics(Map.class, Integer.class))
.withMessageContaining("Mismatched number of generics specified");
assertThatIllegalArgumentException()
.isThrownBy(() -> ResolvableType.forClassWithGenerics(Map.class, Integer.class))
.withMessageContaining("Mismatched number of generics specified for")
.withMessageContaining("java.util.Map<K,V>");
}
@Test
@@ -1248,19 +1263,19 @@ class ResolvableTypeTests {
@Test
void hasUnresolvableGenerics() throws Exception {
ResolvableType type = ResolvableType.forField(Fields.class.getField("stringList"));
assertThat(type.hasUnresolvableGenerics()).isEqualTo(false);
assertThat(type.hasUnresolvableGenerics()).isFalse();
}
@Test
void hasUnresolvableGenericsBasedOnOwnGenerics() throws Exception {
ResolvableType type = ResolvableType.forClass(List.class);
assertThat(type.hasUnresolvableGenerics()).isEqualTo(true);
assertThat(type.hasUnresolvableGenerics()).isTrue();
}
@Test
void hasUnresolvableGenericsWhenSelfNotResolvable() throws Exception {
ResolvableType type = ResolvableType.forClass(List.class).getGeneric();
assertThat(type.hasUnresolvableGenerics()).isEqualTo(false);
assertThat(type.hasUnresolvableGenerics()).isFalse();
}
@Test
@@ -1269,7 +1284,7 @@ class ResolvableTypeTests {
for (ResolvableType generic : type.getGenerics()) {
assertThat(generic.resolve()).isNotNull();
}
assertThat(type.hasUnresolvableGenerics()).isEqualTo(true);
assertThat(type.hasUnresolvableGenerics()).isTrue();
}
@Test
@@ -1278,7 +1293,7 @@ class ResolvableTypeTests {
for (ResolvableType generic : type.getGenerics()) {
assertThat(generic.resolve()).isNotNull();
}
assertThat(type.hasUnresolvableGenerics()).isEqualTo(true);
assertThat(type.hasUnresolvableGenerics()).isTrue();
}
@Test
@@ -1427,6 +1442,10 @@ class ResolvableTypeTests {
}
interface TypedMethods extends Methods<String> {
}
static class AssignmentBase<O, C, S> {
public O o;
@@ -1479,7 +1498,9 @@ class ResolvableTypeTests {
}
interface TypedMethods extends Methods<String> {
interface ClassArguments {
<T> T typedArgumentFirst(Class<T> arg0, Class<?> arg1, Class<Object> arg2);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,8 +60,8 @@ class AnnotationAttributesTests {
assertThat(attributes.getString("name")).isEqualTo("dave");
assertThat(attributes.getStringArray("names")).isEqualTo(new String[] {"dave", "frank", "hal"});
assertThat(attributes.getBoolean("bool1")).isEqualTo(true);
assertThat(attributes.getBoolean("bool2")).isEqualTo(false);
assertThat(attributes.getBoolean("bool1")).isTrue();
assertThat(attributes.getBoolean("bool2")).isFalse();
assertThat(attributes.<Color>getEnum("color")).isEqualTo(Color.RED);
assertThat(attributes.getClass("class").equals(Integer.class)).isTrue();
assertThat(attributes.getClassArray("classes")).isEqualTo(new Class<?>[] {Number.class, Short.class, Integer.class});
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -257,7 +257,7 @@ class MissingMergedAnnotationTests {
@Test
void synthesizeThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(() -> this.missing.synthesize());
assertThatNoSuchElementException().isThrownBy(this.missing::synthesize);
}
@Test
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -79,7 +79,7 @@ class DefaultConversionServiceTests {
@Test
void stringToCharacterEmptyString() {
assertThat(conversionService.convert("", Character.class)).isEqualTo(null);
assertThat(conversionService.convert("", Character.class)).isNull();
}
@Test
@@ -95,29 +95,29 @@ class DefaultConversionServiceTests {
@Test
void stringToBooleanTrue() {
assertThat(conversionService.convert("true", Boolean.class)).isEqualTo(true);
assertThat(conversionService.convert("on", Boolean.class)).isEqualTo(true);
assertThat(conversionService.convert("yes", Boolean.class)).isEqualTo(true);
assertThat(conversionService.convert("1", Boolean.class)).isEqualTo(true);
assertThat(conversionService.convert("TRUE", Boolean.class)).isEqualTo(true);
assertThat(conversionService.convert("ON", Boolean.class)).isEqualTo(true);
assertThat(conversionService.convert("YES", Boolean.class)).isEqualTo(true);
assertThat(conversionService.convert("true", Boolean.class)).isTrue();
assertThat(conversionService.convert("on", Boolean.class)).isTrue();
assertThat(conversionService.convert("yes", Boolean.class)).isTrue();
assertThat(conversionService.convert("1", Boolean.class)).isTrue();
assertThat(conversionService.convert("TRUE", Boolean.class)).isTrue();
assertThat(conversionService.convert("ON", Boolean.class)).isTrue();
assertThat(conversionService.convert("YES", Boolean.class)).isTrue();
}
@Test
void stringToBooleanFalse() {
assertThat(conversionService.convert("false", Boolean.class)).isEqualTo(false);
assertThat(conversionService.convert("off", Boolean.class)).isEqualTo(false);
assertThat(conversionService.convert("no", Boolean.class)).isEqualTo(false);
assertThat(conversionService.convert("0", Boolean.class)).isEqualTo(false);
assertThat(conversionService.convert("FALSE", Boolean.class)).isEqualTo(false);
assertThat(conversionService.convert("OFF", Boolean.class)).isEqualTo(false);
assertThat(conversionService.convert("NO", Boolean.class)).isEqualTo(false);
assertThat(conversionService.convert("false", Boolean.class)).isFalse();
assertThat(conversionService.convert("off", Boolean.class)).isFalse();
assertThat(conversionService.convert("no", Boolean.class)).isFalse();
assertThat(conversionService.convert("0", Boolean.class)).isFalse();
assertThat(conversionService.convert("FALSE", Boolean.class)).isFalse();
assertThat(conversionService.convert("OFF", Boolean.class)).isFalse();
assertThat(conversionService.convert("NO", Boolean.class)).isFalse();
}
@Test
void stringToBooleanEmptyString() {
assertThat(conversionService.convert("", Boolean.class)).isEqualTo(null);
assertThat(conversionService.convert("", Boolean.class)).isNull();
}
@Test
@@ -219,7 +219,7 @@ class DefaultConversionServiceTests {
@Test
void stringToNumberEmptyString() {
assertThat(conversionService.convert("", Number.class)).isEqualTo(null);
assertThat(conversionService.convert("", Number.class)).isNull();
}
@Test
@@ -234,7 +234,7 @@ class DefaultConversionServiceTests {
@Test
void stringToEnumEmptyString() {
assertThat(conversionService.convert("", Foo.class)).isEqualTo(null);
assertThat(conversionService.convert("", Foo.class)).isNull();
}
@Test
@@ -254,7 +254,7 @@ class DefaultConversionServiceTests {
@Test
void integerToEnumNull() {
assertThat(conversionService.convert(null, Foo.class)).isEqualTo(null);
assertThat(conversionService.convert(null, Foo.class)).isNull();
}
@Test
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -109,7 +109,7 @@ class GenericConversionServiceTests {
@Test
void convertNullSource() {
assertThat(conversionService.convert(null, Integer.class)).isEqualTo(null);
assertThat(conversionService.convert(null, Integer.class)).isNull();
}
@Test
@@ -190,12 +190,7 @@ class GenericConversionServiceTests {
@Test
void convertSuperSourceType() {
conversionService.addConverter(new Converter<CharSequence, Integer>() {
@Override
public Integer convert(CharSequence source) {
return Integer.valueOf(source.toString());
}
});
conversionService.addConverter(CharSequence.class, Integer.class, source -> Integer.valueOf(source.toString()));
Integer result = conversionService.convert("3", Integer.class);
assertThat((int) result).isEqualTo((int) Integer.valueOf(3));
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,16 +26,18 @@ import org.junit.jupiter.api.Test;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.convert.ConverterNotFoundException;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.converter.Converter;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.InstanceOfAssertFactories.list;
import static org.assertj.core.api.InstanceOfAssertFactories.stream;
/**
* Tests for {@link StreamConverter}.
*
* @author Stephane Nicoll
* @author Sam Brannen
* @since 4.2
*/
class StreamConverterTests {
@@ -57,60 +59,41 @@ class StreamConverterTests {
@Test
void convertFromStreamToList() throws NoSuchFieldException {
this.conversionService.addConverter(Number.class, String.class, new ObjectToStringConverter());
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
Stream<Integer> stream = Stream.of(1, 2, 3);
TypeDescriptor listOfStrings = new TypeDescriptor(Types.class.getField("listOfStrings"));
Object result = this.conversionService.convert(stream, listOfStrings);
assertThat(result).as("Converted object must not be null").isNotNull();
boolean condition = result instanceof List;
assertThat(condition).as("Converted object must be a list").isTrue();
@SuppressWarnings("unchecked")
List<String> content = (List<String>) result;
assertThat(content.get(0)).isEqualTo("1");
assertThat(content.get(1)).isEqualTo("2");
assertThat(content.get(2)).isEqualTo("3");
assertThat(content.size()).as("Wrong number of elements").isEqualTo(3);
assertThat(result).asInstanceOf(list(String.class)).containsExactly("1", "2", "3");
}
@Test
void convertFromStreamToArray() throws NoSuchFieldException {
this.conversionService.addConverterFactory(new NumberToNumberConverterFactory());
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
Stream<Integer> stream = Stream.of(1, 2, 3);
TypeDescriptor arrayOfLongs = new TypeDescriptor(Types.class.getField("arrayOfLongs"));
Object result = this.conversionService.convert(stream, arrayOfLongs);
assertThat(result).as("Converted object must not be null").isNotNull();
assertThat(result.getClass().isArray()).as("Converted object must be an array").isTrue();
Long[] content = (Long[]) result;
assertThat(content[0]).isEqualTo(Long.valueOf(1L));
assertThat(content[1]).isEqualTo(Long.valueOf(2L));
assertThat(content[2]).isEqualTo(Long.valueOf(3L));
assertThat(content.length).as("Wrong number of elements").isEqualTo(3);
assertThat(content).containsExactly(1L, 2L, 3L);
}
@Test
void convertFromStreamToRawList() throws NoSuchFieldException {
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
Stream<Integer> stream = Stream.of(1, 2, 3);
TypeDescriptor listOfStrings = new TypeDescriptor(Types.class.getField("rawList"));
Object result = this.conversionService.convert(stream, listOfStrings);
assertThat(result).as("Converted object must not be null").isNotNull();
boolean condition = result instanceof List;
assertThat(condition).as("Converted object must be a list").isTrue();
@SuppressWarnings("unchecked")
List<Object> content = (List<Object>) result;
assertThat(content.get(0)).isEqualTo(1);
assertThat(content.get(1)).isEqualTo(2);
assertThat(content.get(2)).isEqualTo(3);
assertThat(content.size()).as("Wrong number of elements").isEqualTo(3);
assertThat(result).asInstanceOf(list(Object.class)).containsExactly(1, 2, 3);
}
@Test
void convertFromStreamToArrayNoConverter() throws NoSuchFieldException {
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
Stream<Integer> stream = Stream.of(1, 2, 3);
TypeDescriptor arrayOfLongs = new TypeDescriptor(Types.class.getField("arrayOfLongs"));
assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() ->
this.conversionService.convert(stream, arrayOfLongs))
assertThatExceptionOfType(ConversionFailedException.class)
.isThrownBy(() -> this.conversionService.convert(stream, arrayOfLongs))
.withCauseInstanceOf(ConverterNotFoundException.class);
}
@@ -118,13 +101,11 @@ class StreamConverterTests {
@SuppressWarnings("resource")
void convertFromListToStream() throws NoSuchFieldException {
this.conversionService.addConverterFactory(new StringToNumberConverterFactory());
List<String> stream = Arrays.asList("1", "2", "3");
List<String> list = Arrays.asList("1", "2", "3");
TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("streamOfIntegers"));
Object result = this.conversionService.convert(stream, streamOfInteger);
Object result = this.conversionService.convert(list, streamOfInteger);
assertThat(result).as("Converted object must not be null").isNotNull();
boolean condition = result instanceof Stream;
assertThat(condition).as("Converted object must be a stream").isTrue();
assertThat(result).as("Converted object must be a stream").isInstanceOf(Stream.class);
@SuppressWarnings("unchecked")
Stream<Integer> content = (Stream<Integer>) result;
assertThat(content.mapToInt(x -> x).sum()).isEqualTo(6);
@@ -133,39 +114,25 @@ class StreamConverterTests {
@Test
@SuppressWarnings("resource")
void convertFromArrayToStream() throws NoSuchFieldException {
Integer[] stream = new Integer[] {1, 0, 1};
this.conversionService.addConverter(new Converter<Integer, Boolean>() {
@Override
public Boolean convert(Integer source) {
return source == 1;
}
});
Integer[] array = new Integer[] {1, 0, 1};
this.conversionService.addConverter(Integer.class, Boolean.class, source -> source == 1);
TypeDescriptor streamOfBoolean = new TypeDescriptor(Types.class.getField("streamOfBooleans"));
Object result = this.conversionService.convert(stream, streamOfBoolean);
Object result = this.conversionService.convert(array, streamOfBoolean);
assertThat(result).as("Converted object must not be null").isNotNull();
boolean condition = result instanceof Stream;
assertThat(condition).as("Converted object must be a stream").isTrue();
@SuppressWarnings("unchecked")
Stream<Boolean> content = (Stream<Boolean>) result;
assertThat(content.filter(x -> x).count()).isEqualTo(2);
assertThat(result).asInstanceOf(stream(Boolean.class)).filteredOn(x -> x).hasSize(2);
}
@Test
@SuppressWarnings("resource")
void convertFromListToRawStream() throws NoSuchFieldException {
List<String> stream = Arrays.asList("1", "2", "3");
List<String> list = Arrays.asList("1", "2", "3");
TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("rawStream"));
Object result = this.conversionService.convert(stream, streamOfInteger);
Object result = this.conversionService.convert(list, streamOfInteger);
assertThat(result).as("Converted object must not be null").isNotNull();
boolean condition = result instanceof Stream;
assertThat(condition).as("Converted object must be a stream").isTrue();
assertThat(result).as("Converted object must be a stream").isInstanceOf(Stream.class);
@SuppressWarnings("unchecked")
Stream<Object> content = (Stream<Object>) result;
StringBuilder sb = new StringBuilder();
content.forEach(sb::append);
assertThat(sb.toString()).isEqualTo("123");
assertThat(content).containsExactly("1", "2", "3");
}
@Test
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,8 +47,8 @@ class ProfilesTests {
@Test
void ofWhenEmptyThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
Profiles.of())
assertThatIllegalArgumentException()
.isThrownBy(Profiles::of)
.withMessageContaining("Must specify at least one profile");
}
@@ -354,8 +354,8 @@ class ProfilesTests {
private static void assertMalformed(Supplier<Profiles> supplier) {
assertThatIllegalArgumentException().isThrownBy(
supplier::get)
assertThatIllegalArgumentException()
.isThrownBy(supplier::get)
.withMessageContaining("Malformed");
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -79,7 +79,7 @@ class PropertySourceTests {
PropertySource<?> ps1 = new MapPropertySource("ps1", map1);
ps1.getSource();
List<PropertySource<?>> propertySources = new ArrayList<>();
assertThat(propertySources.add(ps1)).isEqualTo(true);
assertThat(propertySources.add(ps1)).isTrue();
assertThat(propertySources.contains(ps1)).isTrue();
assertThat(propertySources.contains(PropertySource.named("ps1"))).isTrue();
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -212,7 +212,7 @@ public class StandardEnvironmentTests {
void defaultProfileWithCircularPlaceholder() {
try {
System.setProperty(DEFAULT_PROFILES_PROPERTY_NAME, "${spring.profiles.default}");
assertThatIllegalArgumentException().isThrownBy(() -> environment.getDefaultProfiles());
assertThatIllegalArgumentException().isThrownBy(environment::getDefaultProfiles);
}
finally {
System.clearProperty(DEFAULT_PROFILES_PROPERTY_NAME);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ class SystemEnvironmentPropertySourceTests {
@Test
void none() {
assertThat(ps.containsProperty("a.key")).isEqualTo(false);
assertThat(ps.containsProperty("a.key")).isFalse();
assertThat(ps.getProperty("a.key")).isNull();
}
@@ -58,7 +58,7 @@ class SystemEnvironmentPropertySourceTests {
void normalWithoutPeriod() {
envMap.put("akey", "avalue");
assertThat(ps.containsProperty("akey")).isEqualTo(true);
assertThat(ps.containsProperty("akey")).isTrue();
assertThat(ps.getProperty("akey")).isEqualTo("avalue");
}
@@ -66,7 +66,7 @@ class SystemEnvironmentPropertySourceTests {
void normalWithPeriod() {
envMap.put("a.key", "a.value");
assertThat(ps.containsProperty("a.key")).isEqualTo(true);
assertThat(ps.containsProperty("a.key")).isTrue();
assertThat(ps.getProperty("a.key")).isEqualTo("a.value");
}
@@ -74,8 +74,8 @@ class SystemEnvironmentPropertySourceTests {
void withUnderscore() {
envMap.put("a_key", "a_value");
assertThat(ps.containsProperty("a_key")).isEqualTo(true);
assertThat(ps.containsProperty("a.key")).isEqualTo(true);
assertThat(ps.containsProperty("a_key")).isTrue();
assertThat(ps.containsProperty("a.key")).isTrue();
assertThat(ps.getProperty("a_key")).isEqualTo("a_value");
assertThat( ps.getProperty("a.key")).isEqualTo("a_value");
@@ -97,30 +97,30 @@ class SystemEnvironmentPropertySourceTests {
envMap.put("A_DOT.KEY", "a_dot_value");
envMap.put("A_HYPHEN-KEY", "a_hyphen_value");
assertThat(ps.containsProperty("A_KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A.KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A-KEY")).isEqualTo(true);
assertThat(ps.containsProperty("a_key")).isEqualTo(true);
assertThat(ps.containsProperty("a.key")).isEqualTo(true);
assertThat(ps.containsProperty("a-key")).isEqualTo(true);
assertThat(ps.containsProperty("A_LONG_KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A.LONG.KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A-LONG-KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A.LONG-KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A-LONG.KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A_long_KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A.long.KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A-long-KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A.long-KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A-long.KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A_DOT.KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A-DOT.KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A_dot.KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A-dot.KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A_HYPHEN-KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A.HYPHEN-KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A_hyphen-KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A.hyphen-KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A_KEY")).isTrue();
assertThat(ps.containsProperty("A.KEY")).isTrue();
assertThat(ps.containsProperty("A-KEY")).isTrue();
assertThat(ps.containsProperty("a_key")).isTrue();
assertThat(ps.containsProperty("a.key")).isTrue();
assertThat(ps.containsProperty("a-key")).isTrue();
assertThat(ps.containsProperty("A_LONG_KEY")).isTrue();
assertThat(ps.containsProperty("A.LONG.KEY")).isTrue();
assertThat(ps.containsProperty("A-LONG-KEY")).isTrue();
assertThat(ps.containsProperty("A.LONG-KEY")).isTrue();
assertThat(ps.containsProperty("A-LONG.KEY")).isTrue();
assertThat(ps.containsProperty("A_long_KEY")).isTrue();
assertThat(ps.containsProperty("A.long.KEY")).isTrue();
assertThat(ps.containsProperty("A-long-KEY")).isTrue();
assertThat(ps.containsProperty("A.long-KEY")).isTrue();
assertThat(ps.containsProperty("A-long.KEY")).isTrue();
assertThat(ps.containsProperty("A_DOT.KEY")).isTrue();
assertThat(ps.containsProperty("A-DOT.KEY")).isTrue();
assertThat(ps.containsProperty("A_dot.KEY")).isTrue();
assertThat(ps.containsProperty("A-dot.KEY")).isTrue();
assertThat(ps.containsProperty("A_HYPHEN-KEY")).isTrue();
assertThat(ps.containsProperty("A.HYPHEN-KEY")).isTrue();
assertThat(ps.containsProperty("A_hyphen-KEY")).isTrue();
assertThat(ps.containsProperty("A.hyphen-KEY")).isTrue();
assertThat(ps.getProperty("A_KEY")).isEqualTo("a_value");
assertThat(ps.getProperty("A.KEY")).isEqualTo("a_value");
@@ -170,7 +170,7 @@ class SystemEnvironmentPropertySourceTests {
}
};
assertThat(ps.containsProperty("A_KEY")).isEqualTo(true);
assertThat(ps.containsProperty("A_KEY")).isTrue();
assertThat(ps.getProperty("A_KEY")).isEqualTo("a_value");
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -124,37 +124,37 @@ class PathResourceTests {
@Test
void fileExists() {
PathResource resource = new PathResource(TEST_FILE);
assertThat(resource.exists()).isEqualTo(true);
assertThat(resource.exists()).isTrue();
}
@Test
void dirExists() {
PathResource resource = new PathResource(TEST_DIR);
assertThat(resource.exists()).isEqualTo(true);
assertThat(resource.exists()).isTrue();
}
@Test
void fileDoesNotExist() {
PathResource resource = new PathResource(NON_EXISTING_FILE);
assertThat(resource.exists()).isEqualTo(false);
assertThat(resource.exists()).isFalse();
}
@Test
void fileIsReadable() {
PathResource resource = new PathResource(TEST_FILE);
assertThat(resource.isReadable()).isEqualTo(true);
assertThat(resource.isReadable()).isTrue();
}
@Test
void doesNotExistIsNotReadable() {
PathResource resource = new PathResource(NON_EXISTING_FILE);
assertThat(resource.isReadable()).isEqualTo(false);
assertThat(resource.isReadable()).isFalse();
}
@Test
void directoryIsNotReadable() {
PathResource resource = new PathResource(TEST_DIR);
assertThat(resource.isReadable()).isEqualTo(false);
assertThat(resource.isReadable()).isFalse();
}
@Test
@@ -256,13 +256,13 @@ class PathResourceTests {
@Test
void fileIsWritable() {
PathResource resource = new PathResource(TEST_FILE);
assertThat(resource.isWritable()).isEqualTo(true);
assertThat(resource.isWritable()).isTrue();
}
@Test
void directoryIsNotWritable() {
PathResource resource = new PathResource(TEST_DIR);
assertThat(resource.isWritable()).isEqualTo(false);
assertThat(resource.isWritable()).isFalse();
}
@Test
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -80,7 +80,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
super.bufferFactory = bufferFactory;
Flux<DataBuffer> flux = DataBufferUtils.readInputStream(
() -> this.resource.getInputStream(), super.bufferFactory, 3);
this.resource::getInputStream, super.bufferFactory, 3);
verifyReadData(flux);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
package org.springframework.core.task;
import java.util.concurrent.ThreadFactory;
import org.junit.jupiter.api.Test;
import org.springframework.util.ConcurrencyThrottleSupport;
@@ -61,12 +59,7 @@ class SimpleAsyncTaskExecutorTests {
@Test
void threadFactoryOverridesDefaults() throws Exception {
final Object monitor = new Object();
SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
return new Thread(r, "test");
}
});
SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor(runnable -> new Thread(runnable, "test"));
ThreadNameHarvester task = new ThreadNameHarvester(monitor);
executeAndWait(executor, task, monitor);
assertThat(task.getThreadName()).isEqualTo("test");
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -115,7 +115,7 @@ class AnnotationMetadataTests {
assertThat(metadata.getAnnotationAttributes(MetaAnnotation.class.getName(), false)).isNull();
assertThat(metadata.getAnnotationAttributes(MetaAnnotation.class.getName(), true)).isNull();
assertThat(metadata.getAnnotatedMethods(DirectAnnotation.class.getName()).size()).isEqualTo(0);
assertThat(metadata.isAnnotated(IsAnnotatedAnnotation.class.getName())).isEqualTo(false);
assertThat(metadata.isAnnotated(IsAnnotatedAnnotation.class.getName())).isFalse();
assertThat(metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName())).isNull();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,8 +28,8 @@ class PatternMatchUtilsTests {
@Test
void trivial() {
assertThat(PatternMatchUtils.simpleMatch((String) null, "")).isEqualTo(false);
assertThat(PatternMatchUtils.simpleMatch("1", null)).isEqualTo(false);
assertThat(PatternMatchUtils.simpleMatch((String) null, "")).isFalse();
assertThat(PatternMatchUtils.simpleMatch("1", null)).isFalse();
doTest("*", "123", true);
doTest("123", "123", true);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,18 +37,18 @@ class StringUtilsTests {
@Test
void hasTextBlank() {
String blank = " ";
assertThat(StringUtils.hasText(blank)).isEqualTo(false);
assertThat(StringUtils.hasText(blank)).isFalse();
}
@Test
void hasTextNullEmpty() {
assertThat(StringUtils.hasText(null)).isEqualTo(false);
assertThat(StringUtils.hasText("")).isEqualTo(false);
assertThat(StringUtils.hasText(null)).isFalse();
assertThat(StringUtils.hasText("")).isFalse();
}
@Test
void hasTextValid() {
assertThat(StringUtils.hasText("t")).isEqualTo(true);
assertThat(StringUtils.hasText("t")).isTrue();
}
@Test
@@ -68,7 +68,7 @@ class StringUtilsTests {
@Test
void trimWhitespace() {
assertThat(StringUtils.trimWhitespace(null)).isEqualTo(null);
assertThat(StringUtils.trimWhitespace(null)).isNull();
assertThat(StringUtils.trimWhitespace("")).isEqualTo("");
assertThat(StringUtils.trimWhitespace(" ")).isEqualTo("");
assertThat(StringUtils.trimWhitespace("\t")).isEqualTo("");
@@ -83,7 +83,7 @@ class StringUtilsTests {
@Test
void trimAllWhitespace() {
assertThat(StringUtils.trimAllWhitespace(null)).isEqualTo(null);
assertThat(StringUtils.trimAllWhitespace(null)).isNull();
assertThat(StringUtils.trimAllWhitespace("")).isEqualTo("");
assertThat(StringUtils.trimAllWhitespace(" ")).isEqualTo("");
assertThat(StringUtils.trimAllWhitespace("\t")).isEqualTo("");
@@ -98,7 +98,7 @@ class StringUtilsTests {
@Test
void trimLeadingWhitespace() {
assertThat(StringUtils.trimLeadingWhitespace(null)).isEqualTo(null);
assertThat(StringUtils.trimLeadingWhitespace(null)).isNull();
assertThat(StringUtils.trimLeadingWhitespace("")).isEqualTo("");
assertThat(StringUtils.trimLeadingWhitespace(" ")).isEqualTo("");
assertThat(StringUtils.trimLeadingWhitespace("\t")).isEqualTo("");
@@ -113,7 +113,7 @@ class StringUtilsTests {
@Test
void trimTrailingWhitespace() {
assertThat(StringUtils.trimTrailingWhitespace(null)).isEqualTo(null);
assertThat(StringUtils.trimTrailingWhitespace(null)).isNull();
assertThat(StringUtils.trimTrailingWhitespace("")).isEqualTo("");
assertThat(StringUtils.trimTrailingWhitespace(" ")).isEqualTo("");
assertThat(StringUtils.trimTrailingWhitespace("\t")).isEqualTo("");
@@ -128,7 +128,7 @@ class StringUtilsTests {
@Test
void trimLeadingCharacter() {
assertThat(StringUtils.trimLeadingCharacter(null, ' ')).isEqualTo(null);
assertThat(StringUtils.trimLeadingCharacter(null, ' ')).isNull();
assertThat(StringUtils.trimLeadingCharacter("", ' ')).isEqualTo("");
assertThat(StringUtils.trimLeadingCharacter(" ", ' ')).isEqualTo("");
assertThat(StringUtils.trimLeadingCharacter("\t", ' ')).isEqualTo("\t");
@@ -141,7 +141,7 @@ class StringUtilsTests {
@Test
void trimTrailingCharacter() {
assertThat(StringUtils.trimTrailingCharacter(null, ' ')).isEqualTo(null);
assertThat(StringUtils.trimTrailingCharacter(null, ' ')).isNull();
assertThat(StringUtils.trimTrailingCharacter("", ' ')).isEqualTo("");
assertThat(StringUtils.trimTrailingCharacter(" ", ' ')).isEqualTo("");
assertThat(StringUtils.trimTrailingCharacter("\t", ' ')).isEqualTo("\t");
@@ -152,6 +152,14 @@ class StringUtilsTests {
assertThat(StringUtils.trimTrailingCharacter(" a b c ", ' ')).isEqualTo(" a b c");
}
@Test
void matchesCharacter() {
assertThat(StringUtils.matchesCharacter(null, '/')).isFalse();
assertThat(StringUtils.matchesCharacter("/a", '/')).isFalse();
assertThat(StringUtils.matchesCharacter("a", '/')).isFalse();
assertThat(StringUtils.matchesCharacter("/", '/')).isTrue();
}
@Test
void startsWithIgnoreCase() {
String prefix = "fOo";
@@ -332,7 +340,7 @@ class StringUtilsTests {
@Test
void getFilename() {
assertThat(StringUtils.getFilename(null)).isEqualTo(null);
assertThat(StringUtils.getFilename(null)).isNull();
assertThat(StringUtils.getFilename("")).isEqualTo("");
assertThat(StringUtils.getFilename("myfile")).isEqualTo("myfile");
assertThat(StringUtils.getFilename("mypath/myfile")).isEqualTo("myfile");
@@ -344,11 +352,11 @@ class StringUtilsTests {
@Test
void getFilenameExtension() {
assertThat(StringUtils.getFilenameExtension(null)).isEqualTo(null);
assertThat(StringUtils.getFilenameExtension("")).isEqualTo(null);
assertThat(StringUtils.getFilenameExtension("myfile")).isEqualTo(null);
assertThat(StringUtils.getFilenameExtension("myPath/myfile")).isEqualTo(null);
assertThat(StringUtils.getFilenameExtension("/home/user/.m2/settings/myfile")).isEqualTo(null);
assertThat(StringUtils.getFilenameExtension(null)).isNull();
assertThat(StringUtils.getFilenameExtension("")).isNull();
assertThat(StringUtils.getFilenameExtension("myfile")).isNull();
assertThat(StringUtils.getFilenameExtension("myPath/myfile")).isNull();
assertThat(StringUtils.getFilenameExtension("/home/user/.m2/settings/myfile")).isNull();
assertThat(StringUtils.getFilenameExtension("myfile.")).isEqualTo("");
assertThat(StringUtils.getFilenameExtension("myPath/myfile.")).isEqualTo("");
assertThat(StringUtils.getFilenameExtension("myfile.txt")).isEqualTo("txt");

Some files were not shown because too many files have changed in this diff Show More