-
Notifications
You must be signed in to change notification settings - Fork 168
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 in TemplateInitializer when creating instance from background thread #3738
Comments
The ticket says actually: Whether or not the application itself and/or thread handling needs to be implemented differently can be debated, but at least TemplateInitializer should fail more gracefully with a helpful error message. That what needs to be fixed. If |
At least based on the thread, this occurs even when executing the code via |
The exact source code is needed then. |
The stacktrace in the main description is bad. The good stacktrace is (from the forum thread):
This shows that the exception happens inside But this is totally different exception which is thrown inside |
A good question is whether it should necessary to be inside It will definitely be required when the created component gets attached to the UI, but anything before that is somewhat of a gray area. |
Yes, of course. |
So far, anything that hasn't been directly connected to any specific Even though it might still have been semantically wrong to do so, it has worked without problems for many years. |
The common pattern in Swing is to have a CTOR with a parent component as an argument. It's only theoretically possible to create a UI instance out of the UI thread without any problem and then attach it to the UI tree inside UI thread. I've seen quite a lot of cases where this happens in Swing. That's why there is a rule of dumb: any UI object has to be scoped inside UI thread and may not leak to outside of it. |
Hello, I have an example for you thats represents the bug. I have tried with a Broadcaster and without the Broadcaster. Both end with this exception. |
@Henrizzle The only exception I see when doing |
Disable the Broadcaster and then you will see the same exception... Use this to find this bug. I think it stands in relation with Spring Boot 2? |
@Henrizzle Could you please share code or very specific instructions that actually reproduces the issue instead of only giving a rather vague description on how to modify the code? Even if I would make a guess that leads to a situation that looks similar to the |
The example code modifies the UI without using I will close this issue and create a new one that is only focused on the other |
1.0.0.beta3 with Spring
Based on this Forum thread: https://vaadin.com/forum/thread/17015671
I'm not clear on an exact mechanism on how this can be reproduced. The main idea is that in certain conditions, when creating an instance of a custom PolymerTemplate component in a background thread, TemplateInitializer will fail with a NPE. The exception seems to be thrown from this line in the constructor:
Guess: VaadinService.getCurrent() returns
null
here.Whether or not the application itself and/or thread handling needs to be implemented differently can be debated, but at least TemplateInitializer should fail more gracefully with a helpful error message.
Stack trace:
The text was updated successfully, but these errors were encountered: