mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 01:28:52 -06:00
Fix race conditions on SQLiteScoreList
This commit is contained in:
@@ -81,7 +81,7 @@ public abstract class ScoreList implements Iterable<Score>
|
||||
* @param timestamp the timestamp of a day
|
||||
* @return score value for that day
|
||||
*/
|
||||
public final synchronized int getValue(long timestamp)
|
||||
public synchronized final int getValue(long timestamp)
|
||||
{
|
||||
compute(timestamp, timestamp);
|
||||
Score s = getComputedByTimestamp(timestamp);
|
||||
|
||||
@@ -100,7 +100,8 @@ public class SQLiteScoreList extends ScoreList
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public List<Score> getByInterval(long fromTimestamp, long toTimestamp)
|
||||
public synchronized List<Score> getByInterval(long fromTimestamp,
|
||||
long toTimestamp)
|
||||
{
|
||||
check(habit.getId());
|
||||
compute(fromTimestamp, toTimestamp);
|
||||
@@ -137,7 +138,7 @@ public class SQLiteScoreList extends ScoreList
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTodayValue()
|
||||
public synchronized int getTodayValue()
|
||||
{
|
||||
if (cache == null || cache.expired())
|
||||
cache = new CachedData(super.getTodayValue());
|
||||
@@ -146,7 +147,7 @@ public class SQLiteScoreList extends ScoreList
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateNewerThan(long timestamp)
|
||||
public synchronized void invalidateNewerThan(long timestamp)
|
||||
{
|
||||
cache = null;
|
||||
invalidateStatement.bindLong(1, habit.getId());
|
||||
|
||||
Reference in New Issue
Block a user