DATAJPA-280 - Added null guards to AuditingHandler access.
In case the AuditingEntityListener is declared globally and <jpa:auditing /> is not activated the listener is considered by the JPA infrastructure but not configured correctly. In particular no AuditingHandler gets injected which leads to NullPointerExceptions every time an entity is persisted. Added checks for null to the access and skip it if no AuditingHandler is present.
This commit is contained in:
committed by
Oliver Gierke
parent
28a565faec
commit
6b95150762
@@ -64,7 +64,9 @@ public class AuditingEntityListener<T> {
|
||||
*/
|
||||
@PrePersist
|
||||
public void touchForCreate(Object target) {
|
||||
handler.markCreated(target);
|
||||
if (handler != null) {
|
||||
handler.markCreated(target);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,6 +77,8 @@ public class AuditingEntityListener<T> {
|
||||
*/
|
||||
@PreUpdate
|
||||
public void touchForUpdate(Object target) {
|
||||
handler.markModified(target);
|
||||
if (handler != null) {
|
||||
handler.markModified(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user