CompositeAttributeFlusher throws NPE on some operations #1759
Closed
Description
In some cases (i cannot simply reproduce it), we get this error in our production logs
2023/07/10 13:02:50 [e2e-firefox] ERROR [http-nio-8080-exec-10] o.a.c.c.C.[.[.[.[dispatcherServlet] ⬩ Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: java.lang.NullPointerException: Cannot invoke "com.blazebit.persistence.view.impl.update.flush.CompositeAttributeFlusher.flushEntity(com.blazebit.persistence.view.impl.update.UpdateContext, Object, Object, Object, Object, java.lang.Runnable)" because "this.fullFlusher" is null] with root cause
java.lang.NullPointerException: Cannot invoke "com.blazebit.persistence.view.impl.update.flush.CompositeAttributeFlusher.flushEntity(com.blazebit.persistence.view.impl.update.UpdateContext, Object, Object, Object, Object, java.lang.Runnable)" because "this.fullFlusher" is null
at com.blazebit.persistence.view.impl.update.EntityViewUpdaterImpl.executePersist(EntityViewUpdaterImpl.java:732) ~[blaze-persistence-entity-view-impl-jakarta-1.6.9.jar!/:1.6.9]
at com.blazebit.persistence.view.impl.update.EntityViewUpdaterImpl.executePersist(EntityViewUpdaterImpl.java:727) ~[blaze-persistence-entity-view-impl-jakarta-1.6.9.jar!/:1.6.9]
at com.blazebit.persistence.view.impl.EntityViewManagerImpl.update(EntityViewManagerImpl.java:1191) ~[blaze-persistence-entity-view-impl-jakarta-1.6.9.jar!/:1.6.9]
at com.blazebit.persistence.view.impl.EntityViewManagerImpl.update(EntityViewManagerImpl.java:1153) ~[blaze-persistence-entity-view-impl-jakarta-1.6.9.jar!/:1.6.9]
at com.blazebit.persistence.view.impl.EntityViewManagerImpl.save(EntityViewManagerImpl.java:1070) ~[blaze-persistence-entity-view-impl-jakarta-1.6.9.jar!/:1.6.9]
at de.kontextwork.dw.platform.commons.jpa.sql.blazepersistence.RegularEntityViewRepository.create(RegularEntityViewRepository.java:227) ~[platform-commons-20230710.7.jar!/:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
This is the create view that is used in this case
@EntityView(SpaceContentStructureNode.class)
@CreatableEntityView
public interface SpaceContentStructureNodeCreateView extends SpaceContentStructureNodeIdView
{
Integer getPosition();
void setPosition(Integer position);
SpaceContentStructureNodeIdView getParent();
void setParent(SpaceContentStructureNodeIdView parent);
SpaceIdView getSpace();
void setSpace(SpaceIdView spaceIdView);
PageIdView getPage();
void setPage(PageIdView pageIdView);
}
and this is the entity
@Entity
@Data
@Table(name = "dw_space_content_structure")
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class SpaceContentStructureNode implements Serializable
{
@Id
@Include
@Column(name = "id", columnDefinition = "INT(10)")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
private SpaceContentStructureNode parent;
@OrderColumn(name = "position")
@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
private Set<SpaceContentStructureNode> children;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "node_id", referencedColumnName = "nid", columnDefinition = "INT(10) UNSIGNED")
private Page page;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "space_id", referencedColumnName = "id", columnDefinition = "INT(10) UNSIGNED")
private Space space;
/**
* Custom sort field normalized between 1 (first) and unlimited (last).
* Normalized means, we are ensuring, that if we insert a TreeNode as a child,
* all the position values of the children are a unique sequence starting from 1
*
* see SpaceContentStructureRepository#insertRelativeToNeighbor
*/
@Column(columnDefinition = "INT(10)")
private Integer position;
}
Yet not sure what to provide and how to further narrow it down, maybe this needs a discussion.
i## Env
- BP 1.6.9
- HIbernate 6.2.6
- Java 17
- Spring boot 3.1.1.