# Bug in BundleUtil.removeBundle? Driver classes do not unload

**URL:** <https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249>\
**Category:** Module Development\
**Created:** [April 5, 2012, 10:39am UTC](https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249 "2012-04-05T10:39:08Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [April 5, 2012, 10:39am UTC](https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249/1 "2012-04-05T10:39:08Z")

</div>

There seems to be a little bug or at least a documentation problem with the bundle util.  
When i add a bundle in ModuleHook.setup with `BundleUtil.get().addBundle(xxx.class);` and remove it in ModuleHook.shutdown with `BundleUtil.get().removeBundle(xxx.class);` there is still a reference to my class on the heap. As the built in drivers seem to to use this remove method (the Modbus driver in the api example definitely does), you will always have duplicate classes after a driver restart. This causes problems when trying to debug in development mode, since the VM seems to use parts of the old jar file instead of the newly uploaded one.  
When is use `BundleUtil.get().removeBundle(xxx.class.getSimpleName();` instead, everything works as expected.

If this is a intended behavior of BundleUtil.remove(Class) it would be good to mention it in the javadocs.

By the way, is it correct that the 7.4 api still expects api version 3 in ModuleHook.startup?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [April 5, 2012, 4:31pm UTC](https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249/2 "2012-04-05T16:31:01Z")

</div>

Thanks for the heads up. The docs aren’t wrong (It is removing your bundle), but there is an implementation issue that’s leaving a reference to your module’s ClassLoader when you use the removeBundle(Class) overload, as you reported.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 5, 2012, 5:03pm UTC](https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249/3 "2012-04-05T17:03:50Z")

</div>

> [@chi](#):
>
> By the way, is it correct that the 7.4 api still expects api version 3 in ModuleHook.startup?

Yes, that's correct. I don't think anything in the Driver API changes in a backwards-incompatible way between 7.3 and 7.4, like it did between 7.2 and 7.3.

---

<div class="post-metadata">

**Author:** ![Darren\_Steele](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/darren_steele/32/55624_2.png) [@Darren\_Steele](https://forum.inductiveautomation.com/u/Darren_Steele)\
**Post date:** [February 20, 2024, 4:25pm UTC](https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249/4 "2024-02-20T16:25:51Z")

</div>

So I realise this thread is 12 years old but was this bug ever fixed? I just fixed a very weird issue with module restarts reporting it couldn't find some resources by adding the getSimpleName() fix to removeBundle.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 20, 2024, 4:28pm UTC](https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249/5 "2024-02-20T16:28:08Z")

</div>

Nope... 🙃

---

<div class="post-metadata">

**Author:** ![Darren\_Steele](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/darren_steele/32/55624_2.png) [@Darren\_Steele](https://forum.inductiveautomation.com/u/Darren_Steele)\
**Post date:** [February 20, 2024, 4:37pm UTC](https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249/6 "2024-02-20T16:37:35Z")

</div>

haha, ok, thanks for the prompt reply. Maybe a note in the documentation would be useful. Hopefully people facing similar issues will find this thread.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 20, 2024, 4:46pm UTC](https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249/7 "2024-02-20T16:46:04Z")

</div>

Getting burned by BundleUtil is a right of passage!

I suspect it won't be an issue anymore in 8.3 with module hot-loading on the chopping block.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 20, 2024, 4:55pm UTC](https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249/8 "2024-02-20T16:55:48Z")

</div>

> [@Kevin.Herron](#):
>
> hot-loading on the chopping block.

Sigh. I've slowly shifted to the opinion that this is a mistake. ☹

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 20, 2024, 4:56pm UTC](https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249/9 "2024-02-20T16:56:15Z")

</div>

Really? I thought you were always of the opinion it was a mistake.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 20, 2024, 4:58pm UTC](https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249/10 "2024-02-20T16:58:47Z")

</div>

I didn't think it was a mistake when first announced. It took a few months of paying attention to how often my clients and I would upgrade modules, or add newly licensed modules to running systems, or drop modules. Every one of those would have been a scheduling nightmare.

I was entirely convinced by last ICC.

Even with redundant systems, there's a data loss window during switchover. I'll take another stab at talking Carl out of this in September.

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [February 20, 2024, 4:58pm UTC](https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249/11 "2024-02-20T16:58:54Z")

</div>

> [@Kevin.Herron](#):
>
> hot-loading on the chopping block

Does this mean that 8.3 will require a gateway restart to load modules? What will the new process look like?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 20, 2024, 5:01pm UTC](https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249/12 "2024-02-20T17:01:24Z")

</div>

Yeah, something like that. You will "install" or "uninstall" modules but they will be staged to take effect on the next restart.

This isn't a change I'm really championing or involved in. I see the benefits to both sides and can't really decide where I land.

Maybe we'll run out of time before 8.3 and never do it 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 20, 2024, 5:05pm UTC](https://forum.inductiveautomation.com/t/bug-in-bundleutil-removebundle-driver-classes-do-not-unload/4249/13 "2024-02-20T17:05:11Z")

</div>

> [@Kevin.Herron](#):
>
> and never do it

So, your internal pre-alphas still hot-load? Yay! I'd say your odds of running out of time are now **high**. 😁
