Fixed cleanup of propagated SshScopes

The RequestScopePropagator handles RequestCleanup independently of
the original context. However, SshScope.Context.subContext() was
chaining the cleanup in the parent. This would cause an exception
if the parent scope happened to finish before the sub-context. Since
cleanup is already handled correctly by the RequestScopePropagator,
don't register the continued contect with the original context cleanup.

Change-Id: Ie508d1921050887b95dd18bc5806c17e4894391f
Catch all exceptions when async emailing.

Updated the asynchronous emailing code to catch Exception.

Also, cleaned up some method signatures that had throws declarations for
exceptions that were never thrown.

Change-Id: I7525852b3672e07f7878f81c98cb7fc24ae4797b
Fix lockup of '/COMMIT_MSG' file from patch set

For some changes Gerrit is wrongly showing "No differences" as diff for the
commit message. If this happens the reviewers are unable to comment on the
commit message.

The files in the patch set are lexicographically sorted, but the commit
message is always the first entry. Accessing a file from the patch set by
name assumes that all files in the patch set are lexicographically sorted.
This is normally true since the file for the commit message '/COMMIT_MSG'
comes because of its leading '/' lexicographically before most other files.
However there are files which come lexicographically even before '/', e.g.
all files starting with '.', like '.gitignore'. If such a file is contained
in the patch set accessing the commit message file from the patch set fails.
As result Gerrit thinks that the commit message does not exist and shows the
"No Differences" message on the patch screen.

This change fixes the lookup of the commit message file from the patch set.
If the commit message file is requested, simply the first file from the
patch set is returned as we know that the first entry is always the commit
message file.

Change-Id: I7168b3152ef63586e9ee68cd6abcdc9f77787444
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
Use AtomicBoolean for "logged" in CommandFactoryProvider.

This simplifies the synchronization logic for the log method in
CommandFactoryProvider.

Change-Id: Ifdae88ec3b72a18eb9529f7f27f012bbb88ea2b9
Fix deadlock on destroy of CommandFactoryProvider.

A deadlock can occur when:
1) the CommandFactoryProvider is running in a thread from the
   startExecutor. It holds the this lock while running.
2) CommandFactoryProvider.destroy is called from the network thread,
   and blocks on the this lock. It also holds the network io lock.
3) The CommandFactoryProvider attempts to do io and blocks on the lock.

Fix the problem by offloading the destroy into thread in the
startExecutor.

Bug: Issue 1162
Change-Id: Iaa8658bd937a671ac0714c029ed6b7baa4637a4b
Merge "Fixed cleanup of propagated SshScopes" into stable-2.4
Merge "Fix lockup of '/COMMIT_MSG' file from patch set" into stable-2.4
Merge changes Iaa8658bd,Ifdae88ec into stable-2.4

* changes:
  Fix deadlock on destroy of CommandFactoryProvider.
  Use AtomicBoolean for "logged" in CommandFactoryProvider.
Honor the sendmail.smtpUser from gerrit.config on upgrade

If a review site was already existing when the "init" was run but
sendmail.smtpUser was not defined then "init" would set
sendmail.smtpUser to the username of the user running the init. This
would make gerrit use smtp authentication where, before upgrade, smtp
authentication wasn't used.

Instead of doing that, we now honor the value of sendmail.smtpUser from
gerrit.config even when it is null (not present in gerrit.config) in
order to ensure the same behavior of smtp authentication as before
upgrade.

Change-Id: I1b241484ae1d9b5ded7eaf97dbe5dd5cbe10eaf0
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
Export the universal version of GroupBackend to plugins

Plugins like replication need to be able to see GroupBackend as bound
to UniversalGroupBackend. This was being filtered out of the inherited
Injector because DynamicSet<GroupBackend> was declared, and the
members of that set are not provided to plugins.

Change-Id: I78e57aaa2de52424d8a7abbaa6c1158032a9edab
Do not execute rejected commands

If a command has already been rejected by prior processing,
do not invoke its execute() method.

Bug: issue 1420
Change-Id: I044d2ceba05f0765e28e3130ed9d58c9c107c852
Merge branch 'stable-2.4'

By Colby Ranger (4) and others
via gerrit code review (3) and Shawn O. Pearce (1)
* stable-2.4:
  Do not execute rejected commands
  Honor the sendmail.smtpUser from gerrit.config on upgrade
  Fix deadlock on destroy of CommandFactoryProvider.
  Use AtomicBoolean for "logged" in CommandFactoryProvider.
  Fix lockup of '/COMMIT_MSG' file from patch set
  Catch all exceptions when async emailing.
  Fixed cleanup of propagated SshScopes

Conflicts:
	gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java
	gerrit-sshd/src/main/java/com/google/gerrit/sshd/CommandFactoryProvider.java
	gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshScope.java

Change-Id: Ia67f33ee5bd8a33917221df5cf9c8287913bd99c
Don't hyperlink non-internal groups

When an external group (such as LDAP) is used in a permission rule,
don't attempt to link to the group in the internal account system UI.
The group won't load successfully. Instead just display the name and
put the UUID into a tooltip to show the full DN.

Change-Id: I8fbb67a36da5d5fcb69b4f90bfedbc2638896886