Docs

Documentation versions (currently viewingVaadin 25)
Documentation translations (currently viewing)

Cette page a été traduite automatiquement à partir de la documentation officielle, qui se trouve sur https://vaadin.com/docs. Elle peut contenir des erreurs, des inexactitudes, ou des formulations incorrectes. Vaadin ne garantit pas et ne fait aucune déclaration concernant l’exactitude, la fiabilité, ou l’actualité de la traduction.

Outil de débogage de la réplication de session Kubernetes Kit

Pour aider à rendre les sessions HTTP entièrement sérialisables et désérialisables, Kubernetes Kit propose un outil permettant de découvrir les problèmes de sérialisation pendant le développement.

L’outil de débogage de la réplication de session Kubernetes Kit est composé de trois composants fonctionnant ensemble : HTTP Session Replication Tester ; Vaadin RequestHandler ; et HTTP Filter.

Le tester tente de sérialiser et de désérialiser la session HTTP. Le RequestHandler évalue si la requête HTTP produit des changements d’UI et prépare l’exécution du tester ainsi que la notification du résultat dans la notification de l’UI, si le server push est activé. Le filtre HTTP exécute le tester après que la requête HTTP a été traitée.

Activation de l’outil de débogage

L’outil de débogage est installé automatiquement sur les projets Spring Boot par l’autoconfiguration de Kubernetes Kit. Aucun enregistrement manuel n’est requis. Cependant, l’outil de débogage ne fonctionnera pas dans les builds de production, et pendant le développement il ne fonctionne que si quelques conditions sont remplies.

D’abord, la propriété de configuration d’application vaadin.devmode.sessionSerialization.enabled doit être définie sur true. Vous pouvez la définir soit dans un fichier properties, soit dans un fichier YAML comme suit :

Source code
application.properties
vaadin.devmode.sessionSerialization.enabled=true
application.yaml

Ensuite, la propriété système sun.io.serialization.extendedDebugInfo doit être définie sur true et la JVM doit avoir été démarrée avec le flag --add-opens java.base/java.io=ALL-UNNAMED. La manière dont vous fournissez ces éléments dépend du fait que vous exécutez votre application avec le Spring Boot Maven Plugin ou en exécutant directement le JAR de l’application.

Vous pouvez définir la configuration dans le fichier pom.xml, ou la définir comme variables d’environnement lorsque vous exécutez l’application depuis la ligne de commande.

Source code
pom.xml
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <jvmArguments>
        --add-opens java.base/java.io=ALL-UNNAMED
        -Dsun.io.serialization.extendedDebugInfo=true
        </jvmArguments>
    </configuration>
</plugin>
pom.xml
Terminal
Terminal
Terminal
Terminal
Caution
Effets secondaires potentiels de la sérialisation lors de l’utilisation des informations de debug étendues.
La propriété système sun.io.serialization.extendedDebugInfo peut être utile pour rendre les messages d’exception plus détaillés pendant la sérialisation. La méthode toString() est utilisée pour représenter les objets sérialisés, et dans de rares cas cela peut provoquer des problèmes qui ne sont pas liés à la sérialisation. Par exemple, avec Hibernate, PersistentList.toString() force l’initialisation de la collection chargée en lazy. Si cela se produit sans session Hibernate active, une exception est levée.

Projets non Spring Boot

Pour les autres types de projets, l’outil de débogage doit être installé manuellement. Configurez le Service Init Listener fourni, soit en ajoutant une entrée dans META-INF/services/VaadinServiceInitListener, soit en définissant un bean si vous utilisez l’add-on Vaadin Spring.

De plus, le filtre HTTP doit être enregistré soit en tant que bean Spring, soit avec un ServletContextListener.

Code d’enregistrement manuel
Source code
AppConfig.java
@Configuration
class AppConfig {

    @Bean
    VaadinServiceInitListener serializationDebugInitListener() {
        return new SerializationDebugRequestHandler.InitListener();
    }

    @Bean
    @Order(Integer.MIN_VALUE)
    FilterRegistrationBean<SerializationDebugRequestHandler.Filter> sessionSerializationDebugToolFilter() {
        FilterRegistrationBean<SerializationDebugRequestHandler.Filter> registration =
            new FilterRegistrationBean<>(new SerializationDebugRequestHandler.Filter());
        registration.setAsyncSupported(true);
        return registration;
    }
}
AppConfig.java
src/main/resources/META-INF/services/VaadinServiceInitListener
src/main/resources/META-INF/services/VaadinServiceInitListener
Enregistrement du filtre
Enregistrement du filtre

