# Jira plugin cache problem

**URL:** <https://community.developer.atlassian.com/t/jira-plugin-cache-problem/2717>\
**Category:** Jira Development\
**Tags:** jira-server, java\
**Created:** [April 19, 2017, 10:54am UTC](https://community.developer.atlassian.com/t/jira-plugin-cache-problem/2717 "2017-04-19T10:54:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikola](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/mikola/32/521_2.png) [@Mikola](https://community.developer.atlassian.com/u/Mikola)\
**Post date:** [April 19, 2017, 10:54am UTC](https://community.developer.atlassian.com/t/jira-plugin-cache-problem/2717/1 "2017-04-19T10:54:01Z")

</div>

I’ve recently realized that each time I uninstall and reinstall the same plugin with updated logic, the old one still runs. Let’s say in the IssueUpdate event listener I have the following piece of code:

```
  System.out.println("Hello world");

```

and then I change it to

```
  System.out.println("Weird world");

```

I get both outputs. And if I change it further, the changes will be added to the old ones. So jira obviously caches them somewhere. But, if it caches them, why does it stop when I uninstall the plugin?

---

<div class="post-metadata">

**Author:** ![jobinkk](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/jobinkk/32/526_2.png) [@jobinkk](https://community.developer.atlassian.com/u/jobinkk)\
**Post date:** [April 19, 2017, 1:33pm UTC](https://community.developer.atlassian.com/t/jira-plugin-cache-problem/2717/2 "2017-04-19T13:33:44Z")

</div>

That is definitely not the normal behavior. Did you try changing the version number to see if that makes a difference? Are you uploading the plugin via UPM or running it using atlas-run?

What plugin module are you using?

---

<div class="post-metadata">

**Author:** ![Mikola](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/mikola/32/521_2.png) [@Mikola](https://community.developer.atlassian.com/u/Mikola)\
**Post date:** [April 20, 2017, 10:20am UTC](https://community.developer.atlassian.com/t/jira-plugin-cache-problem/2717/3 "2017-04-20T10:20:26Z")

</div>

Yes, I’ve tried changing the version number.  
I’m uploading it with UPM, through the admin panel  
I don’t use any plugin module.

---

<div class="post-metadata">

**Author:** ![jobinkk](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/jobinkk/32/526_2.png) [@jobinkk](https://community.developer.atlassian.com/u/jobinkk)\
**Post date:** [April 20, 2017, 2:45pm UTC](https://community.developer.atlassian.com/t/jira-plugin-cache-problem/2717/4 "2017-04-20T14:45:22Z")

</div>

Not sure what the issue is. Could be due to some bug in the UPM version you are using. Never seen this one before.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/daniel/32/35798_2.png) [@daniel](https://community.developer.atlassian.com/u/daniel)\
**Post date:** [April 20, 2017, 4:32pm UTC](https://community.developer.atlassian.com/t/jira-plugin-cache-problem/2717/5 "2017-04-20T16:32:31Z")

</div>

Did you unsubscribe the event listener using the onStop(from SAL’s LifecycleAware) or destroy() (from Spring DisposableBean ) methods?

---

<div class="post-metadata">

**Author:** ![Mikola](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/mikola/32/521_2.png) [@Mikola](https://community.developer.atlassian.com/u/Mikola)\
**Post date:** [April 21, 2017, 5:04am UTC](https://community.developer.atlassian.com/t/jira-plugin-cache-problem/2717/6 "2017-04-21T05:04:25Z")

</div>

Hmmm nouuuuuu. Should I? When should I do it?

---

<div class="post-metadata">

**Author:** ![david.pinn](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/david.pinn/32/36134_2.png) [@david.pinn](https://community.developer.atlassian.com/u/david.pinn)\
**Post date:** [April 21, 2017, 6:11am UTC](https://community.developer.atlassian.com/t/jira-plugin-cache-problem/2717/7 "2017-04-21T06:11:49Z")

</div>

Try something like this:

```auto
public class Foo implements InitializingBean, DisposableBean {

    private final EventPublisher eventPublisher;

    public Foo(EventPublisher eventPublisher) {
        this.eventPublisher = eventPublisher;
    }

    /** Called when the plugin has been enabled */
    @Override
    public void afterPropertiesSet() {
        eventPublisher.register(this);
    }

    /** Called when the plugin is being disabled or removed */
    @Override
    public void destroy() throws Exception {
        eventPublisher.unregister(this);
    }

    @EventListener
    public void onBlah(BlahEvent event) {
        ...
    }
}

```

…and don’t forget to register the class as a component in your `atlassian-plugin.xml` file:

```auto
<component key="myFoo" class="com.example.Foo" />

```

… oh, and also import the `EventPublisher` component:

```auto
    <component-import key="eventPublisher"
        interface="com.atlassian.event.api.EventPublisher" />

```

---

<div class="post-metadata">

**Author:** ![Mikola](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/mikola/32/521_2.png) [@Mikola](https://community.developer.atlassian.com/u/Mikola)\
**Post date:** [April 28, 2017, 8:13am UTC](https://community.developer.atlassian.com/t/jira-plugin-cache-problem/2717/8 "2017-04-28T08:13:27Z")

</div>

> [@david.pinn](#):
>
> …and don’t forget to register the class as a component in your atlassian-plugin.xml file:
> 
> \<component key=“myFoo” class=“com.example.Foo” /\>
> 
> … oh, and also import the EventPublisher component:
> 
> ```
> &lt;component-import key="eventPublisher"
> interface="com.atlassian.event.api.EventPublisher" /&gt;
> 
> ```

In fact, I don’t do this as per the documentation for the latest SDK. The spring scanner.takes care of it automatically. I use the combination of @ComponentImport and @Autowired annotations to achieve this.
