From 80b7a49904d0abac6e7b86844a98e1c54c130bfc Mon Sep 17 00:00:00 2001 From: Richard Mortimer Date: Fri, 16 Nov 2012 21:18:00 +0000 Subject: [PATCH 01/13] Add Iterators#wrap() to allow hiding of Iterable class implementation details --- core/src/main/java/hudson/util/Iterators.java | 30 +++++++++++++++++-- .../test/java/hudson/util/IteratorsTest.java | 15 ++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/util/Iterators.java b/core/src/main/java/hudson/util/Iterators.java index 1a33bef083..2b5d88f74b 100644 --- a/core/src/main/java/hudson/util/Iterators.java +++ b/core/src/main/java/hudson/util/Iterators.java @@ -23,11 +23,8 @@ */ package hudson.util; -import com.google.common.base.Objects; -import com.google.common.base.Predicate; import com.google.common.base.Predicates; -import javax.annotation.Nullable; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -188,6 +185,33 @@ public class Iterators { }; } + /** + * Returns an {@link Iterable} that lists items in the normal order + * but which hides the base iterator implementation details. + * + * @since 1.492 + */ + public static Iterable wrap(final Iterable base) { + return new Iterable() { + public Iterator iterator() { + final Iterator itr = base.iterator(); + return new Iterator() { + public boolean hasNext() { + return itr.hasNext(); + } + + public T next() { + return itr.next(); + } + + public void remove() { + itr.remove(); + } + }; + } + }; + } + /** * Returns a list that represents [start,end). * diff --git a/core/src/test/java/hudson/util/IteratorsTest.java b/core/src/test/java/hudson/util/IteratorsTest.java index ec0a518f38..5c6df4f4c1 100644 --- a/core/src/test/java/hudson/util/IteratorsTest.java +++ b/core/src/test/java/hudson/util/IteratorsTest.java @@ -26,6 +26,7 @@ package hudson.util; import hudson.util.Iterators.CountingPredicate; import junit.framework.TestCase; +import java.util.Iterator; import java.util.List; import static java.util.Arrays.*; @@ -51,6 +52,20 @@ public class IteratorsTest extends TestCase { assertEquals(3, lst.size()); } + public void testWrap() { + List lst = Iterators.sequence(1,4); + Iterable wrapped = Iterators.wrap(lst); + assertFalse(wrapped instanceof List); + Iterator iter = wrapped.iterator(); + assertTrue(iter.hasNext()); + assertEquals(1,(int)iter.next()); + assertTrue(iter.hasNext()); + assertEquals(2,(int)iter.next()); + assertTrue(iter.hasNext()); + assertEquals(3,(int)iter.next()); + assertFalse(iter.hasNext()); + } + public void testLimit() { assertEquals("[0]",com.google.common.collect.Iterators.toString(Iterators.limit(asList(0,1,2,3,4).iterator(), EVEN))); assertEquals("[]", com.google.common.collect.Iterators.toString(Iterators.limit(asList(1,2,4,6).iterator(), EVEN))); From e429b6979b5d736bbbb1168a743c9e32801e2a9b Mon Sep 17 00:00:00 2001 From: Richard Mortimer Date: Fri, 16 Nov 2012 21:33:34 +0000 Subject: [PATCH 02/13] [FIXED JENKINS-15499] HistoryWidget/entry.jelly throws NullPointerException Wrap history iterable to hide class implementation details. Jelly was getting confused by the history underlying class being implemented as an extension of Map --- changelog.html | 3 +++ core/src/main/java/hudson/widgets/HistoryWidget.java | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/changelog.html b/changelog.html index d254fbd756..decbd9d25f 100644 --- a/changelog.html +++ b/changelog.html @@ -63,6 +63,9 @@ Upcoming changes

What's new in 1.490 (2012/11/12)

  • From d6ea1ccfaeee417c857fba3bb60da90210f81a0b Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 18 Nov 2012 17:59:07 -0800 Subject: [PATCH 13/13] updated changelog as a part of the release --- debian/debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/debian/changelog b/debian/debian/changelog index ea3a5a4e79..42137b523c 100644 --- a/debian/debian/changelog +++ b/debian/debian/changelog @@ -1,3 +1,9 @@ +jenkins (1.491) unstable; urgency=low + + * See http://jenkins-ci.org/changelog for more details. + + -- Kohsuke Kawaguchi Sun, 18 Nov 2012 17:42:14 -0800 + jenkins (1.490) unstable; urgency=low * See http://jenkins-ci.org/changelog for more details.