Skip to content

Commit

Permalink
Fixed potential NPEs waiting to happen if there's no brewing events r…
Browse files Browse the repository at this point in the history
…ecorded.
  • Loading branch information
roughike committed Feb 8, 2017
1 parent cbf72dd commit 46335c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class RealmCoffeeEventRepository : CoffeeEventRepository {
.equalTo("isSuccessful", true)
.findAllSorted("time", Sort.ASCENDING)
.lastOrNull()
val copy = copyFromRealm(lastEvent)
val copy = if (lastEvent != null) copyFromRealm(lastEvent) else null

close()
return@with copy
Expand All @@ -73,7 +73,7 @@ class RealmCoffeeEventRepository : CoffeeEventRepository {
.equalTo("isSuccessful", false)
.findAllSorted("time", Sort.ASCENDING)
.lastOrNull()
val copy = copyFromRealm(accident)
val copy = if (accident != null) copyFromRealm(accident) else null

close()
return@with copy
Expand Down

0 comments on commit 46335c7

Please sign in to comment.