You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2017/10/26 23:22:08 UTC

[5/8] juneau git commit: Update code to reflect changes in Java 7.

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/Parser.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/Parser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/Parser.java
index 9d78570..6cf30aa 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/Parser.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/Parser.java
@@ -381,12 +381,7 @@ public abstract class Parser extends CoreObject {
 	 * @see BeanSession#getClassMeta(Type,Type...) for argument syntax for maps and collections.
 	 */
 	public final <T> T parse(Object input, Type type, Type...args) throws ParseException {
-		ParserSession session = createSession();
-		try {
-			return session.parse(input, type, args);
-		} finally {
-			session.close();
-		}
+		return createSession().parse(input, type, args);
 	}
 
 	/**
@@ -425,12 +420,7 @@ public abstract class Parser extends CoreObject {
 	 * 	If the input contains a syntax error or is malformed, or is not valid for the specified type.
 	 */
 	public final <T> T parse(Object input, Class<T> type) throws ParseException {
-		ParserSession session = createSession();
-		try {
-			return session.parse(input, type);
-		} finally {
-			session.close();
-		}
+		return createSession().parse(input, type);
 	}
 
 	/**
@@ -450,12 +440,7 @@ public abstract class Parser extends CoreObject {
 	 * 	If the input contains a syntax error or is malformed, or is not valid for the specified type.
 	 */
 	public final <T> T parse(Object input, ClassMeta<T> type) throws ParseException {
-		ParserSession session = createSession();
-		try {
-			return session.parse(input, type);
-		} finally {
-			session.close();
-		}
+		return createSession().parse(input, type);
 	}
 
 	/**
@@ -510,12 +495,7 @@ public abstract class Parser extends CoreObject {
 	 * @throws UnsupportedOperationException If not implemented.
 	 */
 	public final <K,V> Map<K,V> parseIntoMap(Object input, Map<K,V> m, Type keyType, Type valueType) throws ParseException {
-		ParserSession session = createSession();
-		try {
-			return session.parseIntoMap(input, m, keyType, valueType);
-		} finally {
-			session.close();
-		}
+		return createSession().parseIntoMap(input, m, keyType, valueType);
 	}
 
 	/**
@@ -539,12 +519,7 @@ public abstract class Parser extends CoreObject {
 	 * @throws UnsupportedOperationException If not implemented.
 	 */
 	public final <E> Collection<E> parseIntoCollection(Object input, Collection<E> c, Type elementType) throws ParseException {
-		ParserSession session = createSession();
-		try {
-			return session.parseIntoCollection(input, c, elementType);
-		} finally {
-			session.close();
-		}
+		return createSession().parseIntoCollection(input, c, elementType);
 	}
 
 	/**
@@ -571,12 +546,7 @@ public abstract class Parser extends CoreObject {
 	public final Object[] parseArgs(Object input, Type[] argTypes) throws ParseException {
 		if (argTypes == null || argTypes.length == 0)
 			return new Object[0];
-		ParserSession session = createSession();
-		try {
-			return session.parseArgs(input, argTypes);
-		} finally {
-			session.close();
-		}
+		return createSession().parseArgs(input, argTypes);
 	}
 
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserContext.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserContext.java
index 6443ec5..fe82d59 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserContext.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserContext.java
@@ -36,7 +36,6 @@ public class ParserContext extends BeanContext {
 	 *
 	 * @param ps The property store that created this context.
 	 */
-	@SuppressWarnings("unchecked")
 	public ParserContext(PropertyStore ps) {
 		super(ps);
 		this.trimStrings = ps.getProperty(PARSER_trimStrings, boolean.class, false);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserGroup.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserGroup.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserGroup.java
index d9ee830..775dbbe 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserGroup.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserGroup.java
@@ -72,7 +72,7 @@ import org.apache.juneau.http.*;
 public final class ParserGroup {
 
 	// Maps Content-Type headers to matches.
-	private final ConcurrentHashMap<String,ParserMatch> cache = new ConcurrentHashMap<String,ParserMatch>();
+	private final ConcurrentHashMap<String,ParserMatch> cache = new ConcurrentHashMap<>();
 
 	private final MediaType[] mediaTypes;            // List of media types
 	private final List<MediaType> mediaTypesList;
@@ -93,10 +93,10 @@ public final class ParserGroup {
 	 */
 	public ParserGroup(PropertyStore propertyStore, Parser[] parsers) {
 		this.propertyStore = propertyStore.copy();
-		this.parsers = Collections.unmodifiableList(new ArrayList<Parser>(Arrays.asList(parsers)));
+		this.parsers = Collections.unmodifiableList(new ArrayList<>(Arrays.asList(parsers)));
 
-		List<MediaType> lmt = new ArrayList<MediaType>();
-		List<Parser> l = new ArrayList<Parser>();
+		List<MediaType> lmt = new ArrayList<>();
+		List<Parser> l = new ArrayList<>();
 		for (Parser p : parsers) {
 			for (MediaType m: p.getMediaTypes()) {
 				lmt.add(m);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserGroupBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserGroupBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserGroupBuilder.java
index a9b6d29..cf0568e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserGroupBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserGroupBuilder.java
@@ -34,7 +34,7 @@ public class ParserGroupBuilder {
 	 * Create an empty parser group builder.
 	 */
 	public ParserGroupBuilder() {
-		this.parsers = new ArrayList<Object>();
+		this.parsers = new ArrayList<>();
 		this.propertyStore = PropertyStore.create();
 	}
 
@@ -47,7 +47,7 @@ public class ParserGroupBuilder {
 	 * @param propertyStore The property store containing all settings common to all parsers in this group.
 	 */
 	public ParserGroupBuilder(PropertyStore propertyStore) {
-		this.parsers = new ArrayList<Object>();
+		this.parsers = new ArrayList<>();
 		this.propertyStore = propertyStore;
 	}
 
@@ -57,7 +57,7 @@ public class ParserGroupBuilder {
 	 * @param copyFrom The parser group that we're copying settings and parsers from.
 	 */
 	public ParserGroupBuilder(ParserGroup copyFrom) {
-		this.parsers = new ArrayList<Object>();
+		this.parsers = new ArrayList<>();
 		addReverse(parsers, copyFrom.getParsers());
 		this.propertyStore = copyFrom.createPropertyStore();
 	}
@@ -104,7 +104,7 @@ public class ParserGroupBuilder {
 	 * @return A new {@link ParserGroup} object.
 	 */
 	public ParserGroup build() {
-		List<Parser> l = new ArrayList<Parser>();
+		List<Parser> l = new ArrayList<>();
 		for (Object p : parsers) {
 			Class<?> c = null;
 			PropertyStore ps = propertyStore;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserPipe.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserPipe.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserPipe.java
index 4faf988..f14f46e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserPipe.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserPipe.java
@@ -49,7 +49,7 @@ import org.apache.juneau.internal.*;
  * Note that Readers and InputStreams will NOT be automatically closed when {@link #close()} is called, but
  * streams and readers created from other types (e.g. Files) WILL be automatically closed.
  */
-public final class ParserPipe {
+public final class ParserPipe implements Closeable {
 
 	private final Object input;
 	private final boolean debug, strict;
@@ -265,9 +265,7 @@ public final class ParserPipe {
 		return inputString != null;
 	}
 
-	/**
-	 * Perform cleanup on this context object if necessary.
-	 */
+	@Override /* Closeable */
 	public void close() {
 		try {
 			IOUtils.close(reader, inputStream);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
index d06f857..faefe6a 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
@@ -420,11 +420,8 @@ public abstract class ParserSession extends BeanSession {
 	 */
 	@SuppressWarnings("unchecked")
 	public final <T> T parse(Object input, Type type, Type...args) throws ParseException {
-		ParserPipe pipe = createPipe(input);
-		try {
+		try (ParserPipe pipe = createPipe(input)) {
 			return (T)parseInner(pipe, getClassMeta(type, args));
-		} finally {
-			pipe.close();
 		}
 	}
 
@@ -464,11 +461,8 @@ public abstract class ParserSession extends BeanSession {
 	 * 	If the input contains a syntax error or is malformed, or is not valid for the specified type.
 	 */
 	public final <T> T parse(Object input, Class<T> type) throws ParseException {
-		ParserPipe pipe = createPipe(input);
-		try {
+		try (ParserPipe pipe = createPipe(input)) {
 			return parseInner(pipe, getClassMeta(type));
-		} finally {
-			pipe.close();
 		}
 	}
 
@@ -489,11 +483,8 @@ public abstract class ParserSession extends BeanSession {
 	 * 	If the input contains a syntax error or is malformed, or is not valid for the specified type.
 	 */
 	public final <T> T parse(Object input, ClassMeta<T> type) throws ParseException {
-		ParserPipe pipe = createPipe(input);
-		try {
+		try (ParserPipe pipe = createPipe(input)) {
 			return parseInner(pipe, type);
-		} finally {
-			pipe.close();
 		}
 	}
 
@@ -512,9 +503,9 @@ public abstract class ParserSession extends BeanSession {
 	 * 	If the input contains a syntax error or is malformed, or is not valid for the specified type.
 	 */
 	private <T> T parseInner(ParserPipe pipe, ClassMeta<T> type) throws ParseException {
+		if (type.isVoid())
+			return null;
 		try {
-			if (type.isVoid())
-				return null;
 			return doParse(pipe, type);
 		} catch (ParseException e) {
 			throw e;
@@ -526,6 +517,8 @@ public abstract class ParserSession extends BeanSession {
 		} catch (Exception e) {
 			throw new ParseException(getLastLocation(), "Exception occurred.  exception={0}, message={1}.",
 				e.getClass().getSimpleName(), e.getLocalizedMessage()).initCause(e);
+		} finally {
+			checkForWarnings();
 		}
 	}
 
@@ -554,15 +547,14 @@ public abstract class ParserSession extends BeanSession {
 	 * @throws UnsupportedOperationException If not implemented.
 	 */
 	public final <K,V> Map<K,V> parseIntoMap(Object input, Map<K,V> m, Type keyType, Type valueType) throws ParseException {
-		ParserPipe pipe = createPipe(input);
-		try {
+		try (ParserPipe pipe = createPipe(input)) {
 			return doParseIntoMap(pipe, m, keyType, valueType);
 		} catch (ParseException e) {
 			throw e;
 		} catch (Exception e) {
 			throw new ParseException(getLastLocation(), e);
 		} finally {
-			pipe.close();
+			checkForWarnings();
 		}
 	}
 
@@ -604,8 +596,7 @@ public abstract class ParserSession extends BeanSession {
 	 * @throws UnsupportedOperationException If not implemented.
 	 */
 	public final <E> Collection<E> parseIntoCollection(Object input, Collection<E> c, Type elementType) throws ParseException {
-		ParserPipe pipe = createPipe(input);
-		try {
+		try (ParserPipe pipe = createPipe(input)) {
 			return doParseIntoCollection(pipe, c, elementType);
 		} catch (ParseException e) {
 			throw e;
@@ -618,7 +609,7 @@ public abstract class ParserSession extends BeanSession {
 			throw new ParseException(getLastLocation(), "Exception occurred.  exception={0}, message={1}.",
 				e.getClass().getSimpleName(), e.getLocalizedMessage()).initCause(e);
 		} finally {
-			pipe.close();
+			checkForWarnings();
 		}
 	}
 
@@ -660,8 +651,7 @@ public abstract class ParserSession extends BeanSession {
 	 * 	If the input contains a syntax error or is malformed, or is not valid for the specified type.
 	 */
 	public final Object[] parseArgs(Object input, Type[] argTypes) throws ParseException {
-		ParserPipe pipe = createPipe(input);
-		try {
+		try (ParserPipe pipe = createPipe(input)) {
 			return doParse(pipe, getArgsClassMeta(argTypes));
 		} catch (ParseException e) {
 			throw e;
@@ -674,7 +664,7 @@ public abstract class ParserSession extends BeanSession {
 			throw new ParseException(getLastLocation(), "Exception occurred.  exception={0}, message={1}.",
 				e.getClass().getSimpleName(), e.getLocalizedMessage()).initCause(e);
 		} finally {
-			pipe.close();
+			checkForWarnings();
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/remoteable/RemoteableMeta.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/remoteable/RemoteableMeta.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/remoteable/RemoteableMeta.java
index 82a17d8..6a0954d 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/remoteable/RemoteableMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/remoteable/RemoteableMeta.java
@@ -51,7 +51,7 @@ public class RemoteableMeta {
 		if (! isOneOf(expose, "ALL", "DECLARED", "ANNOTATED"))
 			throw new RemoteableMetadataException(c, "Invalid value specified for ''expose'' annotation.  Valid values are [ALL,ANNOTATED,DECLARED].");
 
-		Map<Method,RemoteableMethodMeta> _methods = new LinkedHashMap<Method,RemoteableMethodMeta>();
+		Map<Method,RemoteableMethodMeta> _methods = new LinkedHashMap<>();
 		for (Method m : expose.equals("DECLARED") ? c.getDeclaredMethods() : c.getMethods()) {
 			if (isPublic(m)) {
 				RemoteMethod rm = c.getAnnotation(RemoteMethod.class);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/remoteable/RemoteableMethodMeta.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/remoteable/RemoteableMethodMeta.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/remoteable/RemoteableMethodMeta.java
index 3568dd5..33accd8 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/remoteable/RemoteableMethodMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/remoteable/RemoteableMethodMeta.java
@@ -65,13 +65,13 @@ public class RemoteableMethodMeta {
 	private static class Builder {
 		private String httpMethod, url;
 		private List<RemoteMethodArg>
-			pathArgs = new LinkedList<RemoteMethodArg>(),
-			queryArgs = new LinkedList<RemoteMethodArg>(),
-			headerArgs = new LinkedList<RemoteMethodArg>(),
-			formDataArgs = new LinkedList<RemoteMethodArg>(),
-			requestBeanArgs = new LinkedList<RemoteMethodArg>();
+			pathArgs = new LinkedList<>(),
+			queryArgs = new LinkedList<>(),
+			headerArgs = new LinkedList<>(),
+			formDataArgs = new LinkedList<>(),
+			requestBeanArgs = new LinkedList<>();
 		private List<Integer>
-			otherArgs = new LinkedList<Integer>();
+			otherArgs = new LinkedList<>();
 		private Integer bodyArg;
 		private ReturnValue returnValue;
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/Serializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/Serializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/Serializer.java
index 6aea5f7..3c2c380 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/Serializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/Serializer.java
@@ -479,8 +479,6 @@ public abstract class Serializer extends CoreObject {
 	 * 	contexts.
 	 * @return
 	 * 	The new session object.
-	 * 	<br>Note that you must call {@link SerializerSession#close()} on this object to perform any necessary
-	 * 	cleanup.
 	 */
 	public abstract SerializerSession createSession(SerializerSessionArgs args);
 
@@ -494,8 +492,6 @@ public abstract class Serializer extends CoreObject {
 	 *
 	 * @return
 	 * 	The new session object.
-	 * 	<br>Note that you must call {@link SerializerSession#close()} on this object to perform any necessary
-	 * 	cleanup.
 	 */
 	public final SerializerSession createSession() {
 		return createSession(createDefaultSessionArgs());
@@ -536,12 +532,7 @@ public abstract class Serializer extends CoreObject {
 	 * @throws SerializeException If a problem occurred trying to convert the output.
 	 */
 	public final void serialize(Object o, Object output) throws SerializeException {
-		SerializerSession s = createSession();
-		try {
-			s.serialize(o, output);
-		} finally {
-			s.close();
-		}
+		createSession().serialize(o, output);
 	}
 
 	/**
@@ -556,12 +547,7 @@ public abstract class Serializer extends CoreObject {
 	 * @throws SerializeException If a problem occurred trying to convert the output.
 	 */
 	public Object serialize(Object o) throws SerializeException {
-		SerializerSession s = createSession();
-		try {
-			return s.serialize(o);
-		} finally {
-			s.close();
-		}
+		return createSession().serialize(o);
 	}
 
 	//--------------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerContext.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerContext.java
index a4d35f6..8d31f4f 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerContext.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerContext.java
@@ -51,7 +51,6 @@ public class SerializerContext extends BeanContext {
 	 *
 	 * @param ps The property store that created this context.
 	 */
-	@SuppressWarnings("unchecked")
 	public SerializerContext(PropertyStore ps) {
 		super(ps);
 		maxDepth = ps.getProperty(SERIALIZER_maxDepth, int.class, 100);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerGroup.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerGroup.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerGroup.java
index 17d83f1..c8146bc 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerGroup.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerGroup.java
@@ -64,7 +64,7 @@ import org.apache.juneau.http.*;
 public final class SerializerGroup {
 
 	// Maps Accept headers to matching serializers.
-	private final ConcurrentHashMap<String,SerializerMatch> cache = new ConcurrentHashMap<String,SerializerMatch>();
+	private final ConcurrentHashMap<String,SerializerMatch> cache = new ConcurrentHashMap<>();
 
 	private final MediaType[] mediaTypes;
 	private final List<MediaType> mediaTypesList;
@@ -87,10 +87,10 @@ public final class SerializerGroup {
 	public SerializerGroup(PropertyStore propertyStore, Serializer[] serializers) {
 		this.propertyStore = propertyStore.copy();
 		this.beanContext = propertyStore.getBeanContext();
-		this.serializers = Collections.unmodifiableList(new ArrayList<Serializer>(Arrays.asList(serializers)));
+		this.serializers = Collections.unmodifiableList(new ArrayList<>(Arrays.asList(serializers)));
 
-		List<MediaType> lmt = new ArrayList<MediaType>();
-		List<Serializer> l = new ArrayList<Serializer>();
+		List<MediaType> lmt = new ArrayList<>();
+		List<Serializer> l = new ArrayList<>();
 		for (Serializer s : serializers) {
 			for (MediaType m: s.getMediaTypes()) {
 				lmt.add(m);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerGroupBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerGroupBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerGroupBuilder.java
index 77a8f3b..3c49f23 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerGroupBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerGroupBuilder.java
@@ -34,7 +34,7 @@ public class SerializerGroupBuilder {
 	 * Create an empty serializer group builder.
 	 */
 	public SerializerGroupBuilder() {
-		this.serializers = new ArrayList<Object>();
+		this.serializers = new ArrayList<>();
 		this.propertyStore = PropertyStore.create();
 	}
 
@@ -47,7 +47,7 @@ public class SerializerGroupBuilder {
 	 * @param propertyStore The property store containing all settings common to all serializers in this group.
 	 */
 	public SerializerGroupBuilder(PropertyStore propertyStore) {
-		this.serializers = new ArrayList<Object>();
+		this.serializers = new ArrayList<>();
 		this.propertyStore = propertyStore;
 	}
 
@@ -57,7 +57,7 @@ public class SerializerGroupBuilder {
 	 * @param copyFrom The serializer group that we're copying settings and serializers from.
 	 */
 	public SerializerGroupBuilder(SerializerGroup copyFrom) {
-		this.serializers = new ArrayList<Object>();
+		this.serializers = new ArrayList<>();
 		addReverse(serializers, copyFrom.getSerializers());
 		this.propertyStore = copyFrom.createPropertyStore();
 	}
@@ -104,7 +104,7 @@ public class SerializerGroupBuilder {
 	 * @return A new {@link SerializerGroup} object.
 	 */
 	public SerializerGroup build() {
-		List<Serializer> l = new ArrayList<Serializer>();
+		List<Serializer> l = new ArrayList<>();
 		for (Object s : serializers) {
 			Class<?> c = null;
 			PropertyStore ps = propertyStore;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerPipe.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerPipe.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerPipe.java
index 4a39264..87f5d48 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerPipe.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerPipe.java
@@ -38,7 +38,7 @@ import org.apache.juneau.internal.*;
  * 	<li>{@link File}
  * </ul>
  */
-public final class SerializerPipe {
+public final class SerializerPipe implements Closeable {
 
 	private final Object output;
 	private final boolean autoClose;
@@ -68,8 +68,11 @@ public final class SerializerPipe {
 	 * 	<li>{@link OutputStream}
 	 * 	<li>{@link File}
 	 * </ul>
-	 *
-	 * @return The output object wrapped in an output stream.
+	 * 
+	 * @return 
+	 * 	The output object wrapped in an output stream.
+	 * 	Calling {@link OutputStream#close()} on the returned object simply flushes the response and does not close
+	 * 	the underlying stream.
 	 * @throws IOException If object could not be converted to an output stream.
 	 */
 	public OutputStream getOutputStream() throws IOException {
@@ -83,7 +86,7 @@ public final class SerializerPipe {
 		else
 			throw new IOException("Cannot convert object of type "+output.getClass().getName()+" to an OutputStream.");
 
-		return outputStream;
+		return new NoCloseOutputStream(outputStream);
 	}
 
 
@@ -101,7 +104,10 @@ public final class SerializerPipe {
 	 * 	<li>{@link File} - Output will be written as system-default encoded stream.
 	 * </ul>
 	 *
-	 * @return The output object wrapped in a Writer.
+	 * @return 
+	 * 	The output object wrapped in a writer.
+	 * 	Calling {@link Writer#close()} on the returned object simply flushes the response and does not close
+	 * 	the underlying writer.
 	 * @throws IOException If object could not be converted to a writer.
 	 */
 	public Writer getWriter() throws IOException {
@@ -119,7 +125,7 @@ public final class SerializerPipe {
 		else
 			throw new IOException("Cannot convert object of type "+output.getClass().getName()+" to a Writer.");
 
-		return writer;
+		return new NoCloseWriter(writer);
 	}
 
 	/**
@@ -140,7 +146,7 @@ public final class SerializerPipe {
 	 *
 	 * <p>
 	 * Used when wrapping the stream returned by {@link #getOutputStream()} so that the wrapped stream will be flushed
-	 * and closed when {@link #close()} is called.
+	 * when {@link #close()} is called.
 	 *
 	 * @param outputStream The wrapped stream.
 	 */
@@ -160,6 +166,7 @@ public final class SerializerPipe {
 	/**
 	 * Closes the output pipe.
 	 */
+	@Override /* Closeable */
 	public void close() {
 		try {
 			IOUtils.flush(writer, outputStream);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
index dedb486..a6f0cf5 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java
@@ -22,6 +22,7 @@ import java.text.*;
 import java.util.*;
 
 import org.apache.juneau.*;
+import org.apache.juneau.internal.ClassUtils;
 import org.apache.juneau.parser.*;
 import org.apache.juneau.soap.*;
 import org.apache.juneau.transform.*;
@@ -65,7 +66,7 @@ public abstract class SerializerSession extends BeanSession {
 	private final UriResolver uriResolver;
 
 	private final Map<Object,Object> set;                                           // Contains the current objects in the current branch of the model.
-	private final LinkedList<StackElement> stack = new LinkedList<StackElement>();  // Contains the current objects in the current branch of the model.
+	private final LinkedList<StackElement> stack = new LinkedList<>();              // Contains the current objects in the current branch of the model.
 	private final Method javaMethod;                                                // Java method that invoked this serializer.
 
 	// Writable properties
@@ -125,7 +126,7 @@ public abstract class SerializerSession extends BeanSession {
 
 		this.indent = initialDepth;
 		if (detectRecursions || isDebug()) {
-			set = new IdentityHashMap<Object,Object>();
+			set = new IdentityHashMap<>();
 		} else {
 			set = Collections.emptyMap();
 		}
@@ -229,8 +230,7 @@ public abstract class SerializerSession extends BeanSession {
 	 * @throws SerializeException If a problem occurred trying to convert the output.
 	 */
 	public final void serialize(Object out, Object o) throws SerializeException {
-		SerializerPipe pipe = createPipe(out);
-		try {
+		try (SerializerPipe pipe = createPipe(out)) {
 			doSerialize(pipe, o);
 		} catch (SerializeException e) {
 			throw e;
@@ -240,8 +240,7 @@ public abstract class SerializerSession extends BeanSession {
 		} catch (Exception e) {
 			throw new SerializeException(this, e);
 		} finally {
-			pipe.close();
-			close();
+			checkForWarnings();
 		}
 	}
 
@@ -600,7 +599,7 @@ public abstract class SerializerSession extends BeanSession {
 	 */
 	protected final <K,V> Map<K,V> sort(Map<K,V> m) {
 		if (sortMaps && m != null && (! m.isEmpty()) && m.keySet().iterator().next() instanceof Comparable<?>)
-			return new TreeMap<K,V>(m);
+			return new TreeMap<>(m);
 		return m;
 	}
 
@@ -612,7 +611,7 @@ public abstract class SerializerSession extends BeanSession {
 	 */
 	protected final <E> Collection<E> sort(Collection<E> c) {
 		if (sortCollections && c != null && (! c.isEmpty()) && c.iterator().next() instanceof Comparable<?>)
-			return new TreeSet<E>(c);
+			return new TreeSet<>(c);
 		return c;
 	}
 
@@ -635,7 +634,7 @@ public abstract class SerializerSession extends BeanSession {
 		Class<?> componentType = type.getComponentType();
 		if (componentType.isPrimitive()) {
 			int l = Array.getLength(array);
-			List<Object> list = new ArrayList<Object>(l);
+			List<Object> list = new ArrayList<>(l);
 			for (int i = 0; i < l; i++)
 				list.add(Array.get(array, i));
 			return list;
@@ -782,7 +781,7 @@ public abstract class SerializerSession extends BeanSession {
 	 * @return A map, typically containing something like <code>{line:123,column:456,currentProperty:"foobar"}</code>
 	 */
 	protected final Map<String,Object> getLastLocation() {
-		Map<String,Object> m = new LinkedHashMap<String,Object>();
+		Map<String,Object> m = new LinkedHashMap<>();
 		if (currentClass != null)
 			m.put("currentClass", currentClass);
 		if (currentProperty != null)

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java
index e14d1c3..8f9fbd4 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java
@@ -51,20 +51,21 @@ public class SoapXmlSerializerSession extends XmlSerializerSession {
 
 	@Override /* SerializerSession */
 	protected void doSerialize(SerializerPipe out, Object o) throws Exception {
-		XmlWriter w = getXmlWriter(out);
-		w.append("<?xml")
-			.attr("version", "1.0")
-			.attr("encoding", "UTF-8")
-			.appendln("?>");
-		w.oTag("soap", "Envelope")
-			.attr("xmlns", "soap", getStringProperty(SOAPXML_SOAPAction, "http://www.w3.org/2003/05/soap-envelope"))
-			.appendln(">");
-		w.sTag(1, "soap", "Body").nl(1);
-		indent += 2;
-		w.flush();
-		super.doSerialize(out, o);
-		w.ie(1).eTag("soap", "Body").nl(1);
-		w.eTag("soap", "Envelope").nl(0);
+		try (XmlWriter w = getXmlWriter(out)) {
+			w.append("<?xml")
+				.attr("version", "1.0")
+				.attr("encoding", "UTF-8")
+				.appendln("?>");
+			w.oTag("soap", "Envelope")
+				.attr("xmlns", "soap", getStringProperty(SOAPXML_SOAPAction, "http://www.w3.org/2003/05/soap-envelope"))
+				.appendln(">");
+			w.sTag(1, "soap", "Body").nl(1);
+			indent += 2;
+			w.flush();
+			super.doSerialize(out, o);
+			w.ie(1).eTag("soap", "Body").nl(1);
+			w.eTag("soap", "Envelope").nl(0);
+		}
 	}
 
 	@Override /* Serializer */

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/AnnotationBeanFilterBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/AnnotationBeanFilterBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/AnnotationBeanFilterBuilder.java
index 7f1d942..c5b0fee 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/AnnotationBeanFilterBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/AnnotationBeanFilterBuilder.java
@@ -38,7 +38,7 @@ public final class AnnotationBeanFilterBuilder extends BeanFilterBuilder {
 	public AnnotationBeanFilterBuilder(Class<?> annotatedClass, Map<Class<?>,Bean> annotations) throws Exception {
 		super(annotatedClass);
 
-		ListIterator<Bean> li = new ArrayList<Bean>(annotations.values()).listIterator(annotations.size());
+		ListIterator<Bean> li = new ArrayList<>(annotations.values()).listIterator(annotations.size());
 		while (li.hasPrevious()) {
 			Bean b = li.previous();
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/BeanFilterBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/BeanFilterBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/BeanFilterBuilder.java
index ebc4f27..9ba63df 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/BeanFilterBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/BeanFilterBuilder.java
@@ -222,7 +222,7 @@ public abstract class BeanFilterBuilder {
 	 * @return This object (for method chaining).
 	 */
 	public BeanFilterBuilder setBeanDictionary(Class<?>...c) {
-		beanDictionary = new ArrayList<Class<?>>(Arrays.asList(c));
+		beanDictionary = new ArrayList<>(Arrays.asList(c));
 		return this;
 	}
 
@@ -234,7 +234,7 @@ public abstract class BeanFilterBuilder {
 	 */
 	public BeanFilterBuilder beanDictionary(Class<?>...c) {
 		if (beanDictionary == null)
-			beanDictionary = new ArrayList<Class<?>>(Arrays.asList(c));
+			beanDictionary = new ArrayList<>(Arrays.asList(c));
 		else for (Class<?> cc : c)
 			beanDictionary.add(cc);
 		return this;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/InterfaceBeanFilterBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/InterfaceBeanFilterBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/InterfaceBeanFilterBuilder.java
index a15522e..bfcfa63 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/InterfaceBeanFilterBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/InterfaceBeanFilterBuilder.java
@@ -40,7 +40,7 @@ public class InterfaceBeanFilterBuilder extends BeanFilterBuilder {
 		interfaceClass(interfaceClass);
 		Map<Class<?>,Bean> annotations = ReflectionUtils.findAnnotationsMap(Bean.class, interfaceClass);
 
-		ListIterator<Bean> li = new ArrayList<Bean>(annotations.values()).listIterator(annotations.size());
+		ListIterator<Bean> li = new ArrayList<>(annotations.values()).listIterator(annotations.size());
 		while (li.hasPrevious()) {
 			Bean b = li.previous();
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/SurrogateSwap.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/SurrogateSwap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/SurrogateSwap.java
index 36a1e71..b3d2b56 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/SurrogateSwap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/transform/SurrogateSwap.java
@@ -56,7 +56,7 @@ public class SurrogateSwap<T,F> extends PojoSwap<T,F> {
 	 */
 	@SuppressWarnings({"unchecked", "rawtypes"})
 	public static List<SurrogateSwap<?,?>> findPojoSwaps(Class<?> c) {
-		List<SurrogateSwap<?,?>> l = new LinkedList<SurrogateSwap<?,?>>();
+		List<SurrogateSwap<?,?>> l = new LinkedList<>();
 		for (Constructor<?> cc : c.getConstructors()) {
 			if (cc.getAnnotation(BeanIgnore.class) == null) {
 				Class<?>[] pt = cc.getParameterTypes();

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
index 7c325f4..f3bd0da 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java
@@ -87,26 +87,29 @@ public class UonParserSession extends ReaderParserSession {
 
 	@Override /* ParserSession */
 	protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception {
-		UonReader r = getUonReader(pipe, decodeChars);
-		T o = parseAnything(type, r, getOuter(), true, null);
-		validateEnd(r);
-		return o;
+		try (UonReader r = getUonReader(pipe, decodeChars)) {
+			T o = parseAnything(type, r, getOuter(), true, null);
+			validateEnd(r);
+			return o;
+		}
 	}
 
 	@Override /* ReaderParserSession */
 	protected <K,V> Map<K,V> doParseIntoMap(ParserPipe pipe, Map<K,V> m, Type keyType, Type valueType) throws Exception {
-		UonReader r = getUonReader(pipe, decodeChars);
-		m = parseIntoMap(r, m, (ClassMeta<K>)getClassMeta(keyType), (ClassMeta<V>)getClassMeta(valueType), null);
-		validateEnd(r);
-		return m;
+		try (UonReader r = getUonReader(pipe, decodeChars)) {
+			m = parseIntoMap(r, m, (ClassMeta<K>)getClassMeta(keyType), (ClassMeta<V>)getClassMeta(valueType), null);
+			validateEnd(r);
+			return m;
+		}
 	}
 
 	@Override /* ReaderParserSession */
 	protected <E> Collection<E> doParseIntoCollection(ParserPipe pipe, Collection<E> c, Type elementType) throws Exception {
-		UonReader r = getUonReader(pipe, decodeChars);
-		c = parseIntoCollection(r, c, (ClassMeta<E>)getClassMeta(elementType), false, null);
-		validateEnd(r);
-		return c;
+		try (UonReader r = getUonReader(pipe, decodeChars)) {
+			c = parseIntoCollection(r, c, (ClassMeta<E>)getClassMeta(elementType), false, null);
+			validateEnd(r);
+			return c;
+		}
 	}
 
 	/**
@@ -125,7 +128,7 @@ public class UonParserSession extends ReaderParserSession {
 	public <T> T parseAnything(ClassMeta<?> eType, UonReader r, Object outer, boolean isUrlParamValue, BeanPropertyMeta pMeta) throws Exception {
 
 		if (eType == null)
-			eType = (ClassMeta<T>)object();
+			eType = object();
 		PojoSwap<T,Object> swap = (PojoSwap<T,Object>)eType.getPojoSwap(this);
 		ClassMeta<?> sType = swap == null ? eType : swap.getSwapClassMeta(this);
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
index 9098d20..6eff79e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
@@ -110,66 +110,63 @@ public class UrlEncodingParser extends UonParser implements PartParser {
 		if (isEmpty(qs))
 			return m;
 
-		// We're reading from a string, so we don't need to make sure close() is called on the pipe.
-		ParserPipe p = new ParserPipe(qs, false, false, null, null);
-		UonReader r = new UonReader(p, true);
-
-		final int S1=1; // Looking for attrName start.
-		final int S2=2; // Found attrName start, looking for = or & or end.
-		final int S3=3; // Found =, looking for valStart.
-		final int S4=4; // Found valStart, looking for & or end.
-
-		try {
-			int c = r.peekSkipWs();
-			if (c == '?')
-				r.read();
-
-			int state = S1;
-			String currAttr = null;
-			while (c != -1) {
-				c = r.read();
-				if (state == S1) {
-					if (c != -1) {
-						r.unread();
-						r.mark();
-						state = S2;
-					}
-				} else if (state == S2) {
-					if (c == -1) {
-						add(m, r.getMarked(), null);
-					} else if (c == '\u0001') {
-						m.put(r.getMarked(0,-1), null);
-						state = S1;
-					} else if (c == '\u0002') {
-						currAttr = r.getMarked(0,-1);
-						state = S3;
-					}
-				} else if (state == S3) {
-					if (c == -1 || c == '\u0001') {
-						add(m, currAttr, "");
-					} else {
-						if (c == '\u0002')
+		try (ParserPipe p = new ParserPipe(qs, false, false, null, null)) {
+			
+			final int S1=1; // Looking for attrName start.
+			final int S2=2; // Found attrName start, looking for = or & or end.
+			final int S3=3; // Found =, looking for valStart.
+			final int S4=4; // Found valStart, looking for & or end.
+
+			try (UonReader r = new UonReader(p, true)) {
+				int c = r.peekSkipWs();
+				if (c == '?')
+					r.read();
+
+				int state = S1;
+				String currAttr = null;
+				while (c != -1) {
+					c = r.read();
+					if (state == S1) {
+						if (c != -1) {
+							r.unread();
+							r.mark();
+							state = S2;
+						}
+					} else if (state == S2) {
+						if (c == -1) {
+							add(m, r.getMarked(), null);
+						} else if (c == '\u0001') {
+							m.put(r.getMarked(0,-1), null);
+							state = S1;
+						} else if (c == '\u0002') {
+							currAttr = r.getMarked(0,-1);
+							state = S3;
+						}
+					} else if (state == S3) {
+						if (c == -1 || c == '\u0001') {
+							add(m, currAttr, "");
+						} else {
+							if (c == '\u0002')
+								r.replace('=');
+							r.unread();
+							r.mark();
+							state = S4;
+						}
+					} else if (state == S4) {
+						if (c == -1) {
+							add(m, currAttr, r.getMarked());
+						} else if (c == '\u0001') {
+							add(m, currAttr, r.getMarked(0,-1));
+							state = S1;
+						} else if (c == '\u0002') {
 							r.replace('=');
-						r.unread();
-						r.mark();
-						state = S4;
-					}
-				} else if (state == S4) {
-					if (c == -1) {
-						add(m, currAttr, r.getMarked());
-					} else if (c == '\u0001') {
-						add(m, currAttr, r.getMarked(0,-1));
-						state = S1;
-					} else if (c == '\u0002') {
-						r.replace('=');
+						}
 					}
 				}
 			}
-		} finally {
-			r.close();
-		}
 
-		return m;
+			return m;
+		}
 	}
 
 	private static void add(Map<String,String[]> m, String key, String val) {
@@ -199,17 +196,14 @@ public class UrlEncodingParser extends UonParser implements PartParser {
 				return null;
 		}
 		UonParserSession session = createParameterSession();
-		ParserPipe pipe = session.createPipe(in);
-		try {
-			UonReader r = session.getUonReader(pipe, false);
-			return session.parseAnything(type, r, null, true, null);
+		try (ParserPipe pipe = session.createPipe(in)) {
+			try (UonReader r = session.getUonReader(pipe, false)) {
+				return session.parseAnything(type, r, null, true, null);
+			}
 		} catch (ParseException e) {
 			throw e;
 		} catch (Exception e) {
-			throw new ParseException(session.getLastLocation(), e);
-		} finally {
-			pipe.close();
-			session.close();
+			throw new ParseException(e);
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserSession.java
index 0fcc315..66bc1e5 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserSession.java
@@ -77,18 +77,19 @@ public class UrlEncodingParserSession extends UonParserSession {
 
 	@Override /* ParserSession */
 	protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception {
-		UonReader r = getUonReader(pipe, true);
-		T o = parseAnything(type, r, getOuter());
-		return o;
+		try (UonReader r = getUonReader(pipe, true)) {
+			return parseAnything(type, r, getOuter());
+		}
 	}
 
 	@Override /* ReaderParserSession */
 	protected <K,V> Map<K,V> doParseIntoMap(ParserPipe pipe, Map<K,V> m, Type keyType, Type valueType) throws Exception {
-		UonReader r = getUonReader(pipe, true);
-		if (r.peekSkipWs() == '?')
-			r.read();
-		m = parseIntoMap2(r, m, getClassMeta(Map.class, keyType, valueType), null);
-		return m;
+		try (UonReader r = getUonReader(pipe, true)) {
+			if (r.peekSkipWs() == '?')
+				r.read();
+			m = parseIntoMap2(r, m, getClassMeta(Map.class, keyType, valueType), null);
+			return m;
+		}
 	}
 
 	private <T> T parseAnything(ClassMeta<T> eType, UonReader r, Object outer) throws Exception {
@@ -121,7 +122,7 @@ public class UrlEncodingParserSession extends UonParserSession {
 		} else if (sType.isCollection() || sType.isArray() || sType.isArgs()) {
 			// ?1=foo&2=bar...
 			Collection c2 = ((sType.isArray() || sType.isArgs()) || ! sType.canCreateNewInstance(outer)) ? new ObjectList(this) : (Collection)sType.newInstance();
-			Map<Integer,Object> m = new TreeMap<Integer,Object>();
+			Map<Integer,Object> m = new TreeMap<>();
 			parseIntoMap2(r, m, sType, c2);
 			c2.addAll(m.values());
 			if (sType.isArray())

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
index 0e300ca..fbf7a47 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
@@ -151,7 +151,7 @@ public class UrlEncodingSerializerSession extends UonSerializerSession {
 	 * Converts a Collection into an integer-indexed map.
 	 */
 	private static Map<Integer,Object> getCollectionMap(Collection<?> c) {
-		Map<Integer,Object> m = new TreeMap<Integer,Object>();
+		Map<Integer,Object> m = new TreeMap<>();
 		int i = 0;
 		for (Object o : c)
 			m.put(i++, o);
@@ -162,7 +162,7 @@ public class UrlEncodingSerializerSession extends UonSerializerSession {
 	 * Converts an array into an integer-indexed map.
 	 */
 	private static Map<Integer,Object> getCollectionMap(Object array) {
-		Map<Integer,Object> m = new TreeMap<Integer,Object>();
+		Map<Integer,Object> m = new TreeMap<>();
 		for (int i = 0; i < Array.getLength(array); i++)
 			m.put(i, Array.get(array, i));
 		return m;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Args.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Args.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Args.java
index bcff168..081e69b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Args.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/Args.java
@@ -111,7 +111,7 @@ public final class Args extends ObjectMap {
 	 * @param args Arguments passed in through a <code>main(String[] args)</code> method.
 	 */
 	public Args(String[] args) {
-		List<String> argList = new LinkedList<String>(Arrays.asList(args));
+		List<String> argList = new LinkedList<>(Arrays.asList(args));
 
 		// Capture the main arguments.
 		Integer i = 0;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/CalendarUtils.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/CalendarUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/CalendarUtils.java
index 38a503c..644b6b7 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/CalendarUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/CalendarUtils.java
@@ -329,7 +329,7 @@ public class CalendarUtils {
 		SHORT_DT
 	}
 
-	private static ThreadLocal<Map<DateFormatKey,DateFormat>> patternCache = new ThreadLocal<Map<DateFormatKey,DateFormat>>();
+	private static ThreadLocal<Map<DateFormatKey,DateFormat>> patternCache = new ThreadLocal<>();
 
 	static class DateFormatKey {
 		final CalendarUtils.Format format;
@@ -371,7 +371,7 @@ public class CalendarUtils {
 
 		Map<DateFormatKey,DateFormat> m1 = patternCache.get();
 		if (m1 == null) {
-			m1 = new ConcurrentHashMap<DateFormatKey,DateFormat>();
+			m1 = new ConcurrentHashMap<>();
 			patternCache.set(m1);
 		}
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/IOPipe.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/IOPipe.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/IOPipe.java
index a39c17c..ede9c34 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/IOPipe.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/IOPipe.java
@@ -175,14 +175,14 @@ public class IOPipe {
 					c += i;
 					out.write(b, 0, i);
 				}
+				out.flush();
 			} else {
 				Reader in = (input instanceof Reader ? (Reader)input : new InputStreamReader((InputStream)input, UTF8));
 				Writer out = (output instanceof Writer ? (Writer)output : new OutputStreamWriter((OutputStream)output, UTF8));
 				output = out;
 				input = in;
 				if (byLines || lineProcessor != null) {
-					Scanner s = new Scanner(in);
-					try {
+					try (Scanner s = new Scanner(in)) {
 						while (s.hasNextLine()) {
 							String l = s.nextLine();
 							if (lineProcessor != null)
@@ -194,8 +194,6 @@ public class IOPipe {
 								c += l.length() + 1;
 							}
 						}
-					} finally {
-						s.close();
 					}
 				} else {
 					int i;
@@ -205,6 +203,7 @@ public class IOPipe {
 						out.write(b, 0, i);
 					}
 				}
+				out.flush();
 			}
 		} finally {
 			closeQuietly(input, output);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ManifestFile.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ManifestFile.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ManifestFile.java
index 1690a19..25c2ecd 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ManifestFile.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ManifestFile.java
@@ -40,14 +40,11 @@ public class ManifestFile extends ObjectMap {
 	 */
 	public ManifestFile(File f) throws IOException {
 		Manifest mf = new Manifest();
-		FileInputStream fis = new FileInputStream(f);
-		try {
+		try (FileInputStream fis = new FileInputStream(f)) {
 			mf.read(fis);
 			load(mf);
 		} catch (IOException e) {
 			throw new IOException("Problem detected in MANIFEST.MF.  Contents below:\n" + read(f), e);
-		} finally {
-			closeQuietly(fis);
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/MessageBundle.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/MessageBundle.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/MessageBundle.java
index 061b12c..84bb9cb 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/MessageBundle.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/MessageBundle.java
@@ -51,7 +51,7 @@ import org.apache.juneau.annotation.*;
 @ThreadSafe
 public class MessageBundle extends ResourceBundle {
 
-	private static final ThreadLocal<Locale> clientLocale = new ThreadLocal<Locale>();
+	private static final ThreadLocal<Locale> clientLocale = new ThreadLocal<>();
 
 	private final ResourceBundle rb;
 	private final String bundlePath, className;
@@ -60,17 +60,17 @@ public class MessageBundle extends ResourceBundle {
 
 	// A map that contains all keys [shortKeyName->keyName] and [keyName->keyName], where shortKeyName
 	// refers to keys prefixed and stripped of the class name (e.g. "foobar"->"MyClass.foobar")
-	private final Map<String,String> keyMap = new ConcurrentHashMap<String,String>();
+	private final Map<String,String> keyMap = new ConcurrentHashMap<>();
 
 	// Contains all keys present in all bundles in searchBundles.
-	private final ConcurrentSkipListSet<String> allKeys = new ConcurrentSkipListSet<String>();
+	private final ConcurrentSkipListSet<String> allKeys = new ConcurrentSkipListSet<>();
 
 	// Bundles to search through to find properties.
 	// Typically this will be a list of resource bundles for each class up the class hierarchy chain.
-	private final CopyOnWriteArrayList<MessageBundle> searchBundles = new CopyOnWriteArrayList<MessageBundle>();
+	private final CopyOnWriteArrayList<MessageBundle> searchBundles = new CopyOnWriteArrayList<>();
 
 	// Cache of message bundles per locale.
-	private final ConcurrentHashMap<Locale,MessageBundle> localizedBundles = new ConcurrentHashMap<Locale,MessageBundle>();
+	private final ConcurrentHashMap<Locale,MessageBundle> localizedBundles = new ConcurrentHashMap<>();
 
 	/**
 	 * Sets the locale for this thread so that calls to {@link #getClientString(String, Object...)} return messages in
@@ -252,7 +252,7 @@ public class MessageBundle extends ResourceBundle {
 	 * @return The set of all keys in the resource bundle with the prefix.
 	 */
 	public Set<String> keySet(String prefix) {
-		Set<String> set = new HashSet<String>();
+		Set<String> set = new HashSet<>();
 		for (String s : keySet()) {
 			if (s.equals(prefix) || (s.startsWith(prefix) && s.charAt(prefix.length()) == '.'))
 				set.add(s);
@@ -317,7 +317,7 @@ public class MessageBundle extends ResourceBundle {
 		if (mb != null)
 			return mb;
 		mb = new MessageBundle(forClass, bundlePath, locale);
-		List<MessageBundle> l = new ArrayList<MessageBundle>(searchBundles.size()-1);
+		List<MessageBundle> l = new ArrayList<>(searchBundles.size()-1);
 		for (int i = 1; i < searchBundles.size(); i++) {
 			MessageBundle srb = searchBundles.get(i);
 			srb = new MessageBundle(srb.forClass, srb.bundlePath, locale);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/PojoQuery.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/PojoQuery.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/PojoQuery.java
index 14abfaf..cc4cf07 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/PojoQuery.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/PojoQuery.java
@@ -308,7 +308,7 @@ public final class PojoQuery {
 	private static void doSort(List list, Map<String,Boolean> sortList) {
 
 		// We reverse the list and sort last to first.
-		List<String> columns = new ArrayList<String>(sortList.keySet());
+		List<String> columns = new ArrayList<>(sortList.keySet());
 		Collections.reverse(columns);
 
 		for (final String c : columns) {
@@ -403,7 +403,7 @@ public final class PojoQuery {
 	 */
 	private class MapMatcher implements IMatcher<Map> {
 
-		Map<String,IMatcher> entryMatchers = new HashMap<String,IMatcher>();
+		Map<String,IMatcher> entryMatchers = new HashMap<>();
 
 		public MapMatcher(Map query, boolean ignoreCase) {
 			for (Map.Entry e : (Set<Map.Entry>)query.entrySet())
@@ -536,7 +536,7 @@ public final class PojoQuery {
 
 		public NumberPattern(String searchPattern) {
 
-			List<NumberRange> l = new LinkedList<NumberRange>();
+			List<NumberRange> l = new LinkedList<>();
 
 			for (String s : breakUpTokens(searchPattern)) {
 				boolean isNot = (s.charAt(0) == '!');
@@ -583,7 +583,7 @@ public final class PojoQuery {
 				if (! startsWith(s2[i], '!'))
 					s2[i] = "^"+s2[i];
 
-			List<String> l = new LinkedList<String>();
+			List<String> l = new LinkedList<>();
 			l.addAll(Arrays.asList(s2));
 			return l;
 		}
@@ -708,7 +708,7 @@ public final class PojoQuery {
 	 */
 	private class TimestampPattern {
 		TimestampRange[] ranges;
-		List<TimestampRange> l = new LinkedList<TimestampRange>();
+		List<TimestampRange> l = new LinkedList<>();
 
 		public TimestampPattern(String s) {
 
@@ -951,9 +951,9 @@ public final class PojoQuery {
 
 		public SearchPattern(String searchPattern, boolean ignoreCase) {
 
-			List<Pattern> ors = new LinkedList<Pattern>();
-			List<Pattern> ands = new LinkedList<Pattern>();
-			List<Pattern> nots = new LinkedList<Pattern>();
+			List<Pattern> ors = new LinkedList<>();
+			List<Pattern> ands = new LinkedList<>();
+			List<Pattern> nots = new LinkedList<>();
 
 			for (String arg : breakUpTokens(searchPattern)) {
 				char prefix = arg.charAt(0);
@@ -1035,7 +1035,7 @@ public final class PojoQuery {
 			s = s.replace('\u9998', '-');
 
 			String[] sa = splitQuoted(s, ' ');
-			List<String> l = new ArrayList<String>(sa.length);
+			List<String> l = new ArrayList<>(sa.length);
 			int numOrs = 0;
 			for (int i = 0; i < sa.length; i++) {
 				String token = sa[i];
@@ -1105,7 +1105,7 @@ public final class PojoQuery {
 		if (s == null || s.matches("\\s*"))
 			return new String[0];
 
-		List<String> l = new LinkedList<String>();
+		List<String> l = new LinkedList<>();
 		char[] sArray = s.toCharArray();
 		int x1 = 0;
 		int escapeCount = 0;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ProcBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ProcBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ProcBuilder.java
index cfa4a2c..300a327 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ProcBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ProcBuilder.java
@@ -247,7 +247,7 @@ public class ProcBuilder {
 	 * @param env The new set of environment variables.
 	 * @return This object (for method chaining).
 	 */
-	@SuppressWarnings({"rawtypes", "unchecked"})
+	@SuppressWarnings({"rawtypes"})
 	public ProcBuilder env(Map env) {
 		if (env != null)
 			for (Map.Entry e : (Set<Map.Entry>)env.entrySet())
@@ -395,7 +395,7 @@ public class ProcBuilder {
 	};
 
 	private static List<String> toList(Object...args) {
-		List<String> l = new LinkedList<String>();
+		List<String> l = new LinkedList<>();
 		for (Object o : args) {
 			if (o.getClass().isArray())
 				for (int i = 0; i < Array.getLength(o); i++)

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ResourceFinder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ResourceFinder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ResourceFinder.java
index 343dd25..0ad81dc 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ResourceFinder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ResourceFinder.java
@@ -52,10 +52,10 @@ public class ResourceFinder {
 	private static final List<Locale> ROOT_LOCALE = Arrays.asList(Locale.ROOT);
 
 	// Maps resource names+locales to found resources.
-	private final ConcurrentHashMap<ResourceKey,Resource> cache = new ConcurrentHashMap<ResourceKey,Resource>();
+	private final ConcurrentHashMap<ResourceKey,Resource> cache = new ConcurrentHashMap<>();
 
 	// Maps resolved URLs to resources.
-	private final ConcurrentHashMap<URL,Resource> cacheByUrl = new ConcurrentHashMap<URL,Resource>();
+	private final ConcurrentHashMap<URL,Resource> cacheByUrl = new ConcurrentHashMap<>();
 
 	private final Class<?> c;
 
@@ -218,7 +218,9 @@ public class ResourceFinder {
 					URL url = f.toURI().toURL();
 					Resource r = cacheByUrl.get(url);
 					if (r == null) {
-						r = new Resource(IOUtils.readBytes(new FileInputStream(f), 1024));
+						try (FileInputStream fis = new FileInputStream(f)) {
+							r = new Resource(IOUtils.readBytes(fis, 1024));
+						}
 						cacheByUrl.putIfAbsent(url, r);
 						r = cacheByUrl.get(url);
 					}

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/SearchArgs.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/SearchArgs.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/SearchArgs.java
index 3cae084..8d1da96 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/SearchArgs.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/SearchArgs.java
@@ -31,9 +31,9 @@ public class SearchArgs {
 	private final boolean ignoreCase;
 
 	private SearchArgs(Builder b) {
-		this.search = unmodifiableMap(new LinkedHashMap<String,String>(b.search));
-		this.view = unmodifiableList(new ArrayList<String>(b.view));
-		this.sort = unmodifiableMap(new LinkedHashMap<String,Boolean>(b.sort));
+		this.search = unmodifiableMap(new LinkedHashMap<>(b.search));
+		this.view = unmodifiableList(new ArrayList<>(b.view));
+		this.sort = unmodifiableMap(new LinkedHashMap<>(b.sort));
 		this.position = b.position;
 		this.limit = b.limit;
 		this.ignoreCase = b.ignoreCase;
@@ -52,9 +52,9 @@ public class SearchArgs {
 	 * Builder for {@link SearchArgs} class.
 	 */
 	public static class Builder {
-		Map<String,String> search = new LinkedHashMap<String,String>();
-		List<String> view = new ArrayList<String>();
-		Map<String,Boolean> sort = new LinkedHashMap<String,Boolean>();
+		Map<String,String> search = new LinkedHashMap<>();
+		List<String> view = new ArrayList<>();
+		Map<String,Boolean> sort = new LinkedHashMap<>();
 		int position, limit;
 		boolean ignoreCase;
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ZipFileList.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ZipFileList.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ZipFileList.java
index 5637136..a12183f 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ZipFileList.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ZipFileList.java
@@ -132,7 +132,9 @@ public class ZipFileList extends LinkedList<ZipFileList.ZipFileEntry> {
 					ZipEntry e = new ZipEntry(path);
 					e.setSize(f.length());
 					zos.putNextEntry(e);
-					IOPipe.create(new FileInputStream(f), zos).run();
+					try (FileInputStream fis = new FileInputStream(f)) {
+						IOPipe.create(fis, zos).run();
+					}
 				}
 			}
 		}

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/NamespaceFactory.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/NamespaceFactory.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/NamespaceFactory.java
index d026611..4b0622c 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/NamespaceFactory.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/NamespaceFactory.java
@@ -30,7 +30,7 @@ import org.apache.juneau.parser.*;
  */
 public final class NamespaceFactory {
 
-	private static ConcurrentHashMap<String,Namespace> cache = new ConcurrentHashMap<String,Namespace>();
+	private static ConcurrentHashMap<String,Namespace> cache = new ConcurrentHashMap<>();
 
 	/**
 	 * Get the {@link Namespace} with the specified name and URI, and create a new one if this is the first time it's

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlBeanMeta.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlBeanMeta.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlBeanMeta.java
index b99f5c5..dc7e257 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlBeanMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlBeanMeta.java
@@ -67,9 +67,9 @@ public class XmlBeanMeta extends BeanMetaExtended {
 
 	private static class XmlBeanMetaBuilder {
 		Map<String,BeanPropertyMeta>
-			attrs = new LinkedHashMap<String,BeanPropertyMeta>(),
-			elements = new LinkedHashMap<String,BeanPropertyMeta>(),
-			collapsedProperties = new LinkedHashMap<String,BeanPropertyMeta>();
+			attrs = new LinkedHashMap<>(),
+			elements = new LinkedHashMap<>(),
+			collapsedProperties = new LinkedHashMap<>();
 		BeanPropertyMeta
 			attrsProperty,
 			contentProperty;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java
index a7a8748..f6035d3 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java
@@ -41,12 +41,13 @@ public class XmlDocSerializerSession extends XmlSerializerSession {
 
 	@Override /* SerializerSession */
 	protected void doSerialize(SerializerPipe out, Object o) throws Exception {
-		XmlWriter w = getXmlWriter(out);
-		w.append("<?xml")
-			.attr("version", "1.0")
-			.attr("encoding", "UTF-8")
-			.appendln("?>");
-		w.flush();
-		super.doSerialize(out, o);
+		try (XmlWriter w = getXmlWriter(out)) {
+			w.append("<?xml")
+				.attr("version", "1.0")
+				.attr("encoding", "UTF-8")
+				.appendln("?>");
+			w.flush();
+			super.doSerialize(out, o);
+		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
index 1e83010..232f722 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
@@ -506,7 +506,7 @@ public class XmlParserSession extends ReaderParserSession {
 				if (cp != null && cpf.isOneOf(MIXED, MIXED_PWS)) {
 					if (cpcm.isCollectionOrArray()) {
 						if (l == null)
-							l = new LinkedList<Object>();
+							l = new LinkedList<>();
 						l.add(getText(r, false));
 					} else {
 						cp.set(m, null, getText(r, trim));
@@ -539,7 +539,7 @@ public class XmlParserSession extends ReaderParserSession {
 					if (isWhitespaceElement(r) && (breg == null || ! breg.hasName(r.getLocalName()))) {
 						if (cpcm.isCollectionOrArray()) {
 							if (l == null)
-								l = new LinkedList<Object>();
+								l = new LinkedList<>();
 							l.add(parseWhitespaceElement(r));
 						} else {
 							cp.set(m, null, parseWhitespaceElement(r));
@@ -547,7 +547,7 @@ public class XmlParserSession extends ReaderParserSession {
 					} else {
 						if (cpcm.isCollectionOrArray()) {
 							if (l == null)
-								l = new LinkedList<Object>();
+								l = new LinkedList<>();
 							l.add(parseAnything(cpcm.getElementType(), cp.getName(), r, m.getBean(false), false, cp));
 						} else {
 							cp.set(m, null, parseAnything(cpcm, cp.getName(), r, m.getBean(false), false, cp));

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlReader.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlReader.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlReader.java
index 50c0e5e..c7206ce 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlReader.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlReader.java
@@ -45,6 +45,7 @@ public final class XmlReader implements XMLStreamReader {
 	protected XmlReader(ParserPipe pipe, boolean validating, XMLReporter reporter, XMLResolver resolver, XMLEventAllocator eventAllocator) throws Exception {
 		this.pipe = pipe;
 		try {
+			@SuppressWarnings("resource")
 			Reader r = pipe.getBufferedReader();
 			XMLInputFactory factory = XMLInputFactory.newInstance();
 			factory.setProperty(XMLInputFactory.IS_VALIDATING, validating);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java
index 8d4a7aa..ee6d15b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java
@@ -41,12 +41,13 @@ public class XmlSchemaDocSerializerSession extends XmlSchemaSerializerSession {
 
 	@Override /* SerializerSession */
 	protected void doSerialize(SerializerPipe out, Object o) throws Exception {
-		XmlWriter w = getXmlWriter(out);
-		w.append("<?xml")
-			.attr("version", "1.0")
-			.attr("encoding", "UTF-8")
-			.appendln("?>");
-		w.flush();
-		super.doSerialize(out, o);
+		try (XmlWriter w = getXmlWriter(out)) {
+			w.append("<?xml")
+				.attr("version", "1.0")
+				.attr("encoding", "UTF-8")
+				.appendln("?>");
+			w.flush();
+			super.doSerialize(out, o);
+		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java
index 6304cea..985edd1 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java
@@ -85,7 +85,7 @@ public class XmlSchemaSerializerSession extends XmlSerializerSession {
 		if (xmlSchema.indexOf('\u0000') != -1) {
 
 			// Break it up into a map of namespaceURI->schema document
-			final Map<String,String> schemas = new HashMap<String,String>();
+			final Map<String,String> schemas = new HashMap<>();
 			String[] ss = xmlSchema.split("\u0000");
 			xmlSchema = ss[0];
 			for (String s : ss) {
@@ -146,9 +146,9 @@ public class XmlSchemaSerializerSession extends XmlSerializerSession {
 		private Namespace defaultNs;
 		private BeanSession session;
 		private LinkedList<QueueEntry>
-			elementQueue = new LinkedList<QueueEntry>(),
-			attributeQueue = new LinkedList<QueueEntry>(),
-			typeQueue = new LinkedList<QueueEntry>();
+			elementQueue = new LinkedList<>(),
+			attributeQueue = new LinkedList<>(),
+			typeQueue = new LinkedList<>();
 
 		private Schemas(BeanSession session, Namespace xs, Namespace defaultNs, Namespace[] allNs) throws IOException {
 			this.session = session;
@@ -232,9 +232,9 @@ public class XmlSchemaSerializerSession extends XmlSerializerSession {
 		private Namespace defaultNs, targetNs;
 		private Schemas schemas;
 		private Set<String>
-			processedTypes = new HashSet<String>(),
-			processedAttributes = new HashSet<String>(),
-			processedElements = new HashSet<String>();
+			processedTypes = new HashSet<>(),
+			processedAttributes = new HashSet<>(),
+			processedElements = new HashSet<>();
 
 		public Schema(Schemas schemas, Namespace xs, Namespace targetNs, Namespace defaultNs, Namespace[] allNs) throws IOException {
 			this.schemas = schemas;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlUtils.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlUtils.java
index 0331315..2b84be6 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlUtils.java
@@ -70,7 +70,9 @@ public final class XmlUtils {
 			return "_xE000_";
 		try {
 			if (needsElementNameEncoding(s))
-				return encodeElementNameInner(new StringBuilderWriter(s.length() * 2), s).toString();
+				try (Writer w = new StringBuilderWriter(s.length() * 2)) {
+					return encodeElementNameInner(w, s).toString();
+				}
 		} catch (IOException e) {
 			throw new RuntimeException(e); // Never happens
 		}

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlParserSession.java
index 70eb434..cb277e2 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlParserSession.java
@@ -81,34 +81,37 @@ public final class YamlParserSession extends ReaderParserSession {
 
 	@Override /* ParserSession */
 	protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception {
-		ParserReader r = pipe.getParserReader();
-		if (r == null)
-			return null;
-		T o = parseAnything(type, r, getOuter(), null);
-		validateEnd(r);
-		return o;
+		try (ParserReader r = pipe.getParserReader()) {
+			if (r == null)
+				return null;
+			T o = parseAnything(type, r, getOuter(), null);
+			validateEnd(r);
+			return o;
+		}
 	}
 
 	@Override /* ReaderParserSession */
 	protected <K,V> Map<K,V> doParseIntoMap(ParserPipe pipe, Map<K,V> m, Type keyType, Type valueType) throws Exception {
-		ParserReader r = pipe.getParserReader();
-		m = parseIntoMap2(r, m, (ClassMeta<K>)getClassMeta(keyType), (ClassMeta<V>)getClassMeta(valueType), null);
-		validateEnd(r);
-		return m;
+		try (ParserReader r = pipe.getParserReader()) {
+			m = parseIntoMap2(r, m, (ClassMeta<K>)getClassMeta(keyType), (ClassMeta<V>)getClassMeta(valueType), null);
+			validateEnd(r);
+			return m;
+		}
 	}
 
 	@Override /* ReaderParserSession */
 	protected <E> Collection<E> doParseIntoCollection(ParserPipe pipe, Collection<E> c, Type elementType) throws Exception {
-		ParserReader r = pipe.getParserReader();
-		c = parseIntoCollection2(r, c, getClassMeta(elementType), null);
-		validateEnd(r);
-		return c;
+		try (ParserReader r = pipe.getParserReader()) {
+			c = parseIntoCollection2(r, c, getClassMeta(elementType), null);
+			validateEnd(r);
+			return c;
+		}
 	}
 
 	private <T> T parseAnything(ClassMeta<?> eType, ParserReader r, Object outer, BeanPropertyMeta pMeta) throws Exception {
 
 		if (eType == null)
-			eType = (ClassMeta<T>)object();
+			eType = object();
 		PojoSwap<T,Object> swap = (PojoSwap<T,Object>)eType.getPojoSwap(this);
 		ClassMeta<?> sType = swap == null ? eType : swap.getSwapClassMeta(this);
 		setCurrentClass(sType);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlSerializerSession.java
index db40dd8..239186e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlSerializerSession.java
@@ -65,7 +65,7 @@ public class YamlSerializerSession extends WriterSerializerSession {
 
 	@Override /* SerializerSesssion */
 	protected void doSerialize(SerializerPipe out, Object o) throws Exception {
-		serializeAnything(getJsonWriter(out), o, getExpectedRootType(o), "root", null);
+		serializeAnything(getYamlWriter(out), o, getExpectedRootType(o), "root", null);
 	}
 
 	/*
@@ -240,7 +240,7 @@ public class YamlSerializerSession extends WriterSerializerSession {
 	 * @return The output target object wrapped in an {@link YamlWriter}.
 	 * @throws Exception
 	 */
-	protected final YamlWriter getJsonWriter(SerializerPipe out) throws Exception {
+	protected final YamlWriter getYamlWriter(SerializerPipe out) throws Exception {
 		Object output = out.getRawOutput();
 		if (output instanceof YamlWriter)
 			return (YamlWriter)output;