diff options
author | Martin Fick <mfick@codeaurora.org> | 2012-05-31 10:02:43 -0700 |
---|---|---|
committer | gerrit code review <noreply-gerritcodereview@google.com> | 2012-05-31 10:02:44 -0700 |
commit | 0cd7d1e23f5e68407789d913657ad245b5d50417 (patch) | |
tree | 70ca705416e77462ddad1b4fd1f398e85d343b45 | |
parent | 4a3bd6d5749b6de8d52214e5d9dff74fa31b13cc (diff) | |
parent | 4d741c29e5e1446091c57937edb89a6faf2aabb7 (diff) |
Merge "Fixed cleanup of propagated SshScopes" into stable-2.4
-rw-r--r-- | gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshScope.java | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshScope.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshScope.java index f923d80fb0..92609b5235 100644 --- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshScope.java +++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshScope.java @@ -39,7 +39,7 @@ class SshScope { volatile long started; volatile long finished; - Context(final SshSession s, final String c) { + private Context(final SshSession s, final String c, final long at) { cleanup = new RequestCleanup(); session = s; commandLine = c; @@ -47,25 +47,17 @@ class SshScope { map = new HashMap<Key<?>, Object>(); map.put(RC_KEY, cleanup); - final long now = System.currentTimeMillis(); - created = now; - started = now; - finished = now; + created = started = finished = at; } private Context(Context p, SshSession s, String c) { - cleanup = new RequestCleanup(); - session = s; - commandLine = c; - - map = new HashMap<Key<?>, Object>(); - map.put(RC_KEY, cleanup); - - created = p.created; + this(s, c, p.created); started = p.started; finished = p.finished; + } - p.cleanup.add(cleanup); + Context(final SshSession s, final String c) { + this(s, c, System.currentTimeMillis()); } String getCommandLine() { @@ -87,7 +79,9 @@ class SshScope { } synchronized Context subContext(SshSession newSession, String newCommandLine) { - return new Context(this, newSession, newCommandLine); + Context ctx = new Context(this, newSession, newCommandLine); + cleanup.add(ctx.cleanup); + return ctx; } } @@ -112,7 +106,9 @@ class SshScope { @Override protected Context continuingContext(Context ctx) { - return ctx.subContext(ctx.getSession(), ctx.getCommandLine()); + // The cleanup is not chained, since the RequestScopePropagator executors + // the Context's cleanup when finished executing. + return new Context(ctx, ctx.getSession(), ctx.getCommandLine()); } } |