diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameLock.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameLock.java index d060d0e06..27a68b653 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameLock.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameLock.java @@ -26,6 +26,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Stack; +import android.support.annotation.NonNull; + // Implements read-locks and write-locks per game. A read lock is // obtainable when other read locks are granted but not when a // write lock is. Write-locks are exclusive. @@ -156,24 +158,30 @@ public class GameLock implements AutoCloseable { return this; } + @NonNull public GameLock lock() throws InterruptedException { if ( BuildConfig.DEBUG ) { DbgUtils.assertOnUIThread( false ); } - return lockImpl( Long.MAX_VALUE, false ); + GameLock result = lockImpl( Long.MAX_VALUE, false ); + Assert.assertNotNull( result ); + return result; } - public GameLock lockRO() throws InterruptedException - { - if ( BuildConfig.DEBUG ) { - DbgUtils.assertOnUIThread( false ); - } - return lockImpl( Long.MAX_VALUE, true ); - } + // @NonNull + // public GameLock lockRO() throws InterruptedException + // { + // if ( BuildConfig.DEBUG ) { + // DbgUtils.assertOnUIThread( false ); + // } + // GameLock result = lockImpl( Long.MAX_VALUE, true ); + // Assert.assertNotNull( result ); + // return result; + // } // Version that's allowed to return null -- if maxMillis > 0 - public GameLock lock( long maxMillis ) + public GameLock lock( long maxMillis ) throws GameLockedException { Assert.assertTrue( maxMillis <= THROW_TIME ); GameLock result = null; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java index 1a0fad4ca..370672797 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java @@ -1007,6 +1007,8 @@ public class GameUtils { } } } + } catch ( GameLock.GameLockedException gle ) { + Log.e( TAG, "feedMessage(): game locked; dropping message" ); } } return draw;