Commit Graph

1429 Commits

Author SHA1 Message Date
Juergen Hoeller
6b1fbc9fe1 Revise ResolvableType equality
ResolvableTypes are only considered equal if of the very same class now.
As a consequence, a forRawClass result is not equal to forClass anymore.
The new equalsType method is available for plain type equality checks.

Closes gh-28608
Closes gh-27748
2023-07-09 12:35:37 +02:00
Sam Brannen
0bf85af8e9 Merge branch '6.0.x'
# Conflicts:
#	framework-docs/modules/ROOT/pages/integration/observability.adoc
#	spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java
2023-07-06 14:11:24 +02:00
Sam Brannen
826776f321 Improve assertions in DefaultConversionServiceTests
Specifically, we now check the actual type of a converted collection in
various assertions to ensure that converters adhere to their contracts.
2023-07-06 14:01:26 +02:00
Juergen Hoeller
0c8d3e70cf Prefer ArrayList for Collection when source is an array
Closes gh-28048
2023-07-05 20:23:17 +02:00
Juergen Hoeller
47e631d5ff Merge branch '6.0.x' 2023-07-05 20:15:53 +02:00
Juergen Hoeller
b7b9f2cb6b Expand tests for array to Collection/Set/List interface
See gh-28048
2023-07-05 20:15:10 +02:00
Sam Brannen
e86003b692 Merge branch '6.0.x' 2023-07-05 17:02:35 +02:00
Sam Brannen
b76664e757 Support arrays, collections, & maps in ObjectUtils.nullSafeConciseToString()
Prior to this commit, there was no explicit support for arrays,
collections, and maps in nullSafeConciseToString(). This lead to string
representations such as the following, regardless of whether the array,
collection, or map was empty.

- char[]@1623b78d
- java.util.ImmutableCollections$List12@74fe5c40
- java.util.ImmutableCollections$MapN@10e31a9a

This commit introduces explicit support for arrays, collections, and
maps in nullSafeConciseToString(), which results in the following
empty/non-empty string representations.

- array: {} / {...}
- collection: [] / [...]
- map: {} / {...}

The reason a string representation of an array uses "{}" instead of
"[]" (like in Arrays.toString(...)) is that
ObjectUtils.nullSafeToString(<array>) already follows that convention,
and the implementation of nullSafeConciseToString() aligns with that
for the sake of consistency.

Closes gh-30810
2023-07-05 17:01:01 +02:00
Juergen Hoeller
420255373d Merge branch '6.0.x' 2023-07-04 16:53:17 +02:00
Juergen Hoeller
80a20488fd Make File/Path tests pass on Windows
See gh-30806
2023-07-04 16:52:39 +02:00
Sam Brannen
7156ea016e Merge branch '6.0.x'
# Conflicts:
#	spring-core/src/main/java/org/springframework/util/ObjectUtils.java
2023-07-04 13:44:19 +02:00
Sam Brannen
3ef1b7d83c Extend supported types in ObjectUtils.nullSafeConciseToString()
This commit extends the list of explicitly supported types in
ObjectUtils.nullSafeConciseToString() with the following.

- Optional
- File
- Path
- InetAddress
- Charset
- Currency
- TimeZone
- ZoneId
- Pattern

Closes gh-30805
2023-07-04 13:27:47 +02:00
Sam Brannen
08bce69d3d Add tests for status quo in ObjectUtils.nullSafeConciseToString() 2023-07-04 13:15:56 +02:00
Sam Brannen
9ac2443b78 Polish ModuleResource[Tests] 2023-07-01 16:49:32 +02:00
Sébastien Deleuze
f075120675 Support WildcardType resolution in GenericTypeResolver
This commit adds support for WildcardType bounds resolution,
commonly seen in Kotlin due to declaration-site variance,
but also possible in Java even if less common.

Closes gh-22313
2023-06-30 15:26:32 +02:00
Sam Brannen
b8f091e2f6 Merge branch '6.0.x' 2023-06-30 14:17:49 +02:00
Sam Brannen
c95426a616 Polishing 2023-06-30 13:55:34 +02:00
Juergen Hoeller
31a51cca4f Support for getFilename() in ModuleResource
See gh-28507
2023-06-30 00:35:14 +02:00
Juergen Hoeller
7028de9dbd Merge branch '6.0.x' 2023-06-29 18:04:40 +02:00
Juergen Hoeller
0c39fff831 Polishing 2023-06-29 18:04:08 +02:00
Juergen Hoeller
6061fdf231 Introduce ModuleResource for resources loaded from a given Module
Closes gh-28507
2023-06-29 17:18:46 +02:00
Sam Brannen
526d9eae7f Merge branch '6.0.x' 2023-06-15 16:20:19 +02:00
Sam Brannen
4565bcd757 Update copyright headers 2023-06-15 16:19:58 +02:00
Juergen Hoeller
858ea1a8c5 Merge branch '6.0.x' 2023-06-14 09:32:30 +02:00
Juergen Hoeller
927d27b121 Consider UUID as simple value type with concise toString output
Closes gh-30661
2023-06-14 09:31:35 +02:00
Sébastien Deleuze
46fe7f5bea Merge branch '6.0.x' 2023-06-09 14:17:45 +02:00
Sébastien Deleuze
9b4e0e9837 Add missing hint for converting String to URI
Closes gh-30627
2023-06-09 14:14:54 +02:00
Juergen Hoeller
53f891226e Merge branch '6.0.x'
# Conflicts:
#	spring-core/src/main/java/org/springframework/core/CollectionFactory.java
2023-06-05 13:59:37 +02:00
Juergen Hoeller
cdc4497664 Restore creation of plain HashSet/HashMap for direct HashSet/HashMap type
Closes gh-30596
2023-06-05 13:57:59 +02:00
Sam Brannen
8d6d99731f Delete unused code 2023-05-23 15:09:38 +02:00
Sam Brannen
e51c71bcd6 Delete unused code 2023-05-10 14:26:41 +02:00
rstoyanchev
944305b9f1 Merge branch '6.0.x' 2023-05-09 19:59:11 +01:00
rstoyanchev
e737980033 Ensure chunks released on cancel in StringDecoder
The current test were not catching the issue because they request 1
via StepVerifier, wait for it, and then cancel. In the case of
StringDecoder it means all chunks are used up to produce that first
String and so the cancel doesn't catch any cached chunks.

