# NPE in getting extension which has lowest order property

**URL:** <https://talk.openmrs.org/t/npe-in-getting-extension-which-has-lowest-order-property/26559>\
**Category:** Development\
**Tags:** refapp\
**Created:** [January 29, 2020, 3:57pm UTC](https://talk.openmrs.org/t/npe-in-getting-extension-which-has-lowest-order-property/26559 "2020-01-29T15:57:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bistenes](https://talk.openmrs.org/user_avatar/talk.openmrs.org/bistenes/32/18573_2.png) [@bistenes](https://talk.openmrs.org/u/bistenes)\
**Post date:** [January 29, 2020, 3:57pm UTC](https://talk.openmrs.org/t/npe-in-getting-extension-which-has-lowest-order-property/26559/1 "2020-01-29T15:57:44Z")

</div>

There’s [a line](https://github.com/openmrs/openmrs-module-appui/commit/9a024d399fadb0950da50cadfab3087f7ec7bf93#diff-c3d6bc0fa0b62416d5c678c2a5c9f18cR47) in the appui code that’s causing NPEs that are hard to debug.

I would fix it, but I don’t understand the code. A few people have commented on that line and no one whose yet seen that code seems to understand it well enough to make the fix. @suthagar23, you wrote that code—can we expect you to fix it? All I’m hoping for is something like

```auto
Extension lowestOrderExtension = getLowestOrderExtenstion(exts);
if (lowestOrderExtension == null) {
  throw new Exception("Something explaining what's gone wrong, some reasons why this might happen, and suggestions for how someone might fix it.");
}
Map<String, Object> configSettings = lowestOrderExtension.getExtensionParams();

```

---

<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:** [January 30, 2020, 12:14pm UTC](https://talk.openmrs.org/t/npe-in-getting-extension-which-has-lowest-order-property/26559/2 "2020-01-30T12:14:32Z")

</div>

In order to maintain the logic of the [original code](https://github.com/openmrs/openmrs-module-appui/blob/724b4a9c8c434bb723b040a2ede8566612db481f/omod/src/main/java/org/openmrs/module/appui/fragment/controller/HeaderFragmentController.java#L39), which expected null in some cases, i would not throw an exception when `lowestOrderExtension` is null. So i have fixed it as in [this commit](https://github.com/openmrs/openmrs-module-appui/commit/3c5a6a0203e48431ac2f016748248006a29b33dc).

---

<div class="post-metadata">

**Author:** ![bistenes](https://talk.openmrs.org/user_avatar/talk.openmrs.org/bistenes/32/18573_2.png) [@bistenes](https://talk.openmrs.org/u/bistenes)\
**Post date:** [January 30, 2020, 2:00pm UTC](https://talk.openmrs.org/t/npe-in-getting-extension-which-has-lowest-order-property/26559/3 "2020-01-30T14:00:00Z")

</div>

Awesome, that makes perfect sense. Thank you!
