Skip to content

Commit

Permalink
Merge pull request #4176 from Coduz/fix-npeOnPreUpdateIfNoSession
Browse files Browse the repository at this point in the history
🐛 [Core] Fixed handling of null KapuaSession on prePersist and preUpdate operation in KapuaEntity
  • Loading branch information
Coduz authored Jan 20, 2025
2 parents 88f427b + 425f96b commit 82b5b18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ public void setCreatedBy(KapuaId createdBy) {
@PrePersist
protected void prePersistsAction() {
setId(new KapuaEid(IdGenerator.generate()));
setCreatedBy(KapuaSecurityUtils.getSession().getUserId());
if (KapuaSecurityUtils.getSession() != null) {
setCreatedBy(KapuaSecurityUtils.getSession().getUserId());
}
setCreatedOn(new Date());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ protected void prePersistsAction() {
*/
@PreUpdate
protected void preUpdateAction() {
setModifiedBy(KapuaSecurityUtils.getSession().getUserId());
if (KapuaSecurityUtils.getSession() != null) {
setModifiedBy(KapuaSecurityUtils.getSession().getUserId());
}
setModifiedOn(new Date());
}
}

0 comments on commit 82b5b18

Please sign in to comment.