# Context.hasPrivilege is too busy

**URL:** <https://talk.openmrs.org/t/context-hasprivilege-is-too-busy/19237>\
**Category:** Development\
**Created:** [August 1, 2018, 10:50am UTC](https://talk.openmrs.org/t/context-hasprivilege-is-too-busy/19237 "2018-08-01T10:50:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![k.joseph](https://talk.openmrs.org/user_avatar/talk.openmrs.org/k.joseph/32/8097_2.png) [@k.joseph](https://talk.openmrs.org/u/k.joseph)\
**Post date:** [August 1, 2018, 10:50am UTC](https://talk.openmrs.org/t/context-hasprivilege-is-too-busy/19237/1 "2018-08-01T10:50:31Z")

</div>

i have noticed that Context.hasPrivilege receives so many calls and ends up evaluating to true most of the times at runtime with wrong privilege argument, has anyone encountered this?

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [August 5, 2018, 7:15am UTC](https://talk.openmrs.org/t/context-hasprivilege-is-too-busy/19237/2 "2018-08-05T07:15:20Z")

</div>

Can you give an example or a unit test where this evaluates to true with the wrong privilege argument?

---

<div class="post-metadata">

**Author:** ![k.joseph](https://talk.openmrs.org/user_avatar/talk.openmrs.org/k.joseph/32/8097_2.png) [@k.joseph](https://talk.openmrs.org/u/k.joseph)\
**Post date:** [August 7, 2018, 10:33am UTC](https://talk.openmrs.org/t/context-hasprivilege-is-too-busy/19237/3 "2018-08-07T10:33:00Z")

</div>

o, there’s need to let privilegeListener know of the privilege

---

<div class="post-metadata">

**Author:** ![piumal1999](https://talk.openmrs.org/user_avatar/talk.openmrs.org/piumal1999/32/13557_2.png) [@piumal1999](https://talk.openmrs.org/u/piumal1999)\
**Post date:** [March 17, 2021, 3:24pm UTC](https://talk.openmrs.org/t/context-hasprivilege-is-too-busy/19237/4 "2021-03-17T15:24:33Z")

</div>

Hi @k.josephI encountered a similar issue in the dhisconnector module.

To test that, I created a unit test like this:

```
@Test
public void testPrivileges(){
	Assert.assertTrue(Context.hasPrivilege("FooBar"));
}

```

This test passed everytime even if there’s no privilege called “FooBar”.

Could you please help me to figure it out. Thanks in advance

---

<div class="post-metadata">

**Author:** ![k.joseph](https://talk.openmrs.org/user_avatar/talk.openmrs.org/k.joseph/32/8097_2.png) [@k.joseph](https://talk.openmrs.org/u/k.joseph)\
**Post date:** [March 22, 2021, 6:44pm UTC](https://talk.openmrs.org/t/context-hasprivilege-is-too-busy/19237/5 "2021-03-22T18:44:17Z")

</div>

please check through if [openmrs-core/AuthorizationAdviceTest.java at master · openmrs/openmrs-core · GitHub](https://github.com/openmrs/openmrs-core/blob/master/api/src/test/java/org/openmrs/aop/AuthorizationAdviceTest.java#L38) can be of help!

---

<div class="post-metadata">

**Author:** ![piumal1999](https://talk.openmrs.org/user_avatar/talk.openmrs.org/piumal1999/32/13557_2.png) [@piumal1999](https://talk.openmrs.org/u/piumal1999)\
**Post date:** [March 23, 2021, 6:50pm UTC](https://talk.openmrs.org/t/context-hasprivilege-is-too-busy/19237/6 "2021-03-23T18:50:15Z")

</div>

Thank you! @k.joseph . I’ll go through it and let you know the status.