Closes gh-30299
2023-05-09 19:58:36 +01:00
Juergen Hoeller
c09055b83a Consistent support for MultiValueMap and common Map implementations
Closes gh-30440
2023-05-08 12:01:58 +02:00
Juergen Hoeller
697d5e6247 Configuration options for virtual threads (on JDK 21)
VirtualThreadDelegate built on JDK 21 for multi-release jar.
Includes dedicated VirtualThreadTaskExecutor as lean option.
Includes setVirtualThreads flag on SimpleAsyncTaskExecutor.
Includes additional default methods on AsyncTaskExecutor.

Closes gh-30241
2023-05-08 11:22:47 +02:00
Juergen Hoeller
87942ed71d Support for SequencedCollection/Set/Map (on JDK 21)
Includes consistent support for MultiValueMap.

Closes gh-30239
2023-05-03 10:16:25 +02:00
Juergen Hoeller
4d15b58ca4 Remove LocalVariableTableParameterNameDiscoverer
Closes gh-29559
2023-04-30 23:05:09 +02:00
Sam Brannen
ce3e9b0c29 Polishing 2023-04-26 11:21:34 +02:00
Sam Brannen
7e0620a143 Use new Environment.matchesProfiles() method 2023-04-26 11:09:38 +02:00
Sam Brannen
e19472568f Merge branch '6.0.x' 2023-04-25 18:11:35 +02:00
Sam Brannen
d023b94a42 Introduce Environment.matchesProfiles() for profile expressions
Environment.acceptsProfiles(String...) was deprecated in 5.1 in
conjunction with gh-17063 which introduced a new
acceptsProfiles(Profiles) method to replace it. The deprecated method
only supports OR semantics; whereas, the new method supports profile
expressions. Thus, the goal was to encourage people to use the more
powerful profile expressions instead of the limited OR support with
profile names.

However, there are use cases where it is difficult (if not impossible)
to provide a Profiles instance, and there are use cases where it is
simply preferable to provide profile expressions directly as strings.

To address these issues, this commit introduces a new matchesProfiles()
method in Environment that accepts a var-args list of profile
expressions.

Closes gh-30206
2023-04-25 18:10:50 +02:00
Sam Brannen
47ba819f96 Polish Environment and StandardEnvironmentTests
See gh-30206
2023-04-25 18:10:39 +02:00
Sam Brannen
845488af8d Improve toString() for Profiles.of() implementation
Prior to this commit, the toString() implementation in ProfilesParser
(which is the internal implementation of Profiles.of()) concatenated
profile expressions with " or ".

For example, the string representation of
Profiles.of("spring & framework", "java | kotlin") was
"spring & framework or java | kotlin".

This commit improves the toString() implementation by wrapping
individual profile expressions in parentheses and concatenating them
with " | ".

For example, the string representation from the previous example is now
"(spring & framework) | (java | kotlin)".

This makes it easier to read (for example, when debugging) and
comprehend.

As an additional benefit, the result of invoking toString() can even be
used as a logically equivalent composite profile expression, though
that is not the primary goal of this change.

Closes gh-30374
2023-04-25 16:49:34 +02:00
Sam Brannen
842490beeb Add tests for corner cases
See gh-30290
See gh-30286
2023-04-05 15:05:25 +02:00
Sam Brannen
e746230de6 Introduce ObjectUtils.nullSafeConciseToString()
ObjectUtils.nullSafeToString(Object) exists for generating a string
representation of various objects in a "null-safe" manner, including
support for object graphs, collections, etc.

However, there are times when we would like to generate a "concise",
null-safe string representation that does not include an entire object
graph (or potentially a collection of object graphs).

This commit introduces ObjectUtils.nullSafeConciseToString(Object) to
address this need and makes use of the new feature in FieldError and
ConversionFailedException.

Closes gh-30286
2023-04-05 14:13:28 +02:00
Sam Brannen
8161316b1d Introduce StringUtils.truncate()
StringUtils.truncate() serves as central, consistent way for truncating
strings used in log messages and exception failure messages, for
immediate use in LogFormatUtils and ObjectUtils.

See gh-30286
Closes gh-30290
2023-04-05 13:50:13 +02:00
Krzysztof Krasoń
1734deca1e Refactor AssertJ assertions into more idiomatic ones
This commit refactors some AssertJ assertions into more idiomatic and
readable ones. Using the dedicated assertion instead of a generic one
will produce more meaningful error messages. 

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

Closes gh-30104
2023-04-04 17:34:07 +02:00
Sam Brannen
69c8f8e9c7 Update copyright headers 2023-04-03 16:45:49 +02:00
Sam Brannen
ca7c2779bf Suppress warnings displayed in Gradle build for test source code 2023-04-01 18:36:56 +02:00
Sébastien Deleuze
807325916f Add class hints for Jackson annotations on fields and methods
Before this commit, only class level annotations were
processed.

Closes gh-30208
2023-03-31 10:39:18 +02:00