-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[mpd]: Music Player Daemon initial contribution #7870
Conversation
Travis tests were successfulHey @stefanroellin, |
Travis tests were successfulHey @stefanroellin, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your clean code makes reviewing easy! There is one checkstyle warning left.
...rg.openhab.binding.mpd/src/main/java/org/openhab/binding/mpd/internal/action/MPDActions.java
Show resolved
Hide resolved
...ng.mpd/src/main/java/org/openhab/binding/mpd/internal/discovery/MPDDiscoveryParticipant.java
Outdated
Show resolved
Hide resolved
...ng.mpd/src/main/java/org/openhab/binding/mpd/internal/discovery/MPDDiscoveryParticipant.java
Outdated
Show resolved
Hide resolved
...binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDConnectionThread.java
Show resolved
Hide resolved
...binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDConnectionThread.java
Outdated
Show resolved
Hide resolved
...org.openhab.binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDSong.java
Show resolved
Hide resolved
...g.openhab.binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDStatus.java
Show resolved
Hide resolved
bundles/org.openhab.binding.mpd/src/main/resources/ESH-INF/i18n/mpd_de.properties
Outdated
Show resolved
Hide resolved
@fwolter thanks for the review. I have made the requested changes. |
Travis tests were successfulHey @stefanroellin, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your changes look good! I found a few minor things I overlooked during the first review. Sorry for that.
...rg.openhab.binding.mpd/src/main/java/org/openhab/binding/mpd/internal/action/MPDActions.java
Outdated
Show resolved
Hide resolved
...ng.mpd/src/main/java/org/openhab/binding/mpd/internal/discovery/MPDDiscoveryParticipant.java
Outdated
Show resolved
Hide resolved
...enhab.binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDConnection.java
Outdated
Show resolved
Hide resolved
...binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDConnectionThread.java
Outdated
Show resolved
Hide resolved
...binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDConnectionThread.java
Show resolved
Hide resolved
...binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDConnectionThread.java
Show resolved
Hide resolved
Travis tests were successfulHey @stefanroellin, |
Thanks again @fwolter for the review and no problem at all. I appreciate any feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @stefanroellin,
Thanks again for your contribution the code looks good!
I added some comments regarding the error messages which are displayed when things go wrong and some other details. Please let me know if you have any questions!
...g.openhab.binding.mpd/src/main/java/org/openhab/binding/mpd/internal/handler/MPDHandler.java
Show resolved
Hide resolved
...g.openhab.binding.mpd/src/main/java/org/openhab/binding/mpd/internal/handler/MPDHandler.java
Outdated
Show resolved
Hide resolved
...binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDConnectionThread.java
Outdated
Show resolved
Hide resolved
....openhab.binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDCommand.java
Outdated
Show resolved
Hide resolved
...enhab.binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDConnection.java
Outdated
Show resolved
Hide resolved
...binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDConnectionThread.java
Outdated
Show resolved
Hide resolved
...binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDConnectionThread.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
private void closeSocket() { | ||
logger.debug("Closing socket"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need to close all of them? Will closing some of them not take a long the rest. E.g closing both the reader
and inputStreamReader
is AFAIK not needed.
A quick peak in the javadoc suggested that closing the socket will do all the work at one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have realized that the writer (DataOutputStream) is not necessary, since one can use socket.getOutputStream() directly.
@fwolter has suggested in #7870 (comment) to also close the InputStreamReader, which is in contrast to your suggestion. From the mentioned javadoc it is clear that the InputStream and the OutputStream will also be closed, when the socket is closed. I do not close these streams explicitly.
However, I would at least close the BufferedReader. But it does not harm, if I also close the InputStreamReader. I prefer to close too much than too little. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with keeping it like this. But there is a reason they mention it. Sometimes closing twice could lead to errors/exceptions and when not explicitly documented I would rather not.
...binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDConnectionThread.java
Outdated
Show resolved
Hide resolved
...binding.mpd/src/main/java/org/openhab/binding/mpd/internal/protocol/MPDConnectionThread.java
Outdated
Show resolved
Hide resolved
@martinvw thanks for your review. I have implemented your suggestions and commented some of them. I would appreciate your feedback. |
throw new MPDException("Missing parameter ipAddress"); | ||
} | ||
if (port < 1 || port > 65335) { | ||
throw new MPDException("Invalid parameter port"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor:
throw new MPDException("Invalid parameter port"); | |
throw new MPDException("Invalid port parameter"); |
Otherwise, it might suggest that the parameter port is invalid and should not be supplied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stefanroellin please let me know if you want to fix this tiny comment otherwise I'm fine merging as is, thanks for your work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will push a fix for it.
if (logger.isTraceEnabled()) { | ||
logger.trace("send command '{}'", command.asLine()); | ||
} | ||
final Socket socket = this.socket; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might make sense to fetch the socket.getOutputStream()
here so that you don't have to fetch it twice or was there a specific reason to do it like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe socket
can be nulled out and socket. getOutputStream
not, sensible enough :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought of using a local variable for getOutputStream(), but I find the current code is easier to read and circumvents the problem you describe.
FTR: Jenkins reports:
I would guess that is because the branch was not fully rebased, the version of the MPD binding seems fine. |
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
@martinvw I have pushed some changes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch> Signed-off-by: Clayton Tabone <taboneclayton@gmail.com>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch> Signed-off-by: Daan Meijer <daan@studioseptember.nl>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin <stefan@roellin-baumann.ch>
Signed-off-by: Stefan Roellin stefan@roellin-baumann.ch
This binding controls Music Player Daemons (https://www.musicpd.org/) and is meant to replace the corresponding binding from openhab1-addons (https://www.openhab.org/addons/bindings/mpd1/)
Almost all functionality from the old binding is supported, except
However, the new implementation has actions, which allow to send arbitrary commands to a Music Player Daemon. With those actions, the missing functionality can be replaced easily and is much more flexible.
Example with actions: