Move listing on startup to prevent exception

With the recent reorganization of Application for Daemon's benefit,
Application.testFastShutdownWhenStarting started being flaky; the
checkAndScheduleImmediatePushOfDocIds in Application.start() sometimes
throws a RejectedExecutionException. This is because of a race with
stop().

This race with stop() has actually been around for a long time, but was
only present when using Application.main(). The race itself isn't
serious, since everything basically continues running as expected
(stopped), but it would be confusing for a user who cancels startup
because an Adaptor keeps throwing an exception in init().

As a fix, we moved the checkAndScheduleImmediatePushOfDocIds from
Application into GsaCommunicationHandler so that it is synchronized with
the rest of start() and there is no longer a race. This is probably what
we should have been doing from the beginning because there is no reason
to do it in Application instead of GsaCommunicationHandler, but the
decision was less obvious when written.
2 files changed