Délai d’expiration de la sérialisation de session

Lorsque le HTTP Session Replication Tester tente de sérialiser et de désérialiser une session HTTP, le processus peut prendre plus de temps pour des sessions plus volumineuses. Le Debug Tool utilise un délai d’expiration pour attendre la fin de ce processus. Cependant, si le processus de sérialisation prend plus longtemps que la période de délai d’expiration, il interrompt l’attente et continue avec les étapes suivantes. Le délai d’expiration de sérialisation est consigné dans les logs, et apparaît aussi dans les résultats pour notifier l’utilisateur. Pour accorder plus de temps, configurez la propriété timeout de sérialisation, qui est définie en millisecondes.

Dans les applications SpringBoot, elle est disponible dans les propriétés de configuration SerializationProperties. Le délai d’expiration peut être défini via les propriétés d’application comme suit :

Source code
application.properties
vaadin.serialization.timeout=60000
application.yaml

Dans les applications non SpringBoot, une propriété système est disponible pour définir le délai d’expiration :

Source code
vaadin.serialization.timeout=60000

Si elle n’est pas configurée, la valeur par défaut du délai d’expiration est de 30 secondes.

Résultats du test de sérialisation

Les résultats du test sont enregistrés dans les logs du serveur. Ils incluent les résultats du processus de test (par ex. SERIALIZATION_FAILED, DESERIALIZATION_FAILED, SUCCESS, etc.). Ils incluent aussi une liste de classes non sérialisables, le graphe de classes d’objets en cas d’erreurs de désérialisation, et des causes potentielles de SerializedLambda ClassCastException.

À titre d’exemple, supposons que vous ayez une application qui n’est pas codée dès le départ pour prendre en charge la réplication de session. Avec l’outil de débogage de la réplication de session Kubernetes Kit en action, des problèmes comme les suivants peuvent être repérés en mode développement en consultant les logs du serveur.

Pour les vues référençant directement ou indirectement des objets non sérialisables, les classes causant des problèmes sont signalées. Vérifiez attentivement ces classes et rendez-les Serializable. Ensuite, naviguez de nouveau vers la vue pour voir si les problèmes sont résolus ou si d’autres problèmes sont apparus.

Source code
Session serialization attempt completed in 382 ms with outcomes: [SERIALIZATION_FAILED, NOT_SERIALIZABLE_CLASSES]

NOT SERIALIZABLE CLASSES FOUND:
===============================

com.vaadin.starter.bakery.ui.views.storefront.OrderPresenter
	Start Track ID: 266, Stack depth: 33. Reference stack;
		- element of array (index: 0)
		- array (class "[Ljava.lang.Object;", size: 1)
		- field (class "java.lang.invoke.SerializedLambda", name: "capturedArgs", type: "class [Ljava.lang.Object;")
		- object (class "java.lang.invoke.SerializedLambda", SerializedLambda[capturingClass=class com.vaadin.starter.bakery.ui.views.storefront.StorefrontView, functionalInterfaceMethod=com/vaadin/flow/function/ValueProvider.apply:(Ljava/lang/Object;)Ljava/lang/Object;, implementation=invokeStatic com/vaadin/starter/bakery/ui/views/storefront/StorefrontView.lambda$new$497a7bcf$1:(Lcom/vaadin/starter/bakery/ui/views/storefront/OrderPresenter;Lcom/vaadin/starter/bakery/backend/data/entity/Order;)Ljava/lang/Object;, instantiatedMethodType=(Lcom/vaadin/starter/bakery/backend/data/entity/Order;)Ljava/lang/Object;, numCaptured=1])
		[.... omitted .... ]
	End Track ID: 216

