
package org.kurento.commons;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TimeoutReentrantLock extends ReentrantLock {

  private static final long serialVersionUID = 3260128010629476025L;

  private static final Logger log = LoggerFactory.getLogger(TimeoutReentrantLock.class);

  private long timeout;
  private String name;

  public TimeoutReentrantLock(long timeout, String name) {
    this.timeout = timeout;
    this.name = name;
  }

  public void tryLockTimeout(String method) {

    // log.info("Thread {} trying to acquire lock {} in method {}", Thread
    // .currentThread().getName(), name, method);

    try {
      if (!tryLock(timeout, TimeUnit.MILLISECONDS)) {
        Thread ownerThread = getOwner();
        throw new TimeoutRuntimeException("Timeout waiting " + timeout + " millis "
            + "to acquire lock " + name + ". The lock is held by thread " + ownerThread.getName());
      }
    } catch (InterruptedException e) {
      throw new RuntimeException("InterruptedException while trying to acquire lock", e);
    }
  }
}

@@ -116,66 +116,8 @@
 k;%0A%0A
-import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0A
 publ
@@ -245,98 +245,8 @@
 L;%0A%0A
-  private static final Logger log = LoggerFactory.getLogger(TimeoutReentrantLock.class);%0A%0A
   pr
@@ -403,16 +403,16 @@
 e;%0A  %7D%0A%0A
+
   public
@@ -454,134 +454,8 @@
  %7B%0A%0A
-    // log.info(%22Thread %7B%7D trying to acquire lock %7B%7D in method %7B%7D%22, Thread%0A    // .currentThread().getName(), name, method);%0A%0A
     

Clean up TimeoutReentrantLock