Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public boolean hasExpired() {
* @throws LeaseExpiredException
* If the lease has already timed out
*/
public void registerCallBack(Callable<Void> callback)
public synchronized void registerCallBack(Callable<Void> callback)
throws LeaseExpiredException {
if (hasExpired()) {
throw new LeaseExpiredException(messageForResource(resource));
Expand Down Expand Up @@ -143,7 +143,7 @@ public long getLeaseLifeTime() throws LeaseExpiredException {
* @throws LeaseExpiredException
* If the lease has already timed out
*/
public void renew(long timeout) throws LeaseExpiredException {
public synchronized void renew(long timeout) throws LeaseExpiredException {
if (hasExpired()) {
throw new LeaseExpiredException(messageForResource(resource));
}
Expand Down Expand Up @@ -185,8 +185,7 @@ List<Callable<Void>> getCallbacks() {
/**
* Expires/Invalidates the lease.
*/
void invalidate() {
callbacks = null;
synchronized void invalidate() {
expired = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ public void run() {
long remainingTime = lease.getRemainingTime();
if (remainingTime <= 0) {
//Lease has timed out
List<Callable<Void>> leaseCallbacks = lease.getCallbacks();
release(resource);
List<Callable<Void>> leaseCallbacks = lease.getCallbacks();
executorService.execute(
new LeaseCallbackExecutor<>(resource, leaseCallbacks));
} else {
Expand Down