Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

[LIFX] IllegalMonitorStateException may occur when unlocking after sending broadcast packet #1915

Closed
wborn opened this issue Jul 25, 2016 · 1 comment
Labels

Comments

@wborn
Copy link
Contributor

wborn commented Jul 25, 2016

Often during initialization of the LifxLightHandler, the following exception is thrown in my setup:

java.lang.IllegalMonitorStateException
    at java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(ReentrantLock.java:151)[:1.8.0_101]
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1261)[:1.8.0_101]
    at java.util.concurrent.locks.ReentrantLock.unlock(ReentrantLock.java:457)[:1.8.0_101]
    at org.eclipse.smarthome.binding.lifx.internal.LifxNetworkThrottler.unlock(LifxNetworkThrottler.java:89)[193:org.eclipse.smarthome.binding.lifx:0.9.0.201607221840]
    at org.eclipse.smarthome.binding.lifx.handler.LifxLightHandler.broadcastPacket(LifxLightHandler.java:599)[193:org.eclipse.smarthome.binding.lifx:0.9.0.201607221840]
    at org.eclipse.smarthome.binding.lifx.handler.LifxLightHandler.initialize(LifxLightHandler.java:223)[193:org.eclipse.smarthome.binding.lifx:0.9.0.201607221840]
    at org.eclipse.smarthome.core.thing.internal.ThingManager$8$1.call(ThingManager.java:739)[102:org.eclipse.smarthome.core.thing:0.9.0.201607221840]
    at org.eclipse.smarthome.core.thing.internal.ThingManager$8$1.call(ThingManager.java:1)[102:org.eclipse.smarthome.core.thing:0.9.0.201607221840]
    at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:177)[96:org.eclipse.smarthome.core:0.9.0.201607221840]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_101]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_101]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_101]
    at java.lang.Thread.run(Thread.java:745)[:1.8.0_101]

The LifxNetworkThrottler.unlock() method always tries to release all locks. Even those of other threads. The exception seems to occur when a bulb is added that was not yet available before the LifxLightHandler.broadcastPacket(..) method called LifxNetworkThrottler.lock() .

As a result of this, the whole LIFX binding becomes unusable. The thread in which the exception occurs does not unlock all its locked ReentrantLocks .

Due to my setup this concurrency issue is often reproducible:

  • 34 LIFX bulbs
  • fast development PC (Skylake i7-6700K)
@kaikreuzer
Copy link
Contributor

34 LIFX bulbs? Wow :-)

Thanks for providing the fix yourself!

@kaikreuzer kaikreuzer added the bug label Jul 26, 2016
cdjackson added a commit to cdjackson/smarthome that referenced this issue Aug 1, 2016
* master: (29 commits)
  Fix mDNS discovery (bug eclipse-archived#577 eclipse-archived#1745) (eclipse-archived#1742)
  create thread pool for firmware update job on demand (eclipse-archived#1906)
  fixes yahoo weather config status provider (eclipse-archived#1937)
  minor changes for the config status message key handling as discussed in eclipse-archived#1819 (eclipse-archived#1933)
  added default constructors (eclipse-archived#1931)
  added gulp-util, which has been missing (eclipse-archived#1929)
  Bug fix: Input type text (eclipse-archived#1930)
  moved to its own repo at https://github.com/eclipse/smarthome.osgi-ri.enocean (eclipse-archived#1923)
  Support state options in control UI (eclipse-archived#1888)
  LIFX binding: Fix eclipse-archived#1915 IllegalMonitorStateException may occur when unlocking after sending broadcast packet (eclipse-archived#1919)
  re-added support for dimmable plug-in units (eclipse-archived#1913)
  use context equals case insensitive for password (eclipse-archived#1910)
  added ConfigStatusBridgeHandler (eclipse-archived#1898)
  Add title tooltip to icons (eclipse-archived#1892)
  added a hint about periodically executed jobs (eclipse-archived#1909)
  override methods to keep type information (eclipse-archived#1911)
  Hue binding: fix 1880 (eclipse-archived#1899)
  mark API dependencies as provided (eclipse-archived#1904)
  password context based input (eclipse-archived#1897)
  make BridgeBuilder a subclass of ThingBuilder and adapt BaseBridgeHandler.editThing() (eclipse-archived#1894)
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants