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

[hueemulation] Fix warnings/stacktraces at startup #5709

Merged
merged 1 commit into from
Jun 10, 2019

Conversation

wborn
Copy link
Member

@wborn wborn commented Jun 9, 2019

  • Properly annotates optional references with nullable to fix NPEs
  • Reworked HueEmulationConfigWithRuntime.startNow to prevent IllegalStateException

Fixes #5622


This fixes all warning/stacktrace noise from this add-on when using the Demo.

* Properly annotates optional references with nullable to fix NPEs
* Reworked HueEmulationConfigWithRuntime.startNow to prevent IllegalStateException

Fixes openhab#5622

Signed-off-by: Wouter Born <github@maindrain.net>
@@ -201,10 +201,11 @@ public void handleEvent(@Nullable Event event) {
initParams.put("com.sun.jersey.api.json.POJOMappingFeature", "false");
initParams.put(ServletProperties.PROVIDER_WEB_APP, "false");
httpService.registerServlet(RESTAPI_PATH, new ServletContainer(resourceConfig), initParams, null);
if (discovery == null) {
UpnpServer localDiscovery = discovery;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question: Why don't you use

            UpnpServer discovery = this.discovery;

IMO this is more clear.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm used to SonarQube telling me declaring local variables that hide fields is a bad practice. ;-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the rule I'm using on other projects. It sometimes saves you from creating bugs too.

http://checkstyle.sourceforge.net/apidocs/com/puppycrawl/tools/checkstyle/checks/coding/HiddenFieldCheck.html

@J-N-K
Copy link
Member

J-N-K commented Jun 10, 2019

Jenkins fails unrelated

@J-N-K J-N-K merged commit 51873b5 into openhab:master Jun 10, 2019
@wborn wborn deleted the hueemulation-fixes branch June 10, 2019 08:15
@davidgraeff
Copy link
Member

Thanks

Pshatsillo pushed a commit to Pshatsillo/openhab-addons that referenced this pull request Jun 19, 2019
* Properly annotates optional references with nullable to fix NPEs
* Reworked HueEmulationConfigWithRuntime.startNow to prevent IllegalStateException

Fixes openhab#5622

Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Pshatsillo <pshatsillo@gmail.com>
@wborn wborn added this to the 2.5 milestone Jul 30, 2019
ne0h pushed a commit to ne0h/openhab-addons that referenced this pull request Sep 15, 2019
* Properly annotates optional references with nullable to fix NPEs
* Reworked HueEmulationConfigWithRuntime.startNow to prevent IllegalStateException

Fixes openhab#5622

Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Maximilian Hess <mail@ne0h.de>
tmrobert8 pushed a commit to tmrobert8/openhab-addons that referenced this pull request Jan 21, 2020
* Properly annotates optional references with nullable to fix NPEs
* Reworked HueEmulationConfigWithRuntime.startNow to prevent IllegalStateException

Fixes openhab#5622

Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Tim Roberts <timmarkroberts@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[hueemulation] Always logs warnings/stacktraces at startup
3 participants