Skip to content

Changes in VaadinSession in Flow 25 break deserialization of UnserializableComponentWrapper #218

@mcollovati

Description

@mcollovati

In Flow 25, VaadinSession has been refactored to remove the internal reference to the DeploymentConfiguration; now, the getConfiguration() method delegates the call to VaadinService.

UnserializableComponentWrapper hits a code path that needs to check for the value of the production mode setting in the configuration when it re-attaches the wrapped component to the UI after deserialization.

However, when a new HTTP session is created and populated with data from the distributed storage, the VaadinService instance is not yet restored into the VaadinSession, causing a null pointer exception.

The following stack trace is from unit tests, but the same will happen at runtime

Caused by: java.lang.NullPointerException: Cannot invoke "com.vaadin.flow.server.VaadinService.getDeploymentConfiguration()" because "this.service" is null
  at com.vaadin.flow.server.VaadinSession.getConfiguration(VaadinSession.java:362)
  at com.vaadin.flow.component.ComponentUtil.setJavaClassNameInDevelopment(ComponentUtil.java:315)
  at com.vaadin.flow.component.ComponentUtil.onComponentAttach(ComponentUtil.java:306)
  at com.vaadin.flow.internal.nodefeature.ComponentMapping.lambda$onAttach$0(ComponentMapping.java:104)
  at java.base/java.util.Optional.ifPresent(Optional.java:178)
  at com.vaadin.flow.internal.nodefeature.ComponentMapping.onAttach(ComponentMapping.java:103)
  at com.vaadin.flow.internal.StateNode.lambda$fireAttachListeners$9(StateNode.java:933)
  at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
  at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
  at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
  at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
  at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
  at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
  at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
  at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
  at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
  at com.vaadin.flow.internal.StateNode.forEachFeature(StateNode.java:376)
  at com.vaadin.flow.internal.StateNode.fireAttachListeners(StateNode.java:933)
  at com.vaadin.flow.internal.StateNode.onAttach(StateNode.java:334)
  at com.vaadin.flow.internal.StateNode.setParent(StateNode.java:286)
  at com.vaadin.flow.internal.nodefeature.NodeFeature.attachPotentialChild(NodeFeature.java:79)
  at com.vaadin.flow.internal.nodefeature.StateNodeNodeList.add(StateNodeNodeList.java:55)
  at com.vaadin.flow.internal.nodefeature.ElementChildrenList.add(ElementChildrenList.java:43)
  at com.vaadin.flow.dom.impl.AbstractNodeStateProvider.insertChild(AbstractNodeStateProvider.java:107)
  at com.vaadin.flow.dom.Node.insertChild(Node.java:391)
  at com.vaadin.flow.dom.Node.appendChild(Node.java:163)
  at com.vaadin.flow.dom.Node.appendChild(Node.java:147)
  at com.vaadin.kubernetes.starter.sessiontracker.UnserializableComponentWrapper.lambda$restoreComponent$0(UnserializableComponentWrapper.java:144)
  at java.base/java.util.Optional.ifPresent(Optional.java:178)
  at com.vaadin.kubernetes.starter.sessiontracker.UnserializableComponentWrapper.restoreComponent(UnserializableComponentWrapper.java:132)
  at java.base/java.io.ObjectInputStream$ValidationList$1.run(ObjectInputStream.java:2801)
  at java.base/java.io.ObjectInputStream$ValidationList$1.run(ObjectInputStream.java:2799)
  at java.base/java.security.AccessController.doPrivileged(AccessController.java:714)
  at java.base/java.io.ObjectInputStream$ValidationList.doCallbacks(ObjectInputStream.java:2797)
  at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:547)
  at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:498)
  at com.vaadin.kubernetes.starter.sessiontracker.serialization.TransientInjectableObjectInputStream.readWithTransients(TransientInjectableObjectInputStream.java:162)
  at com.vaadin.kubernetes.starter.sessiontracker.SessionSerializer.doDeserialize(SessionSerializer.java:604)
  at com.vaadin.kubernetes.starter.sessiontracker.SessionSerializer.deserialize(SessionSerializer.java:258)
  at com.vaadin.kubernetes.starter.sessiontracker.SessionSerializerTest.serialize_and_deserialize_unserializableComponent_usingUnserializableComponentWrapper(SessionSerializerTest.java:296

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    🔎Iteration reviews

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions