Skip to content

Commit

Permalink
[rfxcom] Removed dependency on 'org.apache.commons.io.IOUtils' (openh…
Browse files Browse the repository at this point in the history
…ab#7729)

Related to openhab#7722

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo authored and markus7017 committed Sep 18, 2020
1 parent a43ef97 commit 52b94bf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import java.io.IOException;

import org.apache.commons.io.IOUtils;
import org.eclipse.smarthome.core.util.HexUtils;
import org.openhab.binding.rfxcom.internal.config.RFXComBridgeConfiguration;
import org.slf4j.Logger;
Expand Down Expand Up @@ -77,19 +76,27 @@ public void disconnect() {

if (out != null) {
logger.debug("Close serial out stream");
IOUtils.closeQuietly(out);
try {
out.close();
} catch (IOException e) {
logger.debug("Error while closing the out stream: {}", e.getMessage());
}
}
if (in != null) {
logger.debug("Close serial in stream");
IOUtils.closeQuietly(in);
try {
in.close();
} catch (IOException e) {
logger.debug("Error while closing the in stream: {}", e.getMessage());
}
}

if (serialPort != null) {
logger.debug("Close serial port");
try {
serialPort.close();
} catch (IOException e) {
logger.warn("Serial port closing error", e);
logger.debug("Serial port closing error: {}", e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.io.OutputStream;
import java.util.TooManyListenersException;

import org.apache.commons.io.IOUtils;
import org.eclipse.smarthome.core.util.HexUtils;
import org.eclipse.smarthome.io.transport.serial.PortInUseException;
import org.eclipse.smarthome.io.transport.serial.SerialPort;
Expand Down Expand Up @@ -106,11 +105,19 @@ public void disconnect() {

if (out != null) {
logger.debug("Close serial out stream");
IOUtils.closeQuietly(out);
try {
out.close();
} catch (IOException e) {
logger.debug("Error while closing the out stream: {}", e.getMessage());
}
}
if (in != null) {
logger.debug("Close serial in stream");
IOUtils.closeQuietly(in);
try {
in.close();
} catch (IOException e) {
logger.debug("Error while closing the in stream: {}", e.getMessage());
}
}

if (serialPort != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.net.Socket;
import java.net.SocketTimeoutException;

import org.apache.commons.io.IOUtils;
import org.eclipse.smarthome.core.util.HexUtils;
import org.openhab.binding.rfxcom.internal.config.RFXComBridgeConfiguration;
import org.slf4j.Logger;
Expand Down Expand Up @@ -69,16 +68,28 @@ public void disconnect() {

if (out != null) {
logger.debug("Close tcp out stream");
IOUtils.closeQuietly(out);
try {
out.close();
} catch (IOException e) {
logger.debug("Error while closing the out stream: {}", e.getMessage());
}
}
if (in != null) {
logger.debug("Close tcp in stream");
IOUtils.closeQuietly(in);
try {
in.close();
} catch (IOException e) {
logger.debug("Error while closing the in stream: {}", e.getMessage());
}
}

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());
}
}

readerThread = null;
Expand Down

0 comments on commit 52b94bf

Please sign in to comment.