diff --git a/src/main/java/org/springframework/data/auditing/MappingAuditableBeanWrapperFactory.java b/src/main/java/org/springframework/data/auditing/MappingAuditableBeanWrapperFactory.java index a89df7ec2..461f9781f 100644 --- a/src/main/java/org/springframework/data/auditing/MappingAuditableBeanWrapperFactory.java +++ b/src/main/java/org/springframework/data/auditing/MappingAuditableBeanWrapperFactory.java @@ -45,6 +45,7 @@ import org.springframework.util.ConcurrentReferenceHashMap; * * @author Oliver Gierke * @author Christoph Strobl + * @author Mark Paluch * @since 1.8 */ public class MappingAuditableBeanWrapperFactory extends DefaultAuditableBeanWrapperFactory { @@ -262,8 +263,20 @@ public class MappingAuditableBeanWrapperFactory extends DefaultAuditableBeanWrap private
> TemporalAccessor setDateProperty( PersistentPropertyPaths, ? extends PersistentProperty>> property, TemporalAccessor value) { - property.forEach(it -> this.accessor.setProperty(it, - getDateValueToSet(value, it.getRequiredLeafProperty().getType(), accessor.getBean()))); + property.forEach(it -> { + + try { + + this.accessor.setProperty(it, + getDateValueToSet(value, it.getRequiredLeafProperty().getType(), accessor.getBean())); + } catch (MappingException o_O) { + + // Ignore null intermediate errors temporarily + if (!o_O.getMessage().contains("on null intermediate")) { + throw o_O; + } + } + }); return value; } diff --git a/src/test/java/org/springframework/data/auditing/MappingAuditableBeanWrapperFactoryUnitTests.java b/src/test/java/org/springframework/data/auditing/MappingAuditableBeanWrapperFactoryUnitTests.java index b02e92ec8..a99a796e7 100755 --- a/src/test/java/org/springframework/data/auditing/MappingAuditableBeanWrapperFactoryUnitTests.java +++ b/src/test/java/org/springframework/data/auditing/MappingAuditableBeanWrapperFactoryUnitTests.java @@ -216,13 +216,14 @@ public class MappingAuditableBeanWrapperFactoryUnitTests { }); } - @Test // DATACMNS-1461 + @Test // DATACMNS-1461, DATACMNS-1671 public void skipsNullIntermediatesWhenSettingProperties() { WithEmbedded withEmbedded = new WithEmbedded(); assertThat(factory.getBeanWrapperFor(withEmbedded)).hasValueSatisfying(it -> { assertThatCode(() -> it.setCreatedBy("user")).doesNotThrowAnyException(); + assertThatCode(() -> it.setLastModifiedDate(Instant.now())).doesNotThrowAnyException(); }); }