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:
parent
17a9aa3b20
commit
99130eb472
@ -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() {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user