Re: [EGIT PATCH 5/7] Add a method to get refs by object Id

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robin Rosenberg <robin.rosenberg@xxxxxxxxxx> wrote:
> @@ -952,6 +955,37 @@ public Ref peel(final Ref ref) {
>  	}
>  
>  	/**
> +	 * @return a map with all objects referenced by a peeled ref.
> +	 */
> +	public Map<AnyObjectId, Set<Ref>> getAllRefsByPeeledObjectId() {
> +		Map<String, Ref> allRefs = getAllRefs();
> +		Map<AnyObjectId, Set<Ref>> ret = new HashMap<AnyObjectId, Set<Ref>>(allRefs.size());
> +		for (Ref ref : allRefs.values()) {
> +			if (ref == null)
> +				continue;

How did we get a null Ref inside the allRefs collection?

> +			if (!ref.isPeeled()) {
> +				ref = peel(ref);
> +				allRefs.put(ref.getOrigName(), ref);

Hmm.  Mutating a HashMap while you are traversing it with an Iterator
is *not* a good idea.  Its a ConcurrentModificationException waiting
to happen.

-- 
Shawn.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux