vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
603 stars 165 forks source link

ShortcutRegistration throws NPE #19769

Open simasch opened 1 month ago

simasch commented 1 month ago

Description of the bug

I see the exception below in the logs. I can't reproduce it but I think this should be caught by the framework because there is no code of mine involved.

java.lang.NullPointerException: Cannot invoke "com.vaadin.flow.component.Component.isVisible()" because "component" is null
    at com.vaadin.flow.component.ShortcutRegistration.ancestorsOrSelfAreVisible(ShortcutRegistration.java:648) ~[flow-server-24.4.4.jar:24.4.4]
    at com.vaadin.flow.component.ShortcutRegistration.fireShortcutEvent(ShortcutRegistration.java:641) ~[flow-server-24.4.4.jar:24.4.4]
    at com.vaadin.flow.component.ShortcutRegistration.lambda$updateHandlerListenerRegistration$89e5c563$1(ShortcutRegistration.java:601) ~[flow-server-24.4.4.jar:24.4.4]
    at com.vaadin.flow.component.ComponentEventBus.fireEventForListener(ComponentEventBus.java:239) ~[flow-server-24.4.4.jar:24.4.4]
    at com.vaadin.flow.component.ComponentEventBus.handleDomEvent(ComponentEventBus.java:488) ~[flow-server-24.4.4.jar:24.4.4]
    at com.vaadin.flow.component.ComponentEventBus.lambda$addDomTrigger$dd1b7957$1(ComponentEventBus.java:298) ~[flow-server-24.4.4.jar:24.4.4]
    at com.vaadin.flow.internal.nodefeature.ElementListenerMap.lambda$fireEvent$2(ElementListenerMap.java:473) ~[flow-server-24.4.4.jar:24.4.4]
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596) ~[na:na]
    at com.vaadin.flow.internal.nodefeature.ElementListenerMap.fireEvent(ElementListenerMap.java:473) ~[flow-server-24.4.4.jar:24.4.4]
    at com.vaadin.flow.server.communication.rpc.EventRpcHandler.handleNode(EventRpcHandler.java:62) ~[flow-server-24.4.4.jar:24.4.4]
    at com.vaadin.flow.server.communication.rpc.AbstractRpcInvocationHandler.handle(AbstractRpcInvocationHandler.java:73) ~[flow-server-24.4.4.jar:24.4.4]
    at com.vaadin.flow.server.communication.ServerRpcHandler.handleInvocationData(ServerRpcHandler.java:475) ~[flow-server-24.4.4.jar:24.4.4]
    at com.vaadin.flow.server.communication.ServerRpcHandler.lambda$handleInvocations$5(ServerRpcHandler.java:456) ~[flow-server-24.4.4.jar:24.4.4]
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596) ~[na:na]
    at com.vaadin.flow.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:456) ~[flow-server-24.4.4.jar:24.4.4]
    at com.vaadin.flow.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:324) ~[flow-server-24.4.4.jar:24.4.4]
    at com.vaadin.flow.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:114) ~[flow-server-24.4.4.jar:24.4.4]
    at com.vaadin.flow.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40) ~[flow-server-24.4.4.jar:24.4.4]

Expected behavior

No NPE should be thrown.

Minimal reproducible example

Unfortunately I cannot reproduce it.

Versions

Legioth commented 1 month ago

Speculation on how to reproduce: this might be a timing issue with a component becoming invisible concurrently with a user triggering a keyboard event related to the same component.

simasch commented 1 month ago

But how can the lifecycle owner become null?

image