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:
committed by
Nicolas Fella
parent
1c416852e2
commit
06aac453ea
@@ -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;
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -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) {}
|
||||
IOUtils.close(outputStream);
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user