Fix DelegateSemaphore synchronisation issues on Spigot (#1781)

* Fix DelegateSemaphore synchronisation issues on Spigot
 - Also effectively nullify it on paper - the synchronisation on the object is enough

* Remove unneeded imports
This commit is contained in:
Jordan
2022-06-10 18:50:16 +01:00
committed by GitHub
parent 7f8ce69563
commit da3fc2e6ea
7 changed files with 43 additions and 19 deletions

View File

@ -14,6 +14,9 @@ public class DelegateSemaphore extends Semaphore {
// this is bad
@Override
public synchronized boolean tryAcquire() {
if (delegate == null) {
return true;
}
try {
this.delegate.acquire();
return true;
@ -24,11 +27,17 @@ public class DelegateSemaphore extends Semaphore {
@Override
public synchronized void acquire() throws InterruptedException {
if (delegate == null) {
return;
}
this.delegate.acquire();
}
@Override
public synchronized void release() {
public void release() {
if (delegate == null) {
return;
}
this.delegate.release();
}