Skip to content

Commit

Permalink
[dscalarm] Removed dependency on 'org.apache.commons.io.IOUtils' (ope…
Browse files Browse the repository at this point in the history
…nhab#7737)

Relative to openhab#7722

Let the socket closure close the in/out streams

Signed-off-by: Laurent Garnier <[email protected]>
  • Loading branch information
lolodomo authored and andrewfg committed Aug 31, 2020
1 parent 6cd81c2 commit 182d559
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,9 @@ public void closeConnection() {
logger.debug("closeConnection(): Closing Socket!");
tcpSocket.close();
tcpSocket = null;
}
if (tcpInput != null) {
logger.debug("closeConnection(): Closing Output Writer!");
tcpInput.close();
tcpInput = null;
}
if (tcpOutput != null) {
logger.debug("closeConnection(): Closing Input Reader!");
tcpOutput.close();
tcpOutput = null;
}

setConnected(false);
logger.debug("closeConnection(): Closed TCP Connection!");
} catch (IOException ioException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.io.UnsupportedEncodingException;
import java.util.TooManyListenersException;

import org.apache.commons.io.IOUtils;
import org.eclipse.smarthome.core.thing.Bridge;
import org.eclipse.smarthome.core.thing.ThingStatus;
import org.eclipse.smarthome.io.transport.serial.PortInUseException;
Expand Down Expand Up @@ -189,12 +188,20 @@ public void closeConnection() {
serialPort.removeEventListener();

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,9 @@ public void closeConnection() {
if (tcpSocket != null) {
tcpSocket.close();
tcpSocket = null;
}
if (tcpInput != null) {
tcpInput.close();
tcpInput = null;
}
if (tcpOutput != null) {
tcpOutput.close();
tcpOutput = null;
}

setConnected(false);
logger.debug("closeConnection(): Closed TCP Connection!");
} catch (IOException ioException) {
Expand Down

0 comments on commit 182d559

Please sign in to comment.