Issue 2106: Plugins: LifecycleListener's start() and stop() are called twice
Status:  New
Owner: ----
Project Member Reported by david.pu...@sonymobile.com, Sep 5, 2013
************************************************************
***** NOTE: THIS BUG TRACKER IS FOR GERRIT CODE REVIEW *****
***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, INTERNAL *****
***** ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC.    *****
***** THOSE ISSUE BELONG IN DIFFERENT ISSUE TRACKERS!  *****
************************************************************

Affected Version: master

What steps will reproduce the problem?
1. Make a plugin implement LifecycleListener
2. Output something to the error log in the start() and stop() methods
3.

What is the expected output? What do you see instead?

Expected behaviour: start() and stop() are called once when the server starts and shuts down, respectively.

Actual behaviour: start() and stop() are called twice.

Please provide any additional information below.

See the log output from testing with [1].

 [2013-09-05 18:13:18,051] ERROR com.googlesource.gerrit.plugins.validators.CommitMessageLengthValidation : commit validation plugin start
 [2013-09-05 18:13:18,051] ERROR com.googlesource.gerrit.plugins.validators.CommitMessageLengthValidation : commit validation plugin start
 [2013-09-05 18:13:18,052] INFO  com.google.gerrit.server.plugins.PluginLoader : Loaded plugin commit-message-length-validator

 [2013-09-05 18:13:40,600] INFO  com.google.gerrit.server.plugins.PluginLoader : Unloading plugin commit-message-length-validator
 [2013-09-05 18:13:40,600] ERROR com.googlesource.gerrit.plugins.validators.CommitMessageLengthValidation : commit validation plugin stop
 [2013-09-05 18:13:40,600] ERROR com.googlesource.gerrit.plugins.validators.CommitMessageLengthValidation : commit validation plugin stop

[1] https://gerrit-review.googlesource.com/#/c/49505/1

Sep 5, 2013
Project Member #1 edwin.ke...@gmail.com
I believe this only happens if the plugin provides both, an SSH Module and an HTTP Module.

It also prints out the following warning when creating the plugin HTTP injector:
"WARNING: Multiple Servlet injectors detected. This is a warning indicating that you have more than one GuiceFilter running in your web application. If this is deliberate, you may safely ignore this message. If this is NOT deliberate however, your application may not work as expected."
Sep 6, 2013
Project Member #2 david.pu...@sonymobile.com
I'm not sure if that's right.  I don't have the code in front of me right now, but as far as I remember the commit message check plugin does not provide either http or ssh module.
Nov 13, 2013
Project Member #3 huga...@gmail.com
David is right, I created an empty plugin without any module and only a LifecycleListener and the start/stop were called twice.

Start/stop are only called twice when the LifecycleListener is automatically registered using the @Listen annotation.

To work-around the issue: I created a LifecycleModule to explicitly register my LifecycleListener using the following line:
listener().to(YourLifecycleListener.class);