Repository: eventfahrplan/eventfahrplan
Issue: NullPointerException: Attempt to invoke virtual method 'void AppRepository.cancelLoading()' on a null object reference

Crash report from a user:

- Sent: 22.12.2019 - 24.12.2019
- App version: [v.1.41.0](https://github.com/EventFahrplan/EventFahrplan/releases/tag/v.1.41.0)
- Android version: 9
- Device models: Mi MIX 2, Redmi Note 7

# Stacktrace
``` java
java.lang.RuntimeException: Unable to stop service 
    nerd.tuxmobil.fahrplan.congress.autoupdate.UpdateService@8162e9e: 
    java.lang.NullPointerException: Attempt to invoke virtual method 'void 
    nerd.tuxmobil.fahrplan.congress.repositories.AppRepository.cancelLoading()' 
    on a null object reference
at android.app.ActivityThread.handleStopService(ActivityThread.java:3796)
at android.app.ActivityThread.access$1800(ActivityThread.java:202)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1717)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:6878)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876)

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void 
    nerd.tuxmobil.fahrplan.congress.repositories.AppRepository.cancelLoading()' 
    on a null object reference
at nerd.tuxmobil.fahrplan.congress.autoupdate.UpdateService.onDestroy(UpdateService.java:142)
at android.app.ActivityThread.handleStopService(ActivityThread.java:3772)
```

# Log
``` java
0 D: Writing unhandled exception to: /data/user/0/info.metadude.android.congress.schedule/files/1.41.0-1576974844041.tracedroid
1 D: MyApp.meta = Meta(dayChangeHour=0, dayChangeMinute=0, eTag=W/"c293fd5f1dd7222a799609a0165508e51bff4da38f47995ab2aea13ccd7959da", numDays=4, subtitle=, title=36th Chaos Communication Congress, version=cat; chaos-west 1.0; open-infra 10; wikipaka 0.4; chaoszone 0.5; komona 0.4; sendezentrum 0.1; lightning Praseodymium; wiki 2019-12-22 00:30)
2 D: viewDay(false)
3 D: meta.getNumDays() = 4
4 D: MyApp.task_running = NONE
5 D: lectureId = null
6 D: MyApp.lectureList contains 192 items.
7 D: onResume
8 D: MyApp.meta = Meta(dayChangeHour=0, dayChangeMinute=0, eTag=W/"c293fd5f1dd7222a799609a0165508e51bff4da38f47995ab2aea13ccd7959da", numDays=4, subtitle=, title=36th Chaos Communication Congress, version=cat; chaos-west 1.0; open-infra 10; wikipaka 0.4; chaoszone 0.5; komona 0.4; sendezentrum 0.1; lightning Praseodymium; wiki 2019-12-22 00:30)
9 D: viewDay(false)
10 D: meta.getNumDays() = 4
11 D: MyApp.task_running = NONE
12 D: lectureId = null
13 D: MyApp.lectureList contains 192 items.
14 D: onResume
15 D: MyApp.meta = Meta(dayChangeHour=0, dayChangeMinute=0, eTag=W/"c293fd5f1dd7222a799609a0165508e51bff4da38f47995ab2aea13ccd7959da", numDays=4, subtitle=, title=36th Chaos Communication Congress, version=cat; chaos-west 1.0; open-infra 10; wikipaka 0.4; chaoszone 0.5; komona 0.4; sendezentrum 0.1; lightning Praseodymium; wiki 2019-12-22 00:30)
16 D: viewDay(false)
17 D: meta.getNumDays() = 4
18 D: MyApp.task_running = NONE
19 D: lectureId = null
20 D: MyApp.lectureList contains 192 items.
21 D: onResume
22 D: MyApp.meta = Meta(dayChangeHour=0, dayChangeMinute=0, eTag=W/"c293fd5f1dd7222a799609a0165508e51bff4da38f47995ab2aea13ccd7959da", numDays=4, subtitle=, title=36th Chaos Communication Congress, version=cat; chaos-west 1.0; open-infra 10; wikipaka 0.4; chaoszone 0.5; komona 0.4; sendezentrum 0.1; lightning Praseodymium; wiki 2019-12-22 00:30)
23 D: viewDay(false)
24 D: meta.getNumDays() = 4
25 D: MyApp.task_running = NONE
26 D: lectureId = null
27 D: MyApp.lectureList contains 192 items.
28 D: onResume
29 D: MyApp.meta = Meta(dayChangeHour=0, dayChangeMinute=0, eTag=W/"c293fd5f1dd7222a799609a0165508e51bff4da38f47995ab2aea13ccd7959da", numDays=4, subtitle=, title=36th Chaos Communication Congress, version=cat; chaos-west 1.0; open-infra 10; wikipaka 0.4; chaoszone 0.5; komona 0.4; sendezentrum 0.1; lightning Praseodymium; wiki 2019-12-22 00:30)
30 D: viewDay(false)
31 D: meta.getNumDays() = 4
32 D: MyApp.task_running = NONE
33 D: lectureId = null
34 D: MyApp.lectureList contains 192 items.
35 D: onResume
36 D: MyApp.meta = Meta(dayChangeHour=0, dayChangeMinute=0, eTag=W/"c293fd5f1dd7222a799609a0165508e51bff4da38f47995ab2aea13ccd7959da", numDays=4, subtitle=, title=36th Chaos Communication Congress, version=cat; chaos-west 1.0; open-infra 10; wikipaka 0.4; chaoszone 0.5; komona 0.4; sendezentrum 0.1; lightning Praseodymium; wiki 2019-12-22 00:30)
37 D: viewDay(false)
38 D: meta.getNumDays() = 4
39 D: MyApp.task_running = NONE
40 D: lectureId = null
41 D: MyApp.lectureList contains 192 items.
```


Changed files:
app/src/main/java/nerd/tuxmobil/fahrplan/congress/autoupdate/UpdateService.java

diff --git a/app/src/main/java/nerd/tuxmobil/fahrplan/congress/autoupdate/UpdateService.java b/app/src/main/java/nerd/tuxmobil/fahrplan/congress/autoupdate/UpdateService.java
index 5eeb19c7..b3110062 100644
--- a/app/src/main/java/nerd/tuxmobil/fahrplan/congress/autoupdate/UpdateService.java
+++ b/app/src/main/java/nerd/tuxmobil/fahrplan/congress/autoupdate/UpdateService.java
@@ -38,7 +38,8 @@ public class UpdateService extends JobIntentService {
 
     private static final String LOG_TAG = "UpdateService";
 
-    private AppRepository appRepository;
+    @SuppressWarnings("squid:S1170")
+    private final AppRepository appRepository = AppRepository.INSTANCE;
 
     public void onParseDone(@NonNull ParseResult result) {
         MyApp.LogDebug(LOG_TAG, "parseDone: " + result.isSuccess() + " , numDays=" + MyApp.meta.getNumDays());
@@ -133,7 +134,6 @@ public class UpdateService extends JobIntentService {
             stopSelf();
             return Unit.INSTANCE;
         }, true);
-        appRepository = AppRepository.INSTANCE;
         connectivityObserver.start();
     }