Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE with Polymer 2, Flow and @Synchronize annotation #1668

Closed
SomeoneToIgnore opened this issue May 24, 2017 · 5 comments
Closed

NPE with Polymer 2, Flow and @Synchronize annotation #1668

SomeoneToIgnore opened this issue May 24, 2017 · 5 comments
Assignees
Milestone

Comments

@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented May 24, 2017

The following class throws NPE on init:

@Tag("paper-input")
@HtmlImport("bower_components/paper-input/paper-input.html")
// most of the implementation is copied from com.vaadin.hummingbird.html.Input
public class PaperInput extends Component {
    private static final PropertyDescriptor<String, String> valueDescriptor =
            PropertyDescriptors.propertyWithDefault("value", "");

    public PaperInput() {
        // (this public no-arg constructor is required so that Flow can instantiate beans of this type
        // when they are bound to template elements via the @Id() annotation)
    }

    public PaperInput(String value) {
        setValue(value);
    }

    @Synchronize("value-changed")
    public String getValue() {
        return get(valueDescriptor);
    }

    @Synchronize("invalid-changed")
    public String getInvalid() {
        return getElement().getProperty("invalid");
    }

    public void setValue(String value) {
        set(valueDescriptor, value);
    }
}
public class TestUI extends UI {
    @Override
    protected void init(VaadinRequest request) {
        PaperInput paperInput = new PaperInput("sssssss");

        Button button = new Button("Print results", clickEvent -> {
            System.out.println(paperInput.getValue());
            System.out.println(paperInput.getInvalid());
        });
        add(paperInput, button);
    }
}

Fails with NPE.

If we replace new PaperInput("sssssss"); with new PaperInput(); or remove any @Synchronizeannotation, everything works without NPE.

@SomeoneToIgnore SomeoneToIgnore changed the title NPE while using paper-input with Flow NPE with Polymer 2, Flow and @Synchronize annotation May 24, 2017
@SomeoneToIgnore
Copy link
Contributor Author

My understanding is that there are some properties that are synced by default, like value and if we add an extra sync via annotation, we're getting some side effects that cause the NPE.

If we leave the annotation on getInvalid method and remove one on getValue method, all values will be synced without any error.

We need to fix this behaviour, since it's very confusing.

@denis-anisimov
Copy link
Contributor

It's always good to have the stacktrace available in the ticket if exception is mentioned.

@denis-anisimov
Copy link
Contributor

I don't see any NPE.
I see assertion error and unsupported operation exceptions:

java.lang.AssertionError
	at com.vaadin.server.communication.rpc.MapSyncRpcHandler.handleNode(MapSyncRpcHandler.java:48)
	at com.vaadin.server.communication.rpc.AbstractRpcInvocationHandler.handle(AbstractRpcInvocationHandler.java:50)
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:370)
	at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:296)
	at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:87)
	at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
	at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1391)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:277)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:835)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
	at org.eclipse.jetty.server.handler.ContextHandler.__doHandle(ContextHandler.java:1158)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
	at org.eclipse.jetty.server.Server.handle(Server.java:517)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
	at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
	at java.lang.Thread.run(Thread.java:745)
java.lang.UnsupportedOperationException: FIXME: Implement resync and call it above
	at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:291)
	at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:87)
	at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
	at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1391)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:277)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:835)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
	at org.eclipse.jetty.server.handler.ContextHandler.__doHandle(ContextHandler.java:1158)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
	at org.eclipse.jetty.server.Server.handle(Server.java:517)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
	at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
	at java.lang.Thread.run(Thread.java:745)

@denis-anisimov
Copy link
Contributor

Alright, I have assertions enabled that's why I get assertion exception before NPE.
With disabled assertions there won't be assertion error but NPE will be thrown instead later on.

@denis-anisimov
Copy link
Contributor

I don't see any difference with @Synchronized or without by the way.

Original problem here is on the client side. Property sync message (mSync) always has to contain value for the property . It doesn't. The reason: something happened on the client side which prevents to set this property into transport JSON object. And there is a client side exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants