2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 13:47:41 +00:00

Use IOUtils.close().

This commit is contained in:
Isira Seneviratne
2020-07-11 17:35:41 +05:30
committed by Nicolas Fella
parent 1c416852e2
commit 06aac453ea
3 changed files with 8 additions and 8 deletions

View File

@@ -33,6 +33,7 @@ import android.os.Build;
import android.os.Parcelable;
import android.util.Log;
import org.apache.commons.io.IOUtils;
import org.kde.kdeconnect.Backends.BaseLinkProvider;
import org.kde.kdeconnect.Device;
import org.kde.kdeconnect.NetworkPacket;
@@ -230,7 +231,7 @@ public class BluetoothLinkProvider extends BaseLinkProvider {
} catch (Exception e) {
synchronized (sockets) {
sockets.remove(socket.getRemoteDevice());
if (connection != null) connection.close();
IOUtils.close(connection);
}
throw e;
}

View File

@@ -23,6 +23,7 @@ package org.kde.kdeconnect;
import android.content.Context;
import android.util.Log;
import org.apache.commons.io.IOUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -361,9 +362,7 @@ public class NetworkPacket {
public void close() {
//TODO: If socket only close socket if that also closes the streams that is
try {
if (inputStream != null) {
inputStream.close();
}
IOUtils.close(inputStream);
} catch(IOException ignored) {}
try {

View File

@@ -32,6 +32,7 @@ import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.documentfile.provider.DocumentFile;
import org.apache.commons.io.IOUtils;
import org.kde.kdeconnect.Device;
import org.kde.kdeconnect.Helpers.FilesHelper;
import org.kde.kdeconnect.Helpers.MediaStoreHelper;
@@ -244,10 +245,9 @@ public class CompositeReceiveFileJob extends BackgroundJob<Device, Void> {
} finally {
closeAllInputStreams();
networkPacketList.clear();
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException ignored) {}
try {
IOUtils.close(outputStream);
} catch (IOException ignored) {
}
}
}