Skip to content

Commit

Permalink
[oceanic] Removed dependency on 'org.apache.commons.io.IOUtils' (open…
Browse files Browse the repository at this point in the history
…hab#7732)

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 9ae6a79 commit a01c689
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingStatus;
Expand Down Expand Up @@ -83,8 +82,6 @@ public void initialize() {
public void dispose() {
NetworkOceanicBindingConfiguration config = getConfigAs(NetworkOceanicBindingConfiguration.class);

IOUtils.closeQuietly(inputStream);
IOUtils.closeQuietly(outputStream);
if (socket != null) {
try {
socket.close();
Expand All @@ -93,6 +90,8 @@ public void dispose() {
config.portNumber, e.getMessage());
} finally {
socket = null;
outputStream = null;
inputStream = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Arrays;
import java.util.Enumeration;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingStatus;
Expand Down Expand Up @@ -149,12 +148,29 @@ public void dispose() {
}
}

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

readerThread = null;
inputStream = null;
outputStream = null;
serialPort = null;

super.dispose();
}

Expand Down Expand Up @@ -224,7 +240,6 @@ public void interrupt() {
logger.trace("Interrupting the SerialPortReader");
interrupted = true;
super.interrupt();
IOUtils.closeQuietly(inputStream);
}

@Override
Expand Down

0 comments on commit a01c689

Please sign in to comment.