]> source.dussan.org Git - jgit.git/commit
Revive Repository#notifyIndexChanged() 70/122970/1
authorJonathan Nieder <jrn@google.com>
Fri, 18 May 2018 16:15:30 +0000 (09:15 -0700)
committerJonathan Nieder <jrn@google.com>
Fri, 18 May 2018 16:15:30 +0000 (09:15 -0700)
commitca79b3d4af748c626d2b35d7404ef49983dfe917
tree143cf2809f26fb6e033dd965b0e69cfd60864b2f
parent667e30678a6bad26f4d4d412e996b293e52e5b87
Revive Repository#notifyIndexChanged()

e9e150fdd24d (Store in IndexChangedEvent if it was caused by JGit
itself, 2018-05-13) modified Repository#notifyIndexChanged to take a
boolean argument to indicate whether the index change happened under
the current process's control or externally, for use by EGit.  In
other words, the function signature changed from

public abstract void notifyIndexChanged();

to

public abstract void notifyIndexChanged(boolean internal);

Callers outside JGit itself notifying a Repository about index changes
are expected to be rare, so this is not very disruptive to them.  In
most cases they would be notifying about changes that they made
themselves, so treating their notifyIndexChanged() calls as
notifyIndexChanged(true) should be relatively safe.

Implementors have the opposite problem: adding the new "abstract void
notifyIndexChanged(boolean)" method means they are obligated to
override it.  Add a default implementation that calls their existing
override of notifyIndexChanged() to make their migration easier.

The main downside is that authors of new Repository subclasses that
do not realize they need to override notifyIndexChanged would end up
with a default implementation which calls notifyIndexChanged(true),
in turn calling notifyIndexChanged() again and so on, resulting in
StackOverflowException.  Add an implementors' note to the class
Javadoc to avoid this issue.  A followup commit will force
implementors to adapt to the new API by changing the methods to

@Deprecated
public final void notifyIndexChanged() {
notifyIndexChanged(true);
}

public abstract void notifyIndexChanged(boolean internal);

Change-Id: I7d014890ee19abf283ea824d9baa9044bfdde130
Signed-off-by: Jonathan Nieder <jrn@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java