Yeah, I could see that v2.1 could switch to Java 7... Gary
On Tue, May 20, 2014 at 11:13 PM, Matt Sicker <[email protected]> wrote: > I'd be for it, too, but not for 2.0. Maybe a later release? At my work, > we're stuck with 1.6 for some things, but I've pushed hard to stay up to > date with some new things. Once Karaf gets all its dependencies in order > for Java 1.8, I'm forcing that through as well. Feels good, man. > > > On 20 May 2014 22:09, Gary Gregory <[email protected]> wrote: > >> Java 7 keeps creeping in here and there. I'm all for making Java 7 the >> required platform... I'm probably in the minority... >> >> Gary >> >> ---------- Forwarded message ---------- >> From: <[email protected]> >> Date: Tue, May 20, 2014 at 11:00 PM >> Subject: svn commit: r1596446 - >> /logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/ThreadContext.java >> To: [email protected] >> >> >> Author: mattsicker >> Date: Wed May 21 03:00:17 2014 >> New Revision: 1596446 >> >> URL: http://svn.apache.org/r1596446 >> Log: >> Add empty iterator implementation (yay 1.7) along with some warning >> suppression (it's ok to share immutable collection classes as public >> fields). >> >> Modified: >> >> logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/ThreadContext.java >> >> Modified: >> logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/ThreadContext.java >> URL: >> http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/ThreadContext.java?rev=1596446&r1=1596445&r2=1596446&view=diff >> >> ============================================================================== >> --- >> logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/ThreadContext.java >> (original) >> +++ >> logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/ThreadContext.java >> Wed May 21 03:00:17 2014 >> @@ -24,6 +24,7 @@ import java.util.Collections; >> import java.util.Iterator; >> import java.util.List; >> import java.util.Map; >> +import java.util.NoSuchElementException; >> >> import org.apache.logging.log4j.message.ParameterizedMessage; >> import org.apache.logging.log4j.spi.DefaultThreadContextMap; >> @@ -52,6 +53,8 @@ public final class ThreadContext { >> >> private static final long serialVersionUID = 1L; >> >> + private static final Iterator<String> EMPTY_ITERATOR = new >> EmptyIterator<String>(); >> + >> @Override >> public String pop() { >> return null; >> @@ -131,8 +134,7 @@ public final class ThreadContext { >> >> @Override >> public Iterator<String> iterator() { >> - List<String> empty = Collections.emptyList(); >> - return empty.iterator(); >> + return EMPTY_ITERATOR; >> } >> >> @Override >> @@ -143,13 +145,37 @@ public final class ThreadContext { >> } >> >> /** >> + * An empty iterator. Since Java 1.7 added the >> Collections.emptyIterator() method, we have to make do. >> + * @param <E> the type of the empty iterator >> + */ >> + private static class EmptyIterator<E> implements Iterator<E> { >> + >> + @Override >> + public boolean hasNext() { >> + return false; >> + } >> + >> + @Override >> + public E next() { >> + throw new NoSuchElementException("This is an empty >> iterator!"); >> + } >> + >> + @Override >> + public void remove() { >> + // no-op >> + } >> + } >> + >> + /** >> * Empty, immutable Map. >> */ >> + @SuppressWarnings("PublicStaticCollectionField") >> public static final Map<String, String> EMPTY_MAP = >> Collections.emptyMap(); >> >> /** >> * Empty, immutable ContextStack. >> */ >> + @SuppressWarnings("PublicStaticCollectionField") >> public static final ThreadContextStack EMPTY_STACK = new >> EmptyThreadContextStack(); >> >> private static final String DISABLE_MAP = "disableThreadContextMap"; >> @@ -334,7 +360,7 @@ public final class ThreadContext { >> * @param stack The stack to use. >> */ >> public static void setStack(final Collection<String> stack) { >> - if (stack.size() == 0 || !useStack) { >> + if (stack.isEmpty() || !useStack) { >> return; >> } >> contextStack.clear(); >> >> >> >> >> >> -- >> E-Mail: [email protected] | [email protected] >> Java Persistence with Hibernate, Second >> Edition<http://www.manning.com/bauer3/> >> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> >> Spring Batch in Action <http://www.manning.com/templier/> >> Blog: http://garygregory.wordpress.com >> Home: http://garygregory.com/ >> Tweet! http://twitter.com/GaryGregory >> > > > > -- > Matt Sicker <[email protected]> > -- E-Mail: [email protected] | [email protected] Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> Spring Batch in Action <http://www.manning.com/templier/> Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
