Skip to content

Commit

Permalink
[lirc] Removed dependency on 'org.apache.commons.io.IOUtils' (openhab…
Browse files Browse the repository at this point in the history
…#7733)

Relative to openhab#7722

Let the socket closure close the in/out streams

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: CSchlipp <christian@schlipp.de>
  • Loading branch information
lolodomo authored and CSchlipp committed Jul 26, 2020
1 parent a01c689 commit cb426a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;

import org.apache.commons.io.IOUtils;
import org.openhab.binding.lirc.internal.config.LIRCBridgeConfiguration;
import org.openhab.binding.lirc.internal.messages.LIRCButtonEvent;
import org.openhab.binding.lirc.internal.messages.LIRCResponse;
Expand Down Expand Up @@ -75,23 +74,19 @@ public void disconnect() {
}
if (outWriter != null) {
logger.debug("Close print writer stream");
IOUtils.closeQuietly(outWriter);
outWriter.close();
outWriter = null;
}
if (out != null) {
logger.debug("Close tcp out stream");
IOUtils.closeQuietly(out);
out = null;
}
if (in != null) {
logger.debug("Close tcp in stream");
IOUtils.closeQuietly(in);
in = null;
}
if (socket != null) {
logger.debug("Close socket");
IOUtils.closeQuietly(socket);
try {
socket.close();
} catch (IOException e) {
logger.debug("Error while closing the socket: {}", e.getMessage());
}
socket = null;
out = null;
in = null;
}
logger.debug("Disconnected");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.io.IOUtils;
import org.openhab.binding.lirc.internal.LIRCResponseException;
import org.openhab.binding.lirc.internal.messages.LIRCButtonEvent;
import org.openhab.binding.lirc.internal.messages.LIRCResponse;
Expand Down Expand Up @@ -104,7 +103,11 @@ public void run() {
logger.error("Invalid message received", e);
}
}
IOUtils.closeQuietly(reader);
try {
reader.close();
} catch (IOException e) {
logger.debug("Error while closing the input stream: {}", e.getMessage());
}
}

private void processResponse(String responseText) throws LIRCResponseException {
Expand Down

0 comments on commit cb426a0

Please sign in to comment.