1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-29 05:16:51 +01:00

Fix closeable file leak on weather cache

This commit is contained in:
José Rebelo 2023-10-06 21:38:35 +01:00
parent 17a9aa3b20
commit 99130eb472
2 changed files with 14 additions and 4 deletions

View File

@ -156,7 +156,7 @@ public class GBApplication extends Application {
private BluetoothStateChangeReceiver bluetoothStateChangeReceiver;
private OpenTracksContentObserver openTracksObserver;
private long lastAutoExportTimestamp = 0;
private long autoExportScheduledTimestamp = 0;
@ -171,6 +171,18 @@ public class GBApplication extends Application {
public GBApplication() {
context = this;
// don't do anything here, add it to onCreate instead
//if (BuildConfig.DEBUG) {
// // detect everything
// //StrictMode.enableDefaults();
// // detect closeable objects
// //StrictMode.setVmPolicy(
// // new StrictMode.VmPolicy.Builder()
// // .detectLeakedClosableObjects()
// // .penaltyLog()
// // .build()
// //);
//}
}
public static Logging getLogging() {

View File

@ -994,14 +994,12 @@ public class Weather {
LOG.info("Setting weather cache file to {}", cacheFile.getPath());
if (cacheFile.isFile() && weatherSpec == null) {
try {
final FileInputStream f = new FileInputStream(cacheFile);
try (final FileInputStream f = new FileInputStream(cacheFile)) {
final ObjectInputStream o = new ObjectInputStream(f);
weatherSpec = (WeatherSpec) o.readObject();
o.close();
f.close();
} catch (final Throwable e) {
LOG.error("Failed to read weather from cache", e);
weatherSpec = null;