vaadin / collaboration-engine

The simplest way to build real-time collaboration into web apps
https://vaadin.com/collaboration
Other
3 stars 1 forks source link

Inaccessible bean with CollaborationBinder only triggers async errors after setTopic #72

Open Legioth opened 1 year ago

Legioth commented 1 year ago

If you use CollaborationBinder with a private static bean, then there will initially not be any errors. After you add a setTopic call there will be an asynchronous exception that shows up as stacktrace in the console while the UI still renders.

To Reproduce Can be reproduced with the example code in https://github.com/vaadin/collaboration-engine/issues/71.

By adding this additional code snippet

binder.setTopic("foo", TextValueModel::new);

Expected behavior Expected that the problem is detected as quickly as possible and reported in a way that the developer definitely notices, e.g. as an exception directly from the CollaborationBinder constructor.

Versions

Legioth commented 1 year ago

The relevant part of the stack trace of the suppressed exception is

Caused by: java.lang.RuntimeException: java.lang.IllegalAccessException: class com.vaadin.flow.data.binder.BeanPropertySet cannot access a member of class com.example.application.views.CollaborationTextAreaBug$TextValueModel with modifiers "public"
    at com.vaadin.flow.data.binder.BeanPropertySet.invokeWrapExceptions(BeanPropertySet.java:536) ~[flow-data-23.3.0.jar:23.3.0]
    at com.vaadin.flow.data.binder.BeanPropertySet$BeanPropertyDefinition.lambda$getGetter$3ec26976$1(BeanPropertySet.java:122) ~[flow-data-23.3.0.jar:23.3.0]
    at com.vaadin.flow.data.binder.Binder$BindingImpl.read(Binder.java:1462) ~[flow-data-23.3.0.jar:23.3.0]
    at com.vaadin.collaborationengine.CollaborationBinder.lambda$initializeBindingsWithoutFieldState$8(CollaborationBinder.java:678) ~[collaboration-engine-5.3.0.jar:na]
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[na:na]
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[na:na]
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[na:na]
    at com.vaadin.collaborationengine.CollaborationBinder.initializeBindingsWithoutFieldState(CollaborationBinder.java:674) ~[collaboration-engine-5.3.0.jar:na]
    at com.vaadin.collaborationengine.CollaborationBinder.lambda$setTopic$58100c62$1(CollaborationBinder.java:645) ~[collaboration-engine-5.3.0.jar:na]
    at com.vaadin.collaborationengine.AbstractCollaborationManager.lambda$openTopicConnection$bf1f6fd6$1(AbstractCollaborationManager.java:101) ~[collaboration-engine-5.3.0.jar:na]
    at com.vaadin.collaborationengine.TopicConnection.lambda$acceptActionDispatcher$d0bdd016$1(TopicConnection.java:653) ~[collaboration-engine-5.3.0.jar:na]
    at com.vaadin.collaborationengine.ExecutionQueue.runPendingCommands(ExecutionQueue.java:29) ~[collaboration-engine-5.3.0.jar:na]
    at com.vaadin.collaborationengine.ComponentConnectionContext.lambda$flushPendingActionsIfActive$f657904e$1(ComponentConnectionContext.java:302) ~[collaboration-engine-5.3.0.jar:na]
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577) ~[na:na]
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[na:na]
    at com.vaadin.flow.server.VaadinService.runPendingAccessTasks(VaadinService.java:2059) ~[flow-server-23.3.0.jar:23.3.0]
    ... 58 common frames omitted
Caused by: java.lang.IllegalAccessException: class com.vaadin.flow.data.binder.BeanPropertySet cannot access a member of class com.example.application.views.CollaborationTextAreaBug$TextValueModel with modifiers "public"
    at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:420) ~[na:na]
    at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:709) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:569) ~[na:na]
    at com.vaadin.flow.data.binder.BeanPropertySet.invokeWrapExceptions(BeanPropertySet.java:534) ~[flow-data-23.3.0.jar:23.3.0]
    ... 81 common frames omitted