From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: Re: [EGIT PATCH 2/5] quickdiff - Don't add GitDocument as repository listener more than once
Date: Sun, 5 Apr 2009 13:24:00 -0700 [thread overview]
Message-ID: <20090405202400.GO23521@spearce.org> (raw)
In-Reply-To: <1238697991-12990-3-git-send-email-robin.rosenberg@dewire.com>
Robin Rosenberg <robin.rosenberg@dewire.com> wrote:
> Doing so was very costly and led to sessions being locked
> for a long time while refreshing the reference document used
> by Eclipse's quickdiff feature.
...
> --- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
> @@ -1132,6 +1132,7 @@ public File getWorkDir() {
> * @param l
> */
> public void addRepositoryChangedListener(final RepositoryListener l) {
> + assert !listeners.contains(l);
> listeners.add(l);
> }
>
> @@ -1150,6 +1151,7 @@ public void removeRepositoryChangedListener(final RepositoryListener l) {
> * @param l
> */
> public static void addAnyRepositoryChangedListener(final RepositoryListener l) {
> + assert !allListeners.contains(l);
> allListeners.add(l);
> }
That's a race condition. The two collections are Vectors so another
thread can add the listener between your assertion point and the
add call.
Also, if this really is considered to be very bad behavior on the
part of the application, maybe these should be real tests with
exceptions thrown, so they can't be disabled when assertions are
turned off in the JRE?
--
Shawn.
next prev parent reply other threads:[~2009-04-05 20:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-02 18:46 [EGIT PATCH 0/5] Quickdiff improvements Robin Rosenberg
2009-04-02 18:46 ` [EGIT PATCH 1/5] Make the equals method work for AnyObjectId, not just ObjectId Robin Rosenberg
2009-04-02 18:46 ` [EGIT PATCH 2/5] quickdiff - Don't add GitDocument as repository listener more than once Robin Rosenberg
2009-04-02 18:46 ` [EGIT PATCH 3/5] Move dcocument to repository mapping to GitDocument Robin Rosenberg
2009-04-02 18:46 ` [EGIT PATCH 4/5] Update Quickdiff tracing statements Robin Rosenberg
2009-04-02 18:46 ` [EGIT PATCH 5/5] Cache resolved ids in quickdiff document for faster update Robin Rosenberg
2009-04-05 20:36 ` Shawn O. Pearce
2009-04-05 21:40 ` Robin Rosenberg
2009-04-05 21:43 ` Shawn O. Pearce
2009-04-05 20:24 ` Shawn O. Pearce [this message]
2009-04-05 21:41 ` [EGIT PATCH 2/5] quickdiff - Don't add GitDocument as repository listener more than once Robin Rosenberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090405202400.GO23521@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg@dewire.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).