com.vaadin.starter.bakery.ui.utils.converters.LocalTimeConverter
	Start Track ID: 4383, Stack depth: 70. Reference stack:
		- element of array (index: 0)
		- array (class "[Ljava.lang.Object;", size: 1)
		- field (class "java.lang.invoke.SerializedLambda", name: "capturedArgs", type: "class [Ljava.lang.Object;")
		- object (class "java.lang.invoke.SerializedLambda", SerializedLambda[capturingClass=class com.vaadin.starter.bakery.ui.views.orderedit.OrderEditor, functionalInterfaceMethod=com/vaadin/flow/component/ItemLabelGenerator.apply:(Ljava/lang/Object;)Ljava/lang/String;, implementation=invokeVirtual com/vaadin/starter/bakery/ui/utils/converters/LocalTimeConverter.encode:(Ljava/time/LocalTime;)Ljava/lang/String;, instantiatedMethodType=(Ljava/time/LocalTime;)Ljava/lang/String;, numCaptured=1])
		- field (class "com.vaadin.flow.component.combobox.ComboBoxBase", name: "itemLabelGenerator", type: "interface com.vaadin.flow.component.ItemLabelGenerator")
		- object (class "com.vaadin.flow.component.combobox.ComboBox", com.vaadin.flow.component.combobox.ComboBox@6a256d7f)
		[.... omitted .... ]
	End Track ID: 3268

com.vaadin.starter.bakery.backend.service.PickupLocationService
	Start Track ID: 3348, Stack depth: 78. Reference stack:
		- field (class "com.vaadin.starter.bakery.ui.crud.CrudEntityDataProvider", name: "crudService", type: "interface com.vaadin.starter.bakery.backend.service.FilterableCrudService")
		- object (class "com.vaadin.starter.bakery.ui.crud.CrudEntityDataProvider", com.vaadin.starter.bakery.ui.crud.CrudEntityDataProvider@42830bd9)
		- field (class "com.vaadin.flow.data.provider.DataCommunicator", name: "dataProvider", type: "interface com.vaadin.flow.data.provider.DataProvider")
		- object (class "com.vaadin.flow.component.combobox.ComboBoxDataCommunicator", com.vaadin.flow.component.combobox.ComboBoxDataCommunicator@1ae5194d)
		- field (class "com.vaadin.flow.component.combobox.ComboBoxDataController", name: "dataCommunicator", type: "class com.vaadin.flow.component.combobox.ComboBoxDataCommunicator")
		- object (class "com.vaadin.flow.component.combobox.ComboBoxDataController", com.vaadin.flow.component.combobox.ComboBoxDataController@351fed32)
		[.... omitted .... ]
	End Track ID: 3348

com.vaadin.starter.bakery.ui.views.orderedit.OrderEditor$$Lambda$2071/0x0000000800c7a840
	[ SAM interface: java.util.function.Function.compose(java.util.function.Function) ]
	Start Track ID: 3525, Stack depth: 69. Reference stack:
		- element of array (index: 0)
		- array (class "[Ljava.lang.Object;", size: 1)
		- field (class "java.lang.invoke.SerializedLambda", name: "capturedArgs", type: "class [Ljava.lang.Object;")
		- object (class "java.lang.invoke.SerializedLambda", SerializedLambda[capturingClass=class com.vaadin.starter.bakery.ui.dataproviders.DataProviderUtil, functionalInterfaceMethod=com/vaadin/flow/component/ItemLabelGenerator.apply:(Ljava/lang/Object;)Ljava/lang/String;, implementation=invokeStatic com/vaadin/starter/bakery/ui/dataproviders/DataProviderUtil.lambda$createItemLabelGenerator$bbbabe6b$1:(Ljava/util/function/Function;Ljava/lang/Object;)Ljava/lang/String;, instantiatedMethodType=(Ljava/lang/Object;)Ljava/lang/String;, numCaptured=1])
		[.... omitted .... ]
	End Track ID: 3525

com.vaadin.starter.bakery.backend.service.ProductService
	Start Track ID: 3947, Stack depth: 68. Reference stack:
		- field (class "com.vaadin.starter.bakery.ui.crud.CrudEntityDataProvider", name: "crudService", type: "interface com.vaadin.starter.bakery.backend.service.FilterableCrudService")
		- object (class "com.vaadin.starter.bakery.ui.crud.CrudEntityDataProvider", com.vaadin.starter.bakery.ui.crud.CrudEntityDataProvider@7392f310)
		- field (class "com.vaadin.starter.bakery.ui.views.orderedit.OrderItemsEditor", name: "productDataProvider", type: "interface com.vaadin.flow.data.provider.DataProvider")
		- object (class "com.vaadin.starter.bakery.ui.views.orderedit.OrderItemsEditor", com.vaadin.starter.bakery.ui.views.orderedit.OrderItemsEditor@2a64d7d9)
		[.... omitted .... ]
	End Track ID: 3947

com.vaadin.starter.bakery.ui.views.orderedit.OrderEditor$$Lambda$2032/0x0000000800c74c40
	[ SAM interface: java.util.function.Function.compose(java.util.function.Function) ]
	Start Track ID: 4182, Stack depth: 49. Reference stack:
		- element of array (index: 0)
		- array (class "[Ljava.lang.Object;", size: 1)
		- field (class "java.lang.invoke.SerializedLambda", name: "capturedArgs", type: "class [Ljava.lang.Object;")
		- object (class "java.lang.invoke.SerializedLambda", SerializedLambda[capturingClass=class com.vaadin.starter.bakery.ui.dataproviders.DataProviderUtil, functionalInterfaceMethod=com/vaadin/flow/component/ItemLabelGenerator.apply:(Ljava/lang/Object;)Ljava/lang/String;, implementation=invokeStatic com/vaadin/starter/bakery/ui/dataproviders/DataProviderUtil.lambda$createItemLabelGenerator$bbbabe6b$1:(Ljava/util/function/Function;Ljava/lang/Object;)Ljava/lang/String;, instantiatedMethodType=(Ljava/lang/Object;)Ljava/lang/String;, numCaptured=1])
		- field (class "com.vaadin.flow.component.combobox.ComboBoxBase", name: "itemLabelGenerator", type: "interface com.vaadin.flow.component.ItemLabelGenerator")
		- object (class "com.vaadin.flow.component.combobox.ComboBox", com.vaadin.flow.component.combobox.ComboBox@7a86589e)
		[.... omitted .... ]
	End Track ID: 4182

com.vaadin.starter.bakery.backend.service.OrderService$$EnhancerBySpringCGLIB$$212d0636
	Start Track ID: 4757, Stack depth: 10. Reference stack:
		- field (class "com.vaadin.starter.bakery.ui.dataproviders.OrdersGridDataProvider", name: "orderService", type: "class com.vaadin.starter.bakery.backend.service.OrderService")
		- object (class "com.vaadin.starter.bakery.ui.dataproviders.OrdersGridDataProvider", com.vaadin.starter.bakery.ui.dataproviders.OrdersGridDataProvider@39940b23)
		[.... omitted .... ]
	End Track ID: 4757

com.vaadin.starter.bakery.ui.views.storefront.OrderPresenter$$Lambda$1943/0x0000000800c4d040
	[ SAM interface: java.util.function.Consumer.andThen(java.util.function.Consumer) ]
	Start Track ID: 4758, Stack depth: 10. Reference stack:
		- field (class "com.vaadin.starter.bakery.ui.dataproviders.OrdersGridDataProvider", name: "pageObserver", type: "interface java.util.function.Consumer")
		- object (class "com.vaadin.starter.bakery.ui.dataproviders.OrdersGridDataProvider", com.vaadin.starter.bakery.ui.dataproviders.OrdersGridDataProvider@39940b23)
		- custom writeObject data (class "java.util.HashMap")
		- object (class "java.util.HashMap", {ordersGridDataProvider=com.vaadin.starter.bakery.ui.dataproviders.OrdersGridDataProvider@39940b23})
		- field (class "com.vaadin.flow.spring.scopes.BeanStore", name: "objects", type: "interface java.util.Map")
		- object (class "com.vaadin.flow.spring.scopes.BeanStore", com.vaadin.flow.spring.scopes.BeanStore@55b88ad)
		- custom writeObject data (class "java.util.HashMap")
		- object (class "java.util.HashMap", {1=com.vaadin.flow.spring.scopes.BeanStore@55b88ad})
		- field (class "com.vaadin.flow.spring.scopes.VaadinUIScope$UIStoreWrapper", name: "uiStores", type: "interface java.util.Map")
		- object (class "com.vaadin.flow.spring.scopes.VaadinUIScope$UIStoreWrapper", com.vaadin.flow.spring.scopes.VaadinUIScope$UIStoreWrapper@53b93285)
		[.... omitted .... ]
	End Track ID: 4758

Pour résoudre les exceptions de cast de classe SerializedLambda pendant la désérialisation, analysez le graphe de classes du bas vers le haut et recherchez des classes connues. Vérifiez les sections BEST CANDIDATES pour identifier l’expression lambda en échec.

Source code
Session serialization attempt completed in 1375 ms with outcomes: [SERIALIZATION_FAILED, NOT_SERIALIZABLE_CLASSES, DESERIALIZATION_FAILED]

ERRORS DURING SERIALIZATION/DESERIALIZATION PROCESS:
====================================================
DESERIALIZATION_FAILED: cannot assign instance of java.lang.invoke.SerializedLambda to field com.vaadin.flow.component.ComponentEventBus$ListenerWrapper.listener of type com.vaadin.flow.component.ComponentEventListener in instance of com.vaadin.flow.component.ComponentEventBus$ListenerWrapper

SERIALIZED LAMBDA CLASS CAST EXCEPTION BEST CANDIDATES:
=======================================================
	SerializedLambda[capturingClass=class com.vaadin.starter.bakery.ui.views.dashboard.DashboardView, functionalInterfaceMethod=com/vaadin/flow/component/ComponentEventListener.onComponentEvent:(Lcom/vaadin/flow/component/ComponentEvent;)V, implementation=invokeSpecial com/vaadin/starter/bakery/ui/views/dashboard/DashboardView.lambda$measurePageLoadPerformance$387549c5$1:(Ljava/util/concurrent/atomic/AtomicInteger;Lcom/vaadin/flow/component/charts/events/ChartLoadEvent;)V, instantiatedMethodType=(Lcom/vaadin/flow/component/charts/events/ChartLoadEvent;)V, numCaptured=2]
	- field (class "com.vaadin.flow.component.ComponentEventBus$ListenerWrapper", name: "listener", type: "interface com.vaadin.flow.component.ComponentEventListener")
	- object (class "com.vaadin.flow.component.ComponentEventBus$ListenerWrapper", com.vaadin.flow.component.ComponentEventBus$ListenerWrapper@3cfd4b4e)
	- custom writeObject data (class "java.util.ArrayList")
	- object (class "java.util.ArrayList", [com.vaadin.flow.component.ComponentEventBus$ListenerWrapper@3cfd4b4e])
	- custom writeObject data (class "java.util.HashMap")
	- object (class "java.util.HashMap", {class com.vaadin.flow.component.charts.events.ChartLoadEvent=[com.vaadin.flow.component.ComponentEventBus$ListenerWrapper@3cfd4b4e]})
	- field (class "com.vaadin.flow.component.ComponentEventBus", name: "componentEventData", type: "class java.util.HashMap")
	- object (class "com.vaadin.flow.component.ComponentEventBus", com.vaadin.flow.component.ComponentEventBus@1f42a3e)
	- field (class "com.vaadin.flow.component.Component", name: "eventBus", type: "class com.vaadin.flow.component.ComponentEventBus")
	- object (class "com.vaadin.flow.component.charts.Chart", com.vaadin.flow.component.charts.Chart@1d873f81)
	- field (class "com.vaadin.flow.internal.nodefeature.ComponentMapping", name: "component", type: "class com.vaadin.flow.component.Component")
	- object (class "com.vaadin.flow.internal.nodefeature.ComponentMapping", com.vaadin.flow.internal.nodefeature.ComponentMapping@103098d)
	- element of array (index: 3)
	- array (class "[Lcom.vaadin.flow.internal.nodefeature.NodeFeature;", size: 8)
	- field (class "com.vaadin.flow.internal.StateNode", name: "features", type: "interface java.io.Serializable")
	- object (class "com.vaadin.flow.internal.StateNode", com.vaadin.flow.internal.StateNode@5753faff)
	- custom writeObject data (class "java.util.HashSet")
	- object (class "java.util.LinkedHashSet", [com.vaadin.flow.internal.StateNode@5753faff, com.vaadin.flow.internal.StateNode@715baa6, com.vaadin.flow.internal.StateNode@2002fea9, com.vaadin.flow.internal.StateNode@52b50419, com.vaadin.flow.internal.StateNode@253f0346, com.vaadin.flow.internal.StateNode@32fba91, com.vaadin.flow.internal.StateNode@598ff72d, com.vaadin.flow.internal.StateNode@105e75d3, com.vaadin.flow.internal.StateNode@52acc625, com.vaadin.flow.internal.StateNode@25be0e23, com.vaadin.flow.internal.StateNode@102dfa9, com.vaadin.flow.internal.StateNode@18580649, com.vaadin.flow.internal.StateNode@1e1751e3, com.vaadin.flow.internal.StateNode@4fa4edf8, com.vaadin.flow.internal.StateNode@4d41533b, com.vaadin.flow.internal.StateNode@2e470fb9, com.vaadin.flow.internal.StateNode@26527a8d, com.vaadin.flow.internal.StateNode@13fd3186, com.vaadin.flow.internal.StateNode@acffdd6, com.vaadin.flow.internal.StateNode@3a5f4c8b, com.vaadin.flow.internal.StateNode@e1d32e9])
	- field (class "com.vaadin.flow.internal.StateTree", name: "dirtyNodes", type: "interface java.util.Set")
	- object (class "com.vaadin.flow.internal.StateTree", com.vaadin.flow.internal.StateTree@5199da78)
	- field (class "com.vaadin.flow.internal.StateNode", name: "owner", type: "interface com.vaadin.flow.internal.NodeOwner")
	- object (class "com.vaadin.flow.internal.StateNode", com.vaadin.flow.internal.StateNode@5a9ad499)
	- custom writeObject data (class "java.util.ArrayList")
	- object (class "java.util.ArrayList", [com.vaadin.flow.internal.StateNode@5a9ad499])
	- field (class "com.vaadin.flow.internal.nodefeature.NodeList", name: "values", type: "interface java.util.List")
	- object (class "com.vaadin.flow.internal.nodefeature.ElementChildrenList", com.vaadin.flow.internal.nodefeature.ElementChildrenList@1794b4cc)
	- element of array (index: 1)
	- array (class "[Lcom.vaadin.flow.internal.nodefeature.NodeFeature;", size: 13)
	- field (class "com.vaadin.flow.internal.StateNode", name: "features", type: "interface java.io.Serializable")
	- object (class "com.vaadin.flow.internal.StateNode", com.vaadin.flow.internal.StateNode@3989de96)
	- field (class "com.vaadin.flow.dom.Node", name: "node", type: "class com.vaadin.flow.internal.StateNode")
	- object (class "com.vaadin.flow.dom.Element", <vaadin-grid suppress-template-warning multi-sort-priority="prepend" theme="orders dashboard" id="ordersGrid">
 <vaadin-grid-column suppress-template-warning></vaadin-grid-column>
</vaadin-grid>)
	- field (class "com.vaadin.flow.component.grid.GridArrayUpdater$UpdateQueueData", name: "element", type: "class com.vaadin.flow.dom.Element")
	- object (class "com.vaadin.flow.component.grid.GridArrayUpdater$UpdateQueueData", com.vaadin.flow.component.grid.GridArrayUpdater$UpdateQueueData@36801ef0)
	- field (class "com.vaadin.flow.component.grid.Grid$GridArrayUpdaterImpl", name: "data", type: "class com.vaadin.flow.component.grid.GridArrayUpdater$UpdateQueueData")
	- object (class "com.vaadin.flow.component.grid.Grid$GridArrayUpdaterImpl", com.vaadin.flow.component.grid.Grid$GridArrayUpdaterImpl@349c650f)
	- field (class "com.vaadin.flow.data.provider.DataCommunicator", name: "arrayUpdater", type: "interface com.vaadin.flow.data.provider.ArrayUpdater")
	- object (class "com.vaadin.flow.data.provider.DataCommunicator", com.vaadin.flow.data.provider.DataCommunicator@563c6dd6)
	- element of array (index: 0)
	- array (class "[Ljava.lang.Object;", size: 1)
	- field (class "java.lang.invoke.SerializedLambda", name: "capturedArgs", type: "class [Ljava.lang.Object;")
	- object (class "java.lang.invoke.SerializedLambda", SerializedLambda[capturingClass=class com.vaadin.flow.data.provider.DataCommunicator, functionalInterfaceMethod=com/vaadin/flow/data/provider/DataProviderListener.onDataChange:(Lcom/vaadin/flow/data/provider/DataChangeEvent;)V, implementation=invokeSpecial com/vaadin/flow/data/provider/DataCommunicator.lambda$handleAttach$425c8a01$1:(Lcom/vaadin/flow/data/provider/DataChangeEvent;)V, instantiatedMethodType=(Lcom/vaadin/flow/data/provider/DataChangeEvent;)V, numCaptured=1])
	- field (class "com.vaadin.flow.data.provider.AbstractDataProvider$1", name: "val$listener", type: "interface com.vaadin.flow.data.provider.DataProviderListener")
	- object (class "com.vaadin.flow.data.provider.AbstractDataProvider$1", com.vaadin.flow.data.provider.AbstractDataProvider$1@36139299)
	- field (class "com.vaadin.flow.data.provider.AbstractDataProvider$DataListenerWrapper", name: "listener", type: "interface com.vaadin.flow.function.SerializableConsumer")
	- object (class "com.vaadin.flow.data.provider.AbstractDataProvider$DataListenerWrapper", com.vaadin.flow.data.provider.AbstractDataProvider$DataListenerWrapper@772e98a2)
	- custom writeObject data (class "java.util.ArrayList")
	- object (class "java.util.ArrayList", [com.vaadin.flow.data.provider.AbstractDataProvider$DataListenerWrapper@772e98a2, com.vaadin.flow.data.provider.AbstractDataProvider$DataListenerWrapper@7311029f])
	- custom writeObject data (class "java.util.HashMap")
	- object (class "java.util.HashMap", {class com.vaadin.flow.data.provider.DataChangeEvent=[com.vaadin.flow.data.provider.AbstractDataProvider$DataListenerWrapper@772e98a2, com.vaadin.flow.data.provider.AbstractDataProvider$DataListenerWrapper@7311029f]})
	- field (class "com.vaadin.flow.data.provider.AbstractDataProvider", name: "listeners", type: "class java.util.HashMap")
	- object (class "com.vaadin.starter.bakery.ui.dataproviders.OrdersGridDataProvider", com.vaadin.starter.bakery.ui.dataproviders.OrdersGridDataProvider@39940b23)
	- custom writeObject data (class "java.util.HashMap")
	- object (class "java.util.HashMap", {ordersGridDataProvider=com.vaadin.starter.bakery.ui.dataproviders.OrdersGridDataProvider@39940b23})
	- field (class "com.vaadin.flow.spring.scopes.BeanStore", name: "objects", type: "interface java.util.Map")
	- object (class "com.vaadin.flow.spring.scopes.BeanStore", com.vaadin.flow.spring.scopes.BeanStore@55b88ad)
	- custom writeObject data (class "java.util.HashMap")
	- object (class "java.util.HashMap", {1=com.vaadin.flow.spring.scopes.BeanStore@55b88ad})
	- field (class "com.vaadin.flow.spring.scopes.VaadinUIScope$UIStoreWrapper", name: "uiStores", type: "interface java.util.Map")
	- object (class "com.vaadin.flow.spring.scopes.VaadinUIScope$UIStoreWrapper", com.vaadin.flow.spring.scopes.VaadinUIScope$UIStoreWrapper@53b93285)
	- custom writeObject data (class "java.util.HashMap")
	- object (class "java.util.HashMap", {com.vaadin.flow.spring.scopes.VaadinUIScope$UIStoreWrapper=com.vaadin.flow.spring.scopes.VaadinUIScope$UIStoreWrapper@53b93285, com.vaadin.flow.server.SessionRouteRegistry=com.vaadin.flow.server.SessionRouteRegistry@4f248e99, clientRoutingMode=false})
	- field (class "com.vaadin.flow.server.Attributes", name: "attributes", type: "class java.util.HashMap")
	- object (class "com.vaadin.flow.server.Attributes", com.vaadin.flow.server.Attributes@46ee4d44)
	- field (class "com.vaadin.flow.server.VaadinSession", name: "attributes", type: "class com.vaadin.flow.server.Attributes")
	- custom writeObject data (class "com.vaadin.flow.server.VaadinSession")
	- object (class "com.vaadin.flow.spring.SpringVaadinSession", com.vaadin.flow.spring.SpringVaadinSession@5544baac)
	- custom writeObject data (class "java.util.HashMap")
	- root object (class "java.util.HashMap", {com.vaadin.flow.server.VaadinSession.springServlet=com.vaadin.flow.spring.SpringVaadinSession@5544baac, springServlet.lock=java.util.concurrent.locks.ReentrantLock@46e4aae6[Unlocked], org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository.CSRF_TOKEN=org.springframework.security.web.csrf.DefaultCsrfToken@5786acad, clusterKey=ba60b62d-ae4c-46ee-9259-45b03ec9623d_SOURCE:DAD56D60A91A82D69729F102FED0D322, SPRING_SECURITY_CONTEXT=SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=org.springframework.security.core.userdetails.User [Username=admin@vaadin.com, Password=[PROTECTED], Enabled=true, AccountNonExpired=true, credentialsNonExpired=true, AccountNonLocked=true, Granted Authorities=[ROLE_admin]], Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=9EEA113887DE836010569B45CD9744B3], Granted Authorities=[ROLE_admin]]]})

Par exemple, dans l’extrait ci-dessus lors de la navigation vers l’application DashboardView, le processus n’a pas réussi à désérialiser une expression lambda en com.vaadin.flow.component.ComponentEventListener.

Source code
DESERIALIZATION_FAILED:
cannot assign instance of java.lang.invoke.SerializedLambda
to field com.vaadin.flow.component.ComponentEventBus$ListenerWrapper.listener
of type com.vaadin.flow.component.ComponentEventListener
in instance of com.vaadin.flow.component.ComponentEventBus$ListenerWrapper

En vérifiant la section BEST CANDIDATES, il est possible de voir qu’il existe une entrée dont le capturingClass est DashboardView. La lambda capture un ChartLoadEvent. La méthode définissant l’expression lambda peut être détectée à partir de l’attribut implementation, c’est-à-dire measurePageLoadPerformance dans DashboardView.

Source code
SERIALIZED LAMBDA CLASS CAST EXCEPTION BEST CANDIDATES:
=======================================================
	SerializedLambda[
		capturingClass=class com.vaadin.starter.bakery.ui.views.dashboard.DashboardView,
		functionalInterfaceMethod=com/vaadin/flow/component/ComponentEventListener.onComponentEvent:(Lcom/vaadin/flow/component/ComponentEvent;)V,
		implementation=invokeSpecial com/vaadin/starter/bakery/ui/views/dashboard/DashboardView.lambda$measurePageLoadPerformance$387549c5$1:(Ljava/util/concurrent/atomic/AtomicInteger;Lcom/vaadin/flow/component/charts/events/ChartLoadEvent;)V,
		instantiatedMethodType=(Lcom/vaadin/flow/component/charts/events/ChartLoadEvent;)V,
		numCaptured=2]

La méthode mentionnée présente le code suivant. Il peut être déduit que le problème est que l’expression lambda capture this et le fournit à d’autres composants qui stockent probablement une référence à celui-ci.

Source code
Java
	private void measurePageLoadPerformance() {
		final int nTotal = 5; // the total number of charts on the page
		AtomicInteger nLoaded = new AtomicInteger();
		ComponentEventListener<ChartLoadEvent> chartLoadListener = (event) -> {
			nLoaded.addAndGet(1);
			if (nLoaded.get() == nTotal) {
				UI.getCurrent().getPage().executeJs("$0._chartsLoadedResolve()", this); 1
			}
		};

		todayCountChart.addChartLoadListener(chartLoadListener); 2
		deliveriesThisMonthChart.addChartLoadListener(chartLoadListener);
		deliveriesThisYearChart.addChartLoadListener(chartLoadListener);
		yearlySalesGraph.addChartLoadListener(chartLoadListener);
		monthlyProductSplit.addChartLoadListener(chartLoadListener);
	}
  1. L’expression lambda capture l’instance this.

  2. L’expression lambda est utilisée comme ChartLoadListener.

Pour corriger ce problème, remplacez l’expression lambda par une classe anonyme :

Source code
Java
ComponentEventListener<ChartLoadEvent> chartLoadListener = new ComponentEventListener<>() {
    @Override
    public void onComponentEvent(ChartLoadEvent event) {
        nLoaded.addAndGet(1);
        if (nLoaded.get() == nTotal) {
            UI.getCurrent().getPage().executeJs("$0._chartsLoadedResolve()", DashboardView.this);
        }
    }
};