Commit Graph

1902 Commits

Author SHA1 Message Date
Sam Brannen 4000b244ff Forbid null converters in RestTemplate & HttpMessageConverterExtractor
Prior to this commit, RestTemplate and HttpMessageConverterExtractor did
not validate that the supplied HttpMessageConverter list contained no
null elements, which can lead to a NullPointerException when the
converters are accessed.

This commit improves the user experience by failing immediately if the
supplied HttpMessageConverter list contains a null element. This applies
to constructors for RestTemplate and HttpMessageConverterExtractor as
well as to RestTemplate#setMessageConverters().

Note, however, that RestTemplate#getMessageConverters() returns a mutable
list. Thus, if a user modifies that list so that it contains null values,
that will still lead to a NullPointerException when the converters are
accessed.

This commit also introduces noNullElements() variants for collections in
org.springframework.util.Assert.

Closes gh-23151
2019-06-18 16:13:20 +03:00
Sam Brannen f6a4595cef Polishing 2019-06-17 17:06:37 +03:00
Arjen Poutsma f08656c6cb Add methods to read/write from Path to DataBufferUtils
This commit adds two methods to DataBufferUtils:
- one that reads a Flux<DataBuffer> from a Path
- one that writes a Flux<DataBuffer> to a Path
2019-06-14 14:13:18 +02:00
Juergen Hoeller 0a77477d32 Merge branch '5.1.x' 2019-06-12 18:16:30 +02:00
Juergen Hoeller fc46abf0b7 Polishing 2019-06-12 18:04:06 +02:00
Juergen Hoeller 1ccd99ebe7 Polishing 2019-06-12 14:11:39 +02:00
Juergen Hoeller 918ffacdf8 Polishing 2019-06-12 13:29:35 +02:00
Sam Brannen bee4fb0615 Polishing 2019-06-12 14:07:04 +03:00
Sam Brannen 049437e111 Log exception when closing InputStream in AbstractResource
Prior to this commit, exceptions thrown while closing an InputStream in
AbstractResource were silently ignored.

This commit improves diagnostics for such failure scenarios by logging
the exception at DEBUG level.

Closes gh-23116
2019-06-12 14:07:04 +03:00
Juergen Hoeller 33b5bc2aae Polishing 2019-06-11 23:50:29 +02:00
Juergen Hoeller a89bfffd8c Merge branch '5.1.x' 2019-06-11 23:16:03 +02:00
Phillip Webb 6ac68391c1 Polishing 2019-06-11 12:03:05 -07:00
Phillip Webb b21b27c5ac Add MultiValueMap.addIfAbsent method
Closes gh-23111
2019-06-11 12:03:05 -07:00
Juergen Hoeller 7dc92aa05d Polishing 2019-06-11 20:57:27 +02:00
Juergen Hoeller 4fc9747569 Defensive concurrent access to key set from java.util.Properties
Closes gh-23063
2019-06-11 20:56:57 +02:00
Juergen Hoeller b37390b8fe Restore javax meta-annotation lookup behavior
Closes gh-22957
2019-06-11 20:56:41 +02:00
Sebastien Deleuze 098ac0bbb8 Annotate Object#equals parameter with @Nullable
Closes gh-23093
2019-06-06 14:18:30 +02:00
Sebastien Deleuze 044ea17bf9 Polishing 2019-06-05 12:13:36 +02:00
Sebastien Deleuze 2a19b8f7a5 Refine Coroutines adapter registration activation
Closes gh-23087
2019-06-05 11:52:00 +02:00
Sam Brannen 3b37989774 Apply De Morgan's law for greater clarity of purpose 2019-06-05 10:29:24 +03:00
Sam Brannen 410f204168 Support consistent ordering of string adapting properties
This commit introduces support for consistent ordering of Properties
created by CollectionFactory.createStringAdaptingProperties().

Specifically, the created Properties instance sorts properties
alphanumerically based on their keys.

Closes gh-23081
2019-06-04 14:47:43 +03:00
Stephane Nicoll 0ef4349c4d Polish "Replace with 'Integer.compare()'"
See gh-23071
2019-06-03 08:31:57 +02:00
Issam El-atif 7ce3792672 Replace with 'Integer.compare()'
See gh-23071
2019-06-03 08:31:19 +02:00
Sam Brannen f66eef1f88 Fix SortedPropertiesTests on JDK 9+ 2019-05-30 10:41:49 +02:00
Sam Brannen 53597f90e9 Remove dependency on StringUtils in SortedProperties
See gh-23018, gh-22383
2019-05-28 18:31:54 +02:00
Sam Brannen c6818fe15b Polishing
See gh-23018
2019-05-28 14:53:24 +02:00
Sam Brannen d495902a9c Polish Javadoc 2019-05-28 12:37:50 +02:00
Sam Brannen c39c4211df Introduce support for sorted Properties
This commit introduces an internal SortedProperties class that is a
specialization of java.util.Properties which sorts properties
alphanumerically based on their keys.

This can be useful when storing a java.util.Properties instance in a
properties file, since it allows such files to be generated in a
repeatable manner with consistent ordering of properties.

Comments in generated properties files can also be optionally omitted.

An instance of SortedProperties can be created via two new
createSortedProperties() factory methods in
org.springframework.core.CollectionFactory.

Closes gh-23018
2019-05-28 12:23:56 +02:00
Phillip Webb 6f2f5bb8c1 Fix annotation exceptions in tight memory
Update `AnnotationTypeMapping` so that instance comparisons are no
longer used when checking attribute methods. Prior to this commit,
in an environment with tightly constrained memory, the method cache
could be cleared and different method instances would be returned.

Closes gh-23010
2019-05-26 14:59:33 -07:00
Phillip Webb e386e53f92 Use less confusing MergedAnnotation method names
Rename some `MergedAnnotation` methods to prevent using parent/child
terminology, specifically:

	`getDepth()` has been renamed `getDistance()`
	`getParent()` has been renamed `getMetaSource()`
	`getTypeHierarchy()` has been renamed `getMetaTypes()`

The parent child naming was particularly confusing given that the
parent/child relationships were inverted from the way that a lot of
users think about meta-annotations. For example, a `@RequestMapping`
having a parent of `@GetMapping` feels odd given that `@GetMapping`
is the thing declaring the meta-annotation relationship.

The new method names are designed to align more closely with existing
terms. For example, `getMetaSource` hints at the relationship with
`isMetaAnnotated` and `getSource`.

Closes gh-22946
2019-05-26 13:15:59 -07:00
Sam Brannen 43119deb08 Polishing 2019-05-26 14:28:09 +02:00
Phillip Webb 9d74da006c Migrate JUnit 4 assertions to AssertJ
Migrate all existing JUnit 4 `assert...` based assertions to AssertJ
and add a checkstyle rule to ensure they don't return.

See gh-23022
2019-05-23 15:52:49 -07:00
Phillip Webb 95a9d46a87 Migrate Hamcrest assertions to AssertJ
Migrate all existing `assertThat(..., Matcher)` assertions to AssertJ
and add checkstyle rules to ensure they don't return.

See gh-23022
2019-05-23 15:49:59 -07:00
Rossen Stoyanchev 71396121a7 Merge branch '5.1.x' 2019-05-23 09:57:29 -04:00
Rossen Stoyanchev 99302fd6bd AntPathMatcher#isPattern also checks URI vars
Closes gh-22959
2019-05-23 09:56:11 -04:00
Juergen Hoeller 8a33ef2d14 Merge branch '5.1.x' 2019-05-21 21:06:38 +02:00
Juergen Hoeller 701b7b8a18 Align ReactiveTypeDescriptor accessor methods 2019-05-21 20:46:27 +02:00
Juergen Hoeller ff838fd011 Consistently support CompletionStage in ReactiveAdapterRegistry
Aligns ReactiveAdapterRegistry with MVC/messaging handler methods in terms of recognizing CompletionStage as well as CompletableFuture. Includes consistent use of ReactiveAdapter for reactive transactions.

Closes gh-23011
2019-05-21 19:26:12 +02:00
Juergen Hoeller 171e8f56a3 Merge branch '5.1.x' 2019-05-20 22:27:37 +02:00
Juergen Hoeller 55e601c322 Revise system property replacement tests
See gh-22959
2019-05-20 22:19:03 +02:00
Phillip Webb 02850f357f Migrate exception checking tests to use AssertJ
Migrate tests that use `@Test(expectedException=...)` or
`try...fail...catch` to use AssertJ's `assertThatException`
instead.
2019-05-20 10:47:53 -07:00
Arjen Poutsma a30a134c23 Make StringDecoder use DataBufferUtils.split
* Added DataBufferUtils.split variant that takes multiple delimiters
  as argument (instead of 1).
* Use this new split() variant from within StringDecoder, replacing
  its inefficient algorithm with the Knuth-Morris-Pratt algorithm.
2019-05-15 16:07:28 +02:00
Rossen Stoyanchev b1912f6acc Fix checkstyle error 2019-05-15 08:29:41 -04:00
Rossen Stoyanchev 97c2de915a Add RouteMatcher
Closes gh-22642
2019-05-14 21:44:39 -04:00
Sam Brannen 785e8d8116 Polish MergedAnnotation support 2019-05-13 14:11:29 +02:00
Sam Brannen deecab6311 Use assertThat from Hamcrest instead of JUnit 4
org.junit.Assert.assertThat() is deprecated as of JUnit 4.13.

See gh-22894
2019-05-12 14:46:55 +02:00
Sam Brannen 64819bbc1d Clean up warnings 2019-05-10 18:00:29 +02:00
Phillip Webb 798b51f4a3 Migrate to BDD Mockito
Migrate all tests to consistently use BDD Mockito. Also add
checksyle rule to enforce going forwards.
2019-05-08 13:46:13 -07:00
Phillip Webb 816bbee8de Remove '.*' imports from tests
Organize test imports to expand all '.*' static imports into
fully qualified imports.

This update will allow us to use additional checkstyle rules in
the future, and will also help if we migrate fully to AssertJ.
2019-05-08 09:55:09 -07:00
Phillip Webb 66eb86f055 Delete unused Matchers class
Delete the `Matches` class since it's no longer being used.
2019-05-08 09:52:39 -07:00