Skip to content

Commit 1a6fce1

Browse files
Merge branch 'main' of https://github.com/spring-projects/spring-data-commons into remote-unused-import
Signed-off-by: Tran Ngoc Nhan <[email protected]> # Conflicts: # src/test/java/org/springframework/data/repository/query/ParameterUnitTests.java
2 parents b8559a9 + c76db4a commit 1a6fce1

File tree

142 files changed

+1052
-302
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+1052
-302
lines changed

src/main/antora/modules/ROOT/pages/auditing.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33

44
[[auditing.basics]]
55
== Basics
6-
Spring Data provides sophisticated support to transparently keep track of who created or changed an entity and when the change happened.To benefit from that functionality, you have to equip your entity classes with auditing metadata that can be defined either using annotations or by implementing an interface.
6+
7+
Spring Data provides sophisticated support to transparently keep track of who created or changed an entity and when the change happened.
8+
To benefit from that functionality, you have to equip your entity classes with auditing metadata that can be defined either using annotations or by implementing an interface.
79
Additionally, auditing has to be enabled either through Annotation configuration or XML configuration to register the required infrastructure components.
810
Please refer to the store-specific section for configuration samples.
911

1012
[NOTE]
1113
====
1214
Applications that only track creation and modification dates are not required do make their entities implement <<auditing.auditor-aware,`AuditorAware`>>.
15+
If no `AuditorAware` or `DateTimeProvider` bean is configured, `AuditingHandler` will use Spring's autowiring to detect a matching bean if beans of the corresponding type are available in the application context.
1316
====
1417

1518
[[auditing.annotations]]

src/main/java/org/springframework/data/aot/AotMappingContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.UUID;
2222
import java.util.function.Predicate;
2323

24+
import org.springframework.data.core.TypeInformation;
2425
import org.springframework.data.domain.Page;
2526
import org.springframework.data.geo.Point;
2627
import org.springframework.data.mapping.Association;
@@ -34,7 +35,6 @@
3435
import org.springframework.data.mapping.model.EntityInstantiators;
3536
import org.springframework.data.mapping.model.Property;
3637
import org.springframework.data.mapping.model.SimpleTypeHolder;
37-
import org.springframework.data.util.TypeInformation;
3838

3939
/**
4040
* Simple {@link AbstractMappingContext} for processing of AOT contributions.

src/main/java/org/springframework/data/aot/AuditingBeanRegistrationAotProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
2626
import org.springframework.beans.factory.support.RegisteredBean;
2727
import org.springframework.core.DecoratingProxy;
28+
import org.springframework.data.core.ReactiveWrappers;
2829
import org.springframework.data.domain.AuditorAware;
2930
import org.springframework.data.domain.ReactiveAuditorAware;
30-
import org.springframework.data.util.ReactiveWrappers;
3131
import org.springframework.util.ClassUtils;
3232

3333
/**

src/main/java/org/springframework/data/auditing/AuditingHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
import org.apache.commons.logging.Log;
2121
import org.apache.commons.logging.LogFactory;
22+
import org.jspecify.annotations.Nullable;
23+
2224
import org.springframework.beans.factory.InitializingBean;
2325
import org.springframework.data.domain.AuditorAware;
2426
import org.springframework.data.mapping.context.MappingContext;
@@ -66,12 +68,10 @@ public static AuditingHandler from(MappingContext<?, ?> mappingContext) {
6668
/**
6769
* Setter to inject a {@code AuditorAware} component to retrieve the current auditor.
6870
*
69-
* @param auditorAware must not be {@literal null}.
71+
* @param auditorAware can be {@literal null} if no auditor-aware is available.
7072
*/
71-
public void setAuditorAware(AuditorAware<?> auditorAware) {
72-
73-
Assert.notNull(auditorAware, "AuditorAware must not be null");
74-
this.auditorAware = Optional.of(auditorAware);
73+
public void setAuditorAware(@Nullable AuditorAware<?> auditorAware) {
74+
this.auditorAware = Optional.ofNullable(auditorAware);
7575
}
7676

7777
/**

src/main/java/org/springframework/data/auditing/ReactiveAuditingHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import reactor.core.publisher.Mono;
1919

20+
import org.jspecify.annotations.Nullable;
21+
2022
import org.springframework.data.domain.ReactiveAuditorAware;
2123
import org.springframework.data.mapping.context.MappingContext;
2224
import org.springframework.data.mapping.context.PersistentEntities;
@@ -56,12 +58,10 @@ public static ReactiveAuditingHandler from(MappingContext<?, ?> mappingContext)
5658
/**
5759
* Setter to inject a {@link ReactiveAuditorAware} component to retrieve the current auditor.
5860
*
59-
* @param auditorAware must not be {@literal null}.
61+
* @param auditorAware can be {@literal null}.
6062
*/
61-
public void setAuditorAware(ReactiveAuditorAware<?> auditorAware) {
62-
63-
Assert.notNull(auditorAware, "AuditorAware must not be null");
64-
this.auditorAware = auditorAware;
63+
public void setAuditorAware(@Nullable ReactiveAuditorAware<?> auditorAware) {
64+
this.auditorAware = auditorAware == null ? Mono::empty : auditorAware;
6565
}
6666

6767
/**

src/main/java/org/springframework/data/auditing/config/AuditingBeanDefinitionRegistrarSupport.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@
2121

2222
import org.springframework.aop.framework.ProxyFactoryBean;
2323
import org.springframework.aop.target.LazyInitTargetSource;
24-
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
2524
import org.springframework.beans.factory.config.BeanDefinition;
2625
import org.springframework.beans.factory.support.AbstractBeanDefinition;
2726
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
2827
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
2928
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
3029
import org.springframework.core.type.AnnotationMetadata;
3130
import org.springframework.data.auditing.AuditingHandler;
32-
import org.springframework.data.auditing.CurrentDateTimeProvider;
3331
import org.springframework.util.Assert;
3432
import org.springframework.util.StringUtils;
3533

@@ -42,6 +40,7 @@
4240
* @author Thomas Darimont
4341
* @author Oliver Gierke
4442
* @author Francisco Soler
43+
* @author Jaeyeon Kim
4544
*/
4645
public abstract class AuditingBeanDefinitionRegistrarSupport implements ImportBeanDefinitionRegistrar {
4746

@@ -120,17 +119,19 @@ protected BeanDefinitionBuilder configureDefaultAuditHandlerAttributes(AuditingC
120119
if (StringUtils.hasText(configuration.getAuditorAwareRef())) {
121120
builder.addPropertyValue(AUDITOR_AWARE,
122121
createLazyInitTargetSourceBeanDefinition(configuration.getAuditorAwareRef()));
123-
} else {
124-
builder.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE);
122+
}
123+
else {
124+
builder.addAutowiredProperty(AUDITOR_AWARE);
125125
}
126126

127127
builder.addPropertyValue(SET_DATES, configuration.isSetDates());
128128
builder.addPropertyValue(MODIFY_ON_CREATE, configuration.isModifyOnCreate());
129129

130130
if (StringUtils.hasText(configuration.getDateTimeProviderRef())) {
131131
builder.addPropertyReference(DATE_TIME_PROVIDER, configuration.getDateTimeProviderRef());
132-
} else {
133-
builder.addPropertyValue(DATE_TIME_PROVIDER, CurrentDateTimeProvider.INSTANCE);
132+
}
133+
else {
134+
builder.addAutowiredProperty(DATE_TIME_PROVIDER);
134135
}
135136

136137
builder.setRole(AbstractBeanDefinition.ROLE_INFRASTRUCTURE);

src/main/java/org/springframework/data/convert/ConfigurableTypeInformationMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222
import org.jspecify.annotations.Nullable;
2323

24+
import org.springframework.data.core.TypeInformation;
2425
import org.springframework.data.mapping.Alias;
2526
import org.springframework.data.mapping.PersistentEntity;
2627
import org.springframework.data.mapping.context.MappingContext;
27-
import org.springframework.data.util.TypeInformation;
2828
import org.springframework.util.Assert;
2929

3030
/**

src/main/java/org/springframework/data/convert/CustomConversions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
import org.springframework.core.convert.converter.GenericConverter.ConvertiblePair;
3535
import org.springframework.core.convert.support.GenericConversionService;
3636
import org.springframework.data.convert.ConverterBuilder.ConverterAware;
37+
import org.springframework.data.core.CustomCollections;
3738
import org.springframework.data.mapping.PersistentProperty;
3839
import org.springframework.data.mapping.model.SimpleTypeHolder;
39-
import org.springframework.data.util.CustomCollections;
4040
import org.springframework.data.util.Predicates;
4141
import org.springframework.data.util.Streamable;
4242
import org.springframework.util.Assert;

src/main/java/org/springframework/data/convert/DefaultTypeMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
import org.jspecify.annotations.Nullable;
2727

2828
import org.springframework.beans.factory.BeanClassLoaderAware;
29+
import org.springframework.data.core.TypeInformation;
2930
import org.springframework.data.mapping.Alias;
3031
import org.springframework.data.mapping.PersistentEntity;
3132
import org.springframework.data.mapping.context.MappingContext;
32-
import org.springframework.data.util.TypeInformation;
3333
import org.springframework.util.Assert;
3434

3535
/**

src/main/java/org/springframework/data/convert/MappingContextTypeInformationMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020

2121
import org.jspecify.annotations.Nullable;
2222

23+
import org.springframework.data.core.TypeInformation;
2324
import org.springframework.data.mapping.Alias;
2425
import org.springframework.data.mapping.PersistentEntity;
2526
import org.springframework.data.mapping.PersistentProperty;
2627
import org.springframework.data.mapping.context.MappingContext;
27-
import org.springframework.data.util.TypeInformation;
2828
import org.springframework.util.Assert;
2929

3030
/**

0 commit comments

Comments
 (0)