forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ArC: fix deadlock when calling guarded methods on the same thread
- fixes quarkusio#35136
- Loading branch information
Showing
2 changed files
with
73 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...rojects/arc/tests/src/test/java/io/quarkus/arc/test/lock/LockInterceptorDeadlockTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package io.quarkus.arc.test.lock; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.arc.Lock; | ||
import io.quarkus.arc.Lock.Type; | ||
import io.quarkus.arc.impl.LockInterceptor; | ||
import io.quarkus.arc.test.ArcTestContainer; | ||
|
||
public class LockInterceptorDeadlockTest { | ||
|
||
@RegisterExtension | ||
public ArcTestContainer container = new ArcTestContainer(SimpleApplicationScopedBean.class, Lock.class, | ||
LockInterceptor.class); | ||
|
||
@Test | ||
public void testApplicationScopedBean() throws Exception { | ||
SimpleApplicationScopedBean bean = Arc.container().instance(SimpleApplicationScopedBean.class).get(); | ||
assertTrue(bean.read()); | ||
assertTrue(bean.nestedRead()); | ||
assertTrue(bean.nestedWrite()); | ||
} | ||
|
||
@ApplicationScoped | ||
static class SimpleApplicationScopedBean { | ||
|
||
@Lock(Type.READ) | ||
boolean read() { | ||
return write(); | ||
} | ||
|
||
@Lock(Type.READ) | ||
boolean nestedRead() { | ||
return read(); | ||
} | ||
|
||
@Lock(Type.WRITE) | ||
boolean write() { | ||
return true; | ||
} | ||
|
||
@Lock(Type.WRITE) | ||
boolean nestedWrite() { | ||
return nestedRead(); | ||
} | ||
} | ||
} |