Skip to content

Commit 59d6587

Browse files
christophstroblodrotbohm
authored andcommitted
DATAJPA-1064 - Add null guard for Optional (we actually should not need it).
However EntityManagerFactoryRefTests fail on cmd line when removing it though everything works fine when running tests from ide - strange things happen.
1 parent 6ab6050 commit 59d6587

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/org/springframework/data/jpa/domain/AbstractAuditable.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public Optional<U> getCreatedBy() {
7272
*/
7373
public void setCreatedBy(final Optional<? extends U> createdBy) {
7474

75-
this.createdBy = createdBy.orElse(null);
75+
// TODO: this null guard should really not be required since we expect an optional here
76+
this.createdBy = createdBy != null ? createdBy.orElse(null) : null;
7677
}
7778

7879
/*
@@ -117,7 +118,8 @@ public Optional<U> getLastModifiedBy() {
117118
*/
118119
public void setLastModifiedBy(final Optional<? extends U> lastModifiedBy) {
119120

120-
this.lastModifiedBy = lastModifiedBy.orElse(null);
121+
// TODO: this null guard should really not be required since we expect an optional here
122+
this.lastModifiedBy = lastModifiedBy != null ? lastModifiedBy.orElse(null) : null;
121123
}
122124

123125
/*

0 commit comments

Comments
 (0)