NOTE: This bug report is for JIRA Server. Using JIRA Cloud? See the corresponding bug report.

      Regarding the default/internal MailListener, the documentation states:

      This listener is usually always turned on in JIRA - see Email Notifications for more details. If you want to write more complex or more specific notifications, you can disable the internal MailListener and add your own.

      However, as the MailListener is marked as 'internal', it is not possible to be remove it.

      At present, it is necessary to recompile the MailListener class and set isInternal to false.

      Need to allow users to delete/remove the MailListener through UI.

            [JRASERVER-19957] Unable to delete the default/internal MailListener

            Of course yes, but nothing prevent you for deletion this standard listener at startup.

            Denis Sheluhanov added a comment - Of course yes, but nothing prevent you for deletion this standard listener at startup.

            Matt Doar added a comment -

            Right, but when you restart Jira I think the DefaultMailListener is recreated if it is not present?

            Matt Doar added a comment - Right, but when you restart Jira I think the DefaultMailListener is recreated if it is not present?

            Sure, https://docs.atlassian.com/software/jira/docs/api/7.2.2/com/atlassian/jira/event/ListenerManager.html#deleteListener-java.lang.Class-

            And in your listener:
            @Override
            public void init(Map params)

            { ListenerManager listenerManager = ComponentAccessor.getComponent(ListenerManager.class); listenerManager.deleteListener(MailListener.class); }

            Denis Sheluhanov added a comment - Sure,  https://docs.atlassian.com/software/jira/docs/api/7.2.2/com/atlassian/jira/event/ListenerManager.html#deleteListener-java.lang.Class- And in your listener: @Override public void init(Map params) { ListenerManager listenerManager = ComponentAccessor.getComponent(ListenerManager.class); listenerManager.deleteListener(MailListener.class); }

            Matt Doar added a comment -

            But can you delete the DefaultMailListener?

            Matt Doar added a comment - But can you delete the DefaultMailListener?

            Denis Sheluhanov added a comment - - edited

            Maybe it is time to close this issue as there is now com.atlassian.jira.event.ListenerManager#deleteListener

            Denis Sheluhanov added a comment - - edited Maybe it is time to close this issue as there is now com.atlassian.jira.event.ListenerManager#deleteListener

            Um, for what its worth, I approached this by (a) getting the project to remove its reference to the notification scheme, (b) using my own issue listener, hooked up to the users re-selection of said notification scheme through my plugin. As JIRA is not aware, the result is the same.

            Andy Brook (Javahollic Software) added a comment - Um, for what its worth, I approached this by (a) getting the project to remove its reference to the notification scheme, (b) using my own issue listener, hooked up to the users re-selection of said notification scheme through my plugin. As JIRA is not aware, the result is the same.

            MattS added a comment - - edited

            I don't think this is going to happen. It might one day if JIRA PMs revisited the whole mail infrastructure in JIRA - some projects need best-effort, immediate notification (think IM, SMS). Others need reliable email. Both need ways to reduce the number of notifications people get. I see a lot of filtering of JIRA messages out there.

            MattS added a comment - - edited I don't think this is going to happen. It might one day if JIRA PMs revisited the whole mail infrastructure in JIRA - some projects need best-effort, immediate notification (think IM, SMS). Others need reliable email. Both need ways to reduce the number of notifications people get. I see a lot of filtering of JIRA messages out there.

            Hmm, 4.4 EAP? seeing as not in 4.4, maybe 4.5? fingers crossed, again.

            Andy Brook (Javahollic Software) added a comment - - edited Hmm, 4.4 EAP? seeing as not in 4.4, maybe 4.5? fingers crossed, again.

            MattS added a comment -

            I'm upgrading a customer and one of their custom plugins needs this. I'm providing a patched system class to avoid it, which isn't very good practice.

            MattS added a comment - I'm upgrading a customer and one of their custom plugins needs this. I'm providing a patched system class to avoid it, which isn't very good practice.

            If this isn't going to be addressed, could the documentation at least be updated so as not to get our hopes up?

            Tim Kannenberg added a comment - If this isn't going to be addressed, could the documentation at least be updated so as not to get our hopes up?

            Just making ConsistencyCheckImpl not check isn't the only thing that needs doing. Some part of the install process would need to do the initial setup of listener. Subsequent deletion (and somehow notifying the admin of this) could be handled a bunch of ways. Fingers crossed for 4.2.1

            Andy Brook (Javahollic Software) added a comment - - edited Just making ConsistencyCheckImpl not check isn't the only thing that needs doing. Some part of the install process would need to do the initial setup of listener. Subsequent deletion (and somehow notifying the admin of this) could be handled a bunch of ways. Fingers crossed for 4.2.1

            MattS added a comment - - edited

            Technically, this issue's summary should read "Unable to stop JIRA recreating the default/internal Mail Listener", since it can be deleted via a URL. It would be worth checking whether that last assumption is still true in 4.2.

            MattS added a comment - - edited Technically, this issue's summary should read "Unable to stop JIRA recreating the default/internal Mail Listener", since it can be deleted via a URL. It would be worth checking whether that last assumption is still true in 4.2.

            So, not in 4.2, bah. 4.2.1? please?

            Andy Brook (Javahollic Software) added a comment - So, not in 4.2, bah. 4.2.1? please?

            MattS added a comment -

            It's a right pain to do custom mail listeners with this problem in existence.

            MattS added a comment - It's a right pain to do custom mail listeners with this problem in existence.

            Fix for 4.1.x still? Jira 4.2 imminent, any comment on when this may be done?

            Andy Brook (Javahollic Software) added a comment - Fix for 4.1.x still? Jira 4.2 imminent, any comment on when this may be done?

            Darn. Unassigned... that'll be /dev/null

            Yea +1 to this, In order to install JIRA Notification Digester I have to give people pre-modified classes, all because users might delete one listener? Surely it would be fine if it was a 'built-in' listener that could be re-added if they deleted it in a fit of pique!? how many other features are hard wired in case of 'senior moments'? Given plugins etc, I can't see the case for not enabling this listener to be removed by system admins if they so require.

            Sigh, back to the auto-patching SED script :[

            Andy Brook (Javahollic Software) added a comment - Darn. Unassigned... that'll be /dev/null Yea +1 to this, In order to install JIRA Notification Digester I have to give people pre-modified classes, all because users might delete one listener? Surely it would be fine if it was a 'built-in' listener that could be re-added if they deleted it in a fit of pique!? how many other features are hard wired in case of 'senior moments'? Given plugins etc, I can't see the case for not enabling this listener to be removed by system admins if they so require. Sigh, back to the auto-patching SED script :[

            MattS added a comment -

            I want to have a custom class for the Mail Listener to handle conditional notifications. I can prevent duplicate emails after adding my custom listener by deleting the system Mail listener with a URL such as: http://jira/secure/admin/jira/ViewListeners.jspa?delete=10001
            I find the id for the system Mail Listener in an XML backup file or in the database listenersconfig table. That all works fine but then the ConsistencyCheckImpl class goes and readds the Mail Listener the next time JIRA restarts. Sigh. I guess the quickest change to allow this behaviour to be disabled would probably be to add a property to jira-application.properties or -Djira.option.recreatemaillistener and change ConsistencyCheckImpl thus:

                private void checkMailListenerAndService() throws Exception
                {
                    if ("true".equals((ManagerFactory.getApplicationProperties()).getString(APKeys.JIRA_OPTION_RECREATEMAILLISTENER)))
                    {
                        ensureSingleListener("com.atlassian.jira.event.listeners.mail.MailListener", "Mail Listener");
                    }
                    ensureSingleService("com.atlassian.jira.service.services.mail.MailQueueService", "Mail Queue Service");
                }
            

            I can't see any other way to stop this happening other than recompiling MailListener.java which is a bigger pain to maintain over upgrades.

            I cloned this issue rom JRA-8743 since it's the same idea.

            ~Matt

            MattS added a comment - I want to have a custom class for the Mail Listener to handle conditional notifications. I can prevent duplicate emails after adding my custom listener by deleting the system Mail listener with a URL such as: http://jira/secure/admin/jira/ViewListeners.jspa?delete=10001 I find the id for the system Mail Listener in an XML backup file or in the database listenersconfig table. That all works fine but then the ConsistencyCheckImpl class goes and readds the Mail Listener the next time JIRA restarts. Sigh. I guess the quickest change to allow this behaviour to be disabled would probably be to add a property to jira-application.properties or -Djira.option.recreatemaillistener and change ConsistencyCheckImpl thus: private void checkMailListenerAndService() throws Exception { if ("true".equals((ManagerFactory.getApplicationProperties()).getString(APKeys.JIRA_OPTION_RECREATEMAILLISTENER))) { ensureSingleListener("com.atlassian.jira.event.listeners.mail.MailListener", "Mail Listener"); } ensureSingleService("com.atlassian.jira.service.services.mail.MailQueueService", "Mail Queue Service"); } I can't see any other way to stop this happening other than recompiling MailListener.java which is a bigger pain to maintain over upgrades. I cloned this issue rom JRA-8743 since it's the same idea. ~Matt

              Unassigned Unassigned
              73d805a2526b MattS
              Affected customers:
              43 This affects my team
              Watchers:
              32 Start watching this issue

                Created:
                Updated: