Reduce dependency on commons-io and commons-codec (#10614)
Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -19,7 +19,6 @@ import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.openhab.core.util.HexUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -182,11 +181,8 @@ public class OnkyoAlbumArt {
|
||||
try {
|
||||
URL url = new URL(albumArtUrl);
|
||||
URLConnection connection = url.openConnection();
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
try {
|
||||
return IOUtils.toByteArray(inputStream);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(inputStream);
|
||||
try (InputStream inputStream = connection.getInputStream()) {
|
||||
return inputStream.readAllBytes();
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
logger.warn("Album Art download failed from url '{}', reason {}", albumArtUrl, e.getMessage());
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand;
|
||||
import org.openhab.binding.onkyo.internal.eiscp.EiscpException;
|
||||
import org.openhab.binding.onkyo.internal.eiscp.EiscpMessage;
|
||||
@@ -222,17 +221,26 @@ public class OnkyoConnection {
|
||||
logger.debug("closed connection tester!");
|
||||
}
|
||||
if (inStream != null) {
|
||||
IOUtils.closeQuietly(inStream);
|
||||
try {
|
||||
inStream.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
inStream = null;
|
||||
logger.debug("closed input stream!");
|
||||
}
|
||||
if (outStream != null) {
|
||||
IOUtils.closeQuietly(outStream);
|
||||
try {
|
||||
outStream.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
outStream = null;
|
||||
logger.debug("closed output stream!");
|
||||
}
|
||||
if (eiscpSocket != null) {
|
||||
IOUtils.closeQuietly(eiscpSocket);
|
||||
try {
|
||||
eiscpSocket.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
eiscpSocket = null;
|
||||
logger.debug("closed socket!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user