juneau-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesbog...@apache.org
Subject [6/8] juneau git commit: Update code to reflect changes in Java 7.
Date Thu, 26 Oct 2017 23:22:09 GMT
http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ObjectMap.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ObjectMap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ObjectMap.java
index 7eef2dd..18cf44f 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ObjectMap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ObjectMap.java
@@ -116,13 +116,11 @@ public class ObjectMap extends LinkedHashMap<String,Object> {
 		private static final long serialVersionUID = 1L;
 
 		@Override /* Map */
-		@SuppressWarnings("unchecked")
 		public Set<Map.Entry<String,Object>> entrySet() {
 			return Collections.EMPTY_MAP.entrySet();
 		}
 
 		@Override /* Map */
-		@SuppressWarnings("unchecked")
 		public Set<String> keySet() {
 			return Collections.EMPTY_MAP.keySet();
 		}
@@ -1426,7 +1424,7 @@ public class ObjectMap extends LinkedHashMap<String,Object> {
 	public Set<String> keySet() {
 		if (inner == null)
 			return super.keySet();
-		LinkedHashSet<String> s = new LinkedHashSet<String>();
+		LinkedHashSet<String> s = new LinkedHashSet<>();
 		s.addAll(inner.keySet());
 		s.addAll(super.keySet());
 		return s;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStore.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStore.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStore.java
index cb1d4fb..8a11bf6 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStore.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStore.java
@@ -254,17 +254,17 @@ public final class PropertyStore {
 	// All configuration properties in this object.
 	// Keys are property prefixes (e.g. 'BeanContext').
 	// Values are maps containing properties for that specific prefix.
-	private Map<String,PropertyMap> properties = new ConcurrentSkipListMap<String,PropertyMap>();
+	private Map<String,PropertyMap> properties = new ConcurrentSkipListMap<>();
 
 	// Context cache.
 	// This gets cleared every time any properties change on this object.
-	private final Map<Class<? extends Context>,Context> contexts = new ConcurrentHashMap<Class<? extends Context>,Context>();
+	private final Map<Class<? extends Context>,Context> contexts = new ConcurrentHashMap<>();
 
 	// Global Context cache.
 	// Property stores that are the 'same' will use the same maps from this cache.
 	// 'same' means the context properties are all the same when converted to strings.
 	private static final ConcurrentHashMap<Integer, ConcurrentHashMap<Class<? extends Context>,Context>>
-		globalContextCache = new ConcurrentHashMap<Integer, ConcurrentHashMap<Class<? extends Context>,Context>>();
+		globalContextCache = new ConcurrentHashMap<>();
 
 	private ReadWriteLock lock = new ReentrantReadWriteLock();
 	private Lock rl = lock.readLock(), wl = lock.writeLock();
@@ -929,7 +929,7 @@ public final class PropertyStore {
 	 */
 	public class PropertyMap {
 
-		private final Map<String,Property> map = new ConcurrentSkipListMap<String,Property>();
+		private final Map<String,Property> map = new ConcurrentSkipListMap<>();
 		private volatile int hashCode = 0;
 		private final ReadWriteLock lock = new ReentrantReadWriteLock();
 		private final Lock rl = lock.readLock(), wl = lock.writeLock();
@@ -1038,7 +1038,7 @@ public final class PropertyStore {
 		public Map<String,Object> asMap() {
 			rl.lock();
 			try {
-				Map<String,Object> m = new LinkedHashMap<String,Object>();
+				Map<String,Object> m = new LinkedHashMap<>();
 				for (Property p : map.values())
 					m.put(p.name, p.value);
 				return m;
@@ -1223,7 +1223,7 @@ public final class PropertyStore {
 		private final Set<Object> value;
 
 		private SetProperty(String name, Object value) {
-			super(name, "SET", new ConcurrentSkipListSet<Object>(PROPERTY_COMPARATOR));
+			super(name, "SET", new ConcurrentSkipListSet<>(PROPERTY_COMPARATOR));
 			this.value = (Set<Object>)value();
 			add(value);
 		}
@@ -1283,7 +1283,7 @@ public final class PropertyStore {
 		private final LinkedList<Object> value;
 
 		private ListProperty(String name, Object value) {
-			super(name, "LIST", new LinkedList<Object>());
+			super(name, "LIST", new LinkedList<>());
 			this.value = (LinkedList<Object>)value();
 			add(value);
 		}
@@ -1298,7 +1298,7 @@ public final class PropertyStore {
 				for (ListIterator<Object> i = l.listIterator(l.size()); i.hasPrevious();)
 					add(i.previous());
 			} else if (val instanceof Collection) {
-				List<Object> l = new ArrayList<Object>((Collection<Object>)val);
+				List<Object> l = new ArrayList<>((Collection<Object>)val);
 				for (ListIterator<Object> i = l.listIterator(l.size()); i.hasPrevious();)
 					add(i.previous());
 			} else {
@@ -1345,7 +1345,7 @@ public final class PropertyStore {
 
 		MapProperty(String name, Object value) {
 			// ConcurrentSkipListMap doesn't support Map.Entry.remove(), so use TreeMap instead.
-			super(name, "MAP", Collections.synchronizedMap(new TreeMap<Object,Object>(PROPERTY_COMPARATOR)));
+			super(name, "MAP", Collections.synchronizedMap(new TreeMap<>(PROPERTY_COMPARATOR)));
 			this.value = (Map<Object,Object>)value();
 			put(value);
 		}
@@ -1413,7 +1413,7 @@ public final class PropertyStore {
 	 * Compares two objects for "string"-equality.
 	 * Basically mean both objects are equal if they're the same when converted to strings.
 	 */
-	@SuppressWarnings({ "rawtypes", "unchecked" })
+	@SuppressWarnings({ "rawtypes" })
 	private static boolean same(Object o1, Object o2) {
 		if (o1 == o2)
 			return true;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Session.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Session.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Session.java
index 056604c..061bd9d 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Session.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Session.java
@@ -38,7 +38,6 @@ public abstract class Session {
 	private final ObjectMap properties;
 	private final Context ctx;
 	private Map<String,Object> cache;
-	private boolean closed;
 	private List<String> warnings;                 // Any warnings encountered.
 
 
@@ -138,7 +137,7 @@ public abstract class Session {
 	 */
 	public final void addToCache(String key, Object val) {
 		if (cache == null)
-			cache = new TreeMap<String,Object>();
+			cache = new TreeMap<>();
 		cache.put(key, val);
 	}
 
@@ -155,7 +154,7 @@ public abstract class Session {
 	public final void addToCache(Map<String,Object> cacheObjects) {
 		if (cacheObjects != null) {
 			if (cache == null)
-				cache = new TreeMap<String,Object>();
+				cache = new TreeMap<>();
 			cache.putAll(cacheObjects);
 		}
 	}
@@ -180,7 +179,7 @@ public abstract class Session {
 	 */
 	public final void addWarning(String msg, Object... args) {
 		if (warnings == null)
-			warnings = new LinkedList<String>();
+			warnings = new LinkedList<>();
 		getLogger().warning(msg, args);
 		warnings.add((warnings.size() + 1) + ": " + format(msg, args));
 	}
@@ -235,23 +234,12 @@ public abstract class Session {
 			return e.getLocalizedMessage();
 		}
 	}
-
+	
 	/**
-	 * Perform cleanup on this context object if necessary.
-	 *
-	 * @return <jk>true</jk> if this method wasn't previously called.
-	 * @throws BeanRuntimeException If called more than once, or in debug mode and warnings occurred.
+	 * Throws a {@link BeanRuntimeException} if any warnings occurred in this session.
 	 */
-	public boolean close() throws BeanRuntimeException {
-		if (closed)
-			return false;
-		closed = true;
-		return true;
-	}
-
-	@Override /* Object */
-	protected void finalize() throws Throwable {
-//		if (! closed)
-//			throw new RuntimeException("Session was not closed.");
+	public void checkForWarnings() {
+		if (! warnings.isEmpty())
+			throw new BeanRuntimeException("Warnings occurred in session: \n" + join(getWarnings(), "\n"));		
 	}
 }

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Visibility.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Visibility.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Visibility.java
index 5a03b5b..c9e1e47 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Visibility.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Visibility.java
@@ -131,7 +131,7 @@ public enum Visibility {
 	 * 	The same method if visibility requirements met, or <jk>null</jk> if visibility requirement not
 	 * 	met or call to {@link Method#setAccessible(boolean)} throws a security exception.
 	 */
-	public <T> Method transform(Method x) {
+	public Method transform(Method x) {
 		if (x == null)
 			return null;
 		if (isVisible(x))

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvParserSession.java
index 7f2324f..3037fed 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvParserSession.java
@@ -39,11 +39,11 @@ public final class CsvParserSession 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);
-		return o;
+		try (ParserReader r = pipe.getParserReader()) {
+			if (r == null)
+				return null;
+			return parseAnything(type, r, getOuter(), null);
+		}
 	}
 
 	@SuppressWarnings({"static-method"})

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializerSession.java
index 0a1478b..d97ac35 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializerSession.java
@@ -44,36 +44,37 @@ public final class CsvSerializerSession extends WriterSerializerSession {
 	}
 
 	@Override /* SerializerSession */
-	protected final void doSerialize(SerializerPipe out, Object o) throws Exception {
-		Writer w = out.getWriter();
-		ClassMeta<?> cm = getClassMetaForObject(o);
-		Collection<?> l = null;
-		if (cm.isArray()) {
-			l = Arrays.asList((Object[])o);
-		} else {
-			l = (Collection<?>)o;
-		}
-		// TODO - Doesn't support DynaBeans.
-		if (l.size() > 0) {
-			ClassMeta<?> entryType = getClassMetaForObject(l.iterator().next());
-			if (entryType.isBean()) {
-				BeanMeta<?> bm = entryType.getBeanMeta();
-				int i = 0;
-				for (BeanPropertyMeta pm : bm.getPropertyMetas()) {
-					if (i++ > 0)
-						w.append(',');
-					append(w, pm.getName());
-				}
-				w.append('\n');
-				for (Object o2 : l) {
-					i = 0;
-					BeanMap<?> bean = toBeanMap(o2);
+	protected final void doSerialize(SerializerPipe pipe, Object o) throws Exception {
+		try (Writer w = pipe.getWriter()) {
+			ClassMeta<?> cm = getClassMetaForObject(o);
+			Collection<?> l = null;
+			if (cm.isArray()) {
+				l = Arrays.asList((Object[])o);
+			} else {
+				l = (Collection<?>)o;
+			}
+			// TODO - Doesn't support DynaBeans.
+			if (l.size() > 0) {
+				ClassMeta<?> entryType = getClassMetaForObject(l.iterator().next());
+				if (entryType.isBean()) {
+					BeanMeta<?> bm = entryType.getBeanMeta();
+					int i = 0;
 					for (BeanPropertyMeta pm : bm.getPropertyMetas()) {
 						if (i++ > 0)
 							w.append(',');
-						append(w, pm.get(bean, pm.getName()));
+						append(w, pm.getName());
 					}
 					w.append('\n');
+					for (Object o2 : l) {
+						i = 0;
+						BeanMap<?> bean = toBeanMap(o2);
+						for (BeanPropertyMeta pm : bm.getPropertyMetas()) {
+							if (i++ > 0)
+								w.append(',');
+							append(w, pm.get(bean, pm.getName()));
+						}
+						w.append('\n');
+					}
 				}
 			}
 		}

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/EncoderGroup.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/EncoderGroup.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/EncoderGroup.java
index ec3632a..0c8c448 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/EncoderGroup.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/EncoderGroup.java
@@ -55,7 +55,7 @@ import org.apache.juneau.http.*;
 public final class EncoderGroup {
 
 	// Maps Accept-Encoding headers to matching encoders.
-	private final ConcurrentHashMap<String,EncoderMatch> cache = new ConcurrentHashMap<String,EncoderMatch>();
+	private final ConcurrentHashMap<String,EncoderMatch> cache = new ConcurrentHashMap<>();
 
 	private final String[] encodings;
 	private final List<String> encodingsList;
@@ -68,10 +68,10 @@ public final class EncoderGroup {
 	 * @param encoders The encoders to add to this group.
 	 */
 	public EncoderGroup(Encoder[] encoders) {
-		this.encoders = Collections.unmodifiableList(new ArrayList<Encoder>(Arrays.asList(encoders)));
+		this.encoders = Collections.unmodifiableList(new ArrayList<>(Arrays.asList(encoders)));
 
-		List<String> lc = new ArrayList<String>();
-		List<Encoder> l = new ArrayList<Encoder>();
+		List<String> lc = new ArrayList<>();
+		List<Encoder> l = new ArrayList<>();
 		for (Encoder e : encoders) {
 			for (String c: e.getCodings()) {
 				lc.add(c);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/EncoderGroupBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/EncoderGroupBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/EncoderGroupBuilder.java
index db54070..6e05a5a 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/EncoderGroupBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/EncoderGroupBuilder.java
@@ -28,7 +28,7 @@ public class EncoderGroupBuilder {
 	 * Create an empty encoder group builder.
 	 */
 	public EncoderGroupBuilder() {
-		this.encoders = new ArrayList<Encoder>();
+		this.encoders = new ArrayList<>();
 	}
 
 	/**
@@ -37,7 +37,7 @@ public class EncoderGroupBuilder {
 	 * @param copyFrom The encoder group that we're copying settings and encoders from.
 	 */
 	public EncoderGroupBuilder(EncoderGroup copyFrom) {
-		this.encoders = new ArrayList<Encoder>();
+		this.encoders = new ArrayList<>();
 		addReverse(encoders, copyFrom.getEncoders());
 	}
 
@@ -95,7 +95,7 @@ public class EncoderGroupBuilder {
 	 * @return A new {@link EncoderGroup} object.
 	 */
 	public EncoderGroup build() {
-		List<Encoder> l = new ArrayList<Encoder>();
+		List<Encoder> l = new ArrayList<>();
 		for (Object e : encoders)
 			l.add(newInstance(Encoder.class, e));
 		Collections.reverse(l);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlBeanPropertyMeta.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlBeanPropertyMeta.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlBeanPropertyMeta.java
index 2bceb2a..4ffc57e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlBeanPropertyMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlBeanPropertyMeta.java
@@ -52,7 +52,7 @@ public final class HtmlBeanPropertyMeta extends BeanPropertyMetaExtended {
 		this.anchorText = b.anchorText;
 	}
 
-	private static class Builder {
+	static final class Builder {
 		boolean asXml, noTables, noTableHeaders, asPlainText;
 		Class<? extends HtmlRender> render = HtmlRender.class;
 		String link, anchorText;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
index 3405483..f107823 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
@@ -223,17 +223,18 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
 	@Override /* Serializer */
 	protected void doSerialize(SerializerPipe out, Object o) throws Exception {
 
-		HtmlWriter w = getHtmlWriter(out);
-		HtmlDocTemplate t = getTemplate();
-
-		w.sTag("html").nl(0);
-		w.sTag(1, "head").nl(1);
-		t.head(this, w, o);
-		w.eTag(1, "head").nl(1);
-		w.sTag(1, "body").nl(1);
-		t.body(this, w, o);
-		w.eTag(1, "body").nl(1);
-		w.eTag("html").nl(0);
+		try (HtmlWriter w = getHtmlWriter(out)) {
+			HtmlDocTemplate t = getTemplate();
+
+			w.sTag("html").nl(0);
+			w.sTag(1, "head").nl(1);
+			t.head(this, w, o);
+			w.eTag(1, "head").nl(1);
+			w.sTag(1, "body").nl(1);
+			t.body(this, w, o);
+			w.eTag(1, "body").nl(1);
+			w.eTag("html").nl(0);
+		}
 	}
 
 	/**
@@ -245,11 +246,8 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
 	 * @throws Exception
 	 */
 	public void parentSerialize(Object out, Object o) throws Exception {
-		SerializerPipe pipe = createPipe(out);
-		try {
+		try (SerializerPipe pipe = createPipe(out)) {
 			super.doSerialize(pipe, o);
-		} finally  {
-			pipe.close();
 		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java
index 975cae4..2bde2c2 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java
@@ -36,7 +36,7 @@ import org.apache.juneau.xml.*;
 @SuppressWarnings({ "unchecked", "rawtypes" })
 public final class HtmlParserSession extends XmlParserSession {
 
-	private static final Set<String> whitespaceElements = new HashSet<String>(
+	private static final Set<String> whitespaceElements = new HashSet<>(
 		Arrays.asList(
 			new String[]{"br","bs","sp","ff"}
 		)
@@ -312,7 +312,7 @@ public final class HtmlParserSession extends XmlParserSession {
 	}
 
 	private static Map<String,String> getAttributes(XmlReader r) {
-		Map<String,String> m = new TreeMap<String,String>() ;
+		Map<String,String> m = new TreeMap<>() ;
 		for (int i = 0; i < r.getAttributeCount(); i++)
 			m.put(r.getAttributeLocalName(i), r.getAttributeValue(i));
 		return m;
@@ -375,7 +375,7 @@ public final class HtmlParserSession extends XmlParserSession {
 			ClassMeta<E> type, BeanPropertyMeta pMeta) throws Exception {
 
 		HtmlTag tag = nextTag(r, TR);
-		List<String> keys = new ArrayList<String>();
+		List<String> keys = new ArrayList<>();
 		while (true) {
 			tag = nextTag(r, TH, xTR);
 			if (tag == xTR)

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializerSession.java
index 847b40d..a530f12 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializerSession.java
@@ -116,7 +116,7 @@ public class HtmlSchemaDocSerializerSession extends HtmlDocSerializerSession {
 
 	@SuppressWarnings({ "unchecked", "rawtypes" })
 	private static List<String> getEnumStrings(Class<? extends Enum> c) {
-		List<String> l = new LinkedList<String>();
+		List<String> l = new LinkedList<>();
 		for (Object e : EnumSet.allOf(c))
 			l.add(e.toString());
 		return l;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
index 1cb1a6e..bd15915 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
@@ -384,7 +384,7 @@ public class HtmlSerializerSession extends XmlSerializerSession {
 		CR_NORMAL     // Normal content.  Use whitespace.
 	}
 
-	@SuppressWarnings({ "rawtypes", "unchecked" })
+	@SuppressWarnings({ "rawtypes" })
 	private void serializeMap(HtmlWriter out, Map m, ClassMeta<?> sType,
 			ClassMeta<?> eKeyType, ClassMeta<?> eValueType, String typeName, BeanPropertyMeta ppMeta) throws Exception {
 
@@ -694,7 +694,7 @@ public class HtmlSerializerSession extends XmlSerializerSession {
 			return null;
 		c = sort(c);
 		Object[] th;
-		Set<ClassMeta> prevC = new HashSet<ClassMeta>();
+		Set<ClassMeta> prevC = new HashSet<>();
 		Object o1 = null;
 		for (Object o : c)
 			if (o != null) {
@@ -723,7 +723,7 @@ public class HtmlSerializerSession extends XmlSerializerSession {
 		if (canIgnoreValue(cm, null, o1))
 			return null;
 		if (cm.isMap() && ! cm.isBeanMap()) {
-			Set<Object> set = new LinkedHashSet<Object>();
+			Set<Object> set = new LinkedHashSet<>();
 			for (Object o : c) {
 				if (! canIgnoreValue(cm, null, o)) {
 					if (! cm.isInstance(o))
@@ -737,7 +737,7 @@ public class HtmlSerializerSession extends XmlSerializerSession {
 			}
 			th = set.toArray(new Object[set.size()]);
 		} else {
-			Map<String,Boolean> m = new LinkedHashMap<String,Boolean>();
+			Map<String,Boolean> m = new LinkedHashMap<>();
 			for (Object o : c) {
 				if (! canIgnoreValue(cm, null, o)) {
 					if (! cm.isInstance(o))
@@ -761,7 +761,7 @@ public class HtmlSerializerSession extends XmlSerializerSession {
 		boolean isSortable = true;
 		for (Object o : th)
 			isSortable &= (o instanceof Comparable);
-		Set<Object> s = (isSortable ? new TreeSet<Object>() : new LinkedHashSet<Object>());
+		Set<Object> s = (isSortable ? new TreeSet<>() : new LinkedHashSet<>());
 		s.addAll(Arrays.asList(th));
 
 		for (Object o : c) {

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializerSession.java
index 7589781..31749e1 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializerSession.java
@@ -40,12 +40,13 @@ public class HtmlStrippedDocSerializerSession extends HtmlSerializerSession {
 
 	@Override /* SerializerSession */
 	protected void doSerialize(SerializerPipe out, Object o) throws Exception {
-		HtmlWriter w = getHtmlWriter(out);
-		if (o == null
-			|| (o instanceof Collection && ((Collection<?>)o).size() == 0)
-			|| (o.getClass().isArray() && Array.getLength(o) == 0))
-			w.sTag(1, "p").append("No Results").eTag("p").nl(1);
-		else
-			super.doSerialize(out, o);
+		try (HtmlWriter w = getHtmlWriter(out)) {
+			if (o == null
+				|| (o instanceof Collection && ((Collection<?>)o).size() == 0)
+				|| (o.getClass().isArray() && Array.getLength(o) == 0))
+				w.sTag(1, "p").append("No Results").eTag("p").nl(1);
+			else
+				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/html/HtmlTag.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlTag.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlTag.java
index e841931..663bf64 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlTag.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlTag.java
@@ -60,7 +60,7 @@ enum HtmlTag {
 	xP(-18, "</p>"),
 	xHTML(-19, "</html>");
 
-	private Map<Integer,HtmlTag> cache = new HashMap<Integer,HtmlTag>();
+	private Map<Integer,HtmlTag> cache = new HashMap<>();
 
 	int id;
 	String label;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/Accept.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/Accept.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/Accept.java
index 5b5c64f..f095f97 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/Accept.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/Accept.java
@@ -148,7 +148,7 @@ import org.apache.juneau.internal.*;
  */
 public final class Accept {
 
-	private static final Cache<String,Accept> cache = new Cache<String,Accept>(NOCACHE, CACHE_MAX_SIZE);
+	private static final Cache<String,Accept> cache = new Cache<>(NOCACHE, CACHE_MAX_SIZE);
 
 	/**
 	 * Returns a parsed <code>Accept</code> header.

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptCharset.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptCharset.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptCharset.java
index c17ec3f..39e6c79 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptCharset.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptCharset.java
@@ -76,7 +76,7 @@ import org.apache.juneau.internal.*;
  */
 public final class AcceptCharset extends HeaderRangeArray {
 
-	private static final Cache<String,AcceptCharset> cache = new Cache<String,AcceptCharset>(NOCACHE, CACHE_MAX_SIZE);
+	private static final Cache<String,AcceptCharset> cache = new Cache<>(NOCACHE, CACHE_MAX_SIZE);
 
 	/**
 	 * Returns a parsed <code>Accept-Charset</code> header.

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptEncoding.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptEncoding.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptEncoding.java
index c0cf845..9a8a516 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptEncoding.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptEncoding.java
@@ -96,7 +96,7 @@ import org.apache.juneau.internal.*;
  */
 public final class AcceptEncoding extends HeaderRangeArray {
 
-	private static final Cache<String,AcceptEncoding> cache = new Cache<String,AcceptEncoding>(NOCACHE, CACHE_MAX_SIZE);
+	private static final Cache<String,AcceptEncoding> cache = new Cache<>(NOCACHE, CACHE_MAX_SIZE);
 
 	/**
 	 * Returns a parsed <code>Accept-Encoding</code> header.

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptLanguage.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptLanguage.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptLanguage.java
index cd187d9..c855445 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptLanguage.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/AcceptLanguage.java
@@ -108,7 +108,7 @@ import org.apache.juneau.internal.*;
  */
 public final class AcceptLanguage extends HeaderRangeArray {
 
-	private static final Cache<String,AcceptLanguage> cache = new Cache<String,AcceptLanguage>(NOCACHE, CACHE_MAX_SIZE);
+	private static final Cache<String,AcceptLanguage> cache = new Cache<>(NOCACHE, CACHE_MAX_SIZE);
 
 	/**
 	 * Returns a parsed <code>Accept-Language</code> header.

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/ContentType.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/ContentType.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/ContentType.java
index 5bcc4ed..062a199 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/ContentType.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/ContentType.java
@@ -53,7 +53,7 @@ import org.apache.juneau.internal.*;
  */
 public class ContentType extends MediaType {
 
-	private static Cache<String,ContentType> cache = new Cache<String,ContentType>(NOCACHE, CACHE_MAX_SIZE);
+	private static Cache<String,ContentType> cache = new Cache<>(NOCACHE, CACHE_MAX_SIZE);
 
 	/**
 	 * Returns a parsed <code>Content-Type</code> header.

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/HttpMethod.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/HttpMethod.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/HttpMethod.java
index 58313a2..285a698 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/HttpMethod.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/HttpMethod.java
@@ -55,7 +55,7 @@ public enum HttpMethod {
 	/** A non-standard value. */
 	OTHER;
 
-	private static final Map<String,HttpMethod> cache = new TreeMap<String,HttpMethod>(String.CASE_INSENSITIVE_ORDER);
+	private static final Map<String,HttpMethod> cache = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
 	static {
 		cache.put("OPTIONS", OPTIONS);
 		cache.put("GET", GET);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaType.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaType.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaType.java
index 6f9c3db..4745c64 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaType.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaType.java
@@ -36,11 +36,10 @@ import org.apache.juneau.json.*;
  * </ul>
  */
 @BeanIgnore
-@SuppressWarnings("unchecked")
 public class MediaType implements Comparable<MediaType> {
 
 	private static final boolean nocache = Boolean.getBoolean("juneau.nocache");
-	private static final ConcurrentHashMap<String,MediaType> cache = new ConcurrentHashMap<String,MediaType>();
+	private static final ConcurrentHashMap<String,MediaType> cache = new ConcurrentHashMap<>();
 
 	/** Reusable predefined media type */
 	@SuppressWarnings("javadoc")
@@ -135,20 +134,20 @@ public class MediaType implements Comparable<MediaType> {
 		this.hasSubtypeMeta = b.hasSubtypeMeta;
 	}
 
-	private static class Builder {
+	static class Builder {
 		private String mediaType, type, subType;
 		private String[] subTypes, subTypesSorted;
 		private Map<String,Set<String>> parameters;
 		private boolean hasSubtypeMeta;
 
-		private Builder(String mt) {
+		Builder(String mt) {
 			mt = mt.trim();
 
 			int i = mt.indexOf(';');
 			if (i == -1) {
 				this.parameters = Collections.EMPTY_MAP;
 			} else {
-				this.parameters = new TreeMap<String,Set<String>>();
+				this.parameters = new TreeMap<>();
 				String[] tokens = mt.substring(i+1).split(";");
 
 				for (int j = 0; j < tokens.length; j++) {

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaTypeRange.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaTypeRange.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaTypeRange.java
index 0cdfd99..8d1ce59 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaTypeRange.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/MediaTypeRange.java
@@ -78,7 +78,7 @@ public final class MediaTypeRange implements Comparable<MediaTypeRange>  {
 		if (value.indexOf(',') == -1)
 			return new MediaTypeRange[]{new MediaTypeRange(value)};
 
-		Set<MediaTypeRange> ranges = new TreeSet<MediaTypeRange>();
+		Set<MediaTypeRange> ranges = new TreeSet<>();
 
 		for (String r : StringUtils.split(value)) {
 			r = r.trim();
@@ -92,7 +92,6 @@ public final class MediaTypeRange implements Comparable<MediaTypeRange>  {
 		return ranges.toArray(new MediaTypeRange[ranges.size()]);
 	}
 
-	@SuppressWarnings("unchecked")
 	private MediaTypeRange(String token) {
 		Builder b = new Builder(token);
 		this.mediaType = b.mediaType;
@@ -100,12 +99,12 @@ public final class MediaTypeRange implements Comparable<MediaTypeRange>  {
 		this.extensions = (b.extensions == null ? Collections.EMPTY_MAP : Collections.unmodifiableMap(b.extensions));
 	}
 
-	private static class Builder {
-		private MediaType mediaType;
-		private Float qValue = 1f;
-		private Map<String,Set<String>> extensions;
+	static class Builder {
+		MediaType mediaType;
+		Float qValue = 1f;
+		Map<String,Set<String>> extensions;
 
-		private Builder(String token) {
+		Builder(String token) {
 
 			token = token.trim();
 
@@ -129,7 +128,7 @@ public final class MediaTypeRange implements Comparable<MediaTypeRange>  {
 						String k = parm[0], v = parm[1];
 						if (isInExtensions) {
 							if (extensions == null)
-								extensions = new TreeMap<String,Set<String>>();
+								extensions = new TreeMap<>();
 							if (! extensions.containsKey(k))
 								extensions.put(k, new TreeSet<String>());
 							extensions.get(k).add(v);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/StringRange.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/StringRange.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/StringRange.java
index 593a02d..9ae0bea 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/StringRange.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/StringRange.java
@@ -85,7 +85,7 @@ public final class StringRange implements Comparable<StringRange>  {
 		if (value.indexOf(',') == -1)
 			return new StringRange[]{new StringRange(value)};
 
-		Set<StringRange> ranges = new TreeSet<StringRange>();
+		Set<StringRange> ranges = new TreeSet<>();
 
 		for (String r : StringUtils.split(value)) {
 			r = r.trim();
@@ -99,7 +99,6 @@ public final class StringRange implements Comparable<StringRange>  {
 		return ranges.toArray(new StringRange[ranges.size()]);
 	}
 
-	@SuppressWarnings("unchecked")
 	private StringRange(String token) {
 		Builder b = new Builder(token);
 		this.type = b.type;
@@ -136,7 +135,7 @@ public final class StringRange implements Comparable<StringRange>  {
 						String k = parm[0], v = parm[1];
 						if (isInExtensions) {
 							if (extensions == null)
-								extensions = new TreeMap<String,Set<String>>();
+								extensions = new TreeMap<>();
 							if (! extensions.containsKey(k))
 								extensions.put(k, new TreeSet<String>());
 							extensions.get(k).add(v);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/TE.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/TE.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/TE.java
index 282f891..e944191 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/TE.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/TE.java
@@ -93,7 +93,7 @@ import org.apache.juneau.internal.*;
  */
 public final class TE extends HeaderRangeArray {
 
-	private static final Cache<String,TE> cache = new Cache<String,TE>(NOCACHE, CACHE_MAX_SIZE);
+	private static final Cache<String,TE> cache = new Cache<>(NOCACHE, CACHE_MAX_SIZE);
 
 	/**
 	 * Returns a parsed <code>Accept</code> header.

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ArrayUtils.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ArrayUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ArrayUtils.java
index 9221bff..7181ed2 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ArrayUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ArrayUtils.java
@@ -231,7 +231,7 @@ public final class ArrayUtils {
 	 */
 	@SuppressWarnings("unchecked")
 	public static <T> List<T> toList(Object array, Class<T> componentType) {
-		List<T> l = new ArrayList<T>(Array.getLength(array));
+		List<T> l = new ArrayList<>(Array.getLength(array));
 		for (int i = 0; i < Array.getLength(array); i++)
 			l.add((T)Array.get(array, i));
 		return l;
@@ -370,7 +370,7 @@ public final class ArrayUtils {
 	 * @return A new list of objects copied from the iterable.
 	 */
 	public static List<?> toList(Iterable<?> i) {
-		List<Object> l = new ArrayList<Object>();
+		List<Object> l = new ArrayList<>();
 		Iterator<?> i2 = i.iterator();
 		while (i2.hasNext())
 			l.add(i2.next());

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ByteArrayCache.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ByteArrayCache.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ByteArrayCache.java
index 0dde655..dc90746 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ByteArrayCache.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ByteArrayCache.java
@@ -29,7 +29,7 @@ public class ByteArrayCache {
 	 */
 	public static final ByteArrayCache DEFAULT = new ByteArrayCache();
 
-	private final ConcurrentHashMap<ByteArray,byte[]> cache = new ConcurrentHashMap<ByteArray,byte[]>();
+	private final ConcurrentHashMap<ByteArray,byte[]> cache = new ConcurrentHashMap<>();
 
 	/**
 	 * Add the specified byte array to this cache.
@@ -73,11 +73,11 @@ public class ByteArrayCache {
 		return cache.size();
 	}
 
-	private static class ByteArray {
-		private int hashCode;
-		private byte[] contents;
+	static final class ByteArray {
+		int hashCode;
+		byte[] contents;
 
-		private ByteArray(byte[] contents) {
+		ByteArray(byte[] contents) {
 			this.contents = contents;
 			int multiplier = 1;
 			for (int i = 0; i < contents.length; i++) {

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/Cache.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/Cache.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/Cache.java
index e811bf5..65bf6f6 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/Cache.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/Cache.java
@@ -38,7 +38,7 @@ public class Cache<K,V> {
 		this.nocache = disabled;
 		this.maxSize = maxSize;
 		if (! nocache)
-			cache = new ConcurrentHashMap<K,V>();
+			cache = new ConcurrentHashMap<>();
 		else
 			cache = null;
 	}

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java
index a42684c..8ee3811 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java
@@ -200,8 +200,8 @@ public final class ClassUtils {
 	}
 
 	private final static Map<Class<?>, Class<?>>
-		pmap1 = new HashMap<Class<?>, Class<?>>(),
-		pmap2 = new HashMap<Class<?>, Class<?>>();
+		pmap1 = new HashMap<>(),
+		pmap2 = new HashMap<>();
 	static {
 		pmap1.put(boolean.class, Boolean.class);
 		pmap1.put(byte.class, Byte.class);
@@ -450,7 +450,7 @@ public final class ClassUtils {
 	public static Class<?> resolveParameterType(Class<?> c, int index, Class<?> oc) {
 
 		// We need to make up a mapping of type names.
-		Map<Type,Type> typeMap = new HashMap<Type,Type>();
+		Map<Type,Type> typeMap = new HashMap<>();
 		while (c != oc.getSuperclass()) {
 			extractTypes(typeMap, oc);
 			oc = oc.getSuperclass();
@@ -477,12 +477,12 @@ public final class ClassUtils {
 
 		} else if (actualType instanceof TypeVariable) {
 			TypeVariable<?> typeVariable = (TypeVariable<?>)actualType;
-			List<Class<?>> nestedOuterTypes = new LinkedList<Class<?>>();
+			List<Class<?>> nestedOuterTypes = new LinkedList<>();
 			for (Class<?> ec = oc.getEnclosingClass(); ec != null; ec = ec.getEnclosingClass()) {
 				try {
 					Class<?> outerClass = oc.getClass();
 					nestedOuterTypes.add(outerClass);
-					Map<Type,Type> outerTypeMap = new HashMap<Type,Type>();
+					Map<Type,Type> outerTypeMap = new HashMap<>();
 					extractTypes(outerTypeMap, outerClass);
 					for (Map.Entry<Type,Type> entry : outerTypeMap.entrySet()) {
 						Type key = entry.getKey(), value = entry.getValue();
@@ -820,7 +820,7 @@ public final class ClassUtils {
 				if (con != null)
 					return (T)con.newInstance(args);
 				if (outer != null) {
-					Object[] args2 = new AList<Object>().append(outer).appendAll(args).toArray();
+					Object[] args2 = new AList<>().append(outer).appendAll(args).toArray();
 					con = findPublicConstructor(c3, args2);
 					if (con != null)
 						return (T)con.newInstance(args2);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/CollectionUtils.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/CollectionUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/CollectionUtils.java
index ce3bccf..1e76346 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/CollectionUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/CollectionUtils.java
@@ -28,12 +28,12 @@ public class CollectionUtils {
 	public static <K,V> LinkedHashMap<K,V> reverse(Map<K,V> in) {
 		if (in == null)
 			return null;
-		LinkedHashMap<K,V> m = new LinkedHashMap<K,V>();
+		LinkedHashMap<K,V> m = new LinkedHashMap<>();
 
 		// Note:  Entry objects are reusable in an entry set, so we simply can't
 		// create a reversed iteration of that set.
-		List<K> keys = new ArrayList<K>(in.keySet());
-		List<V> values = new ArrayList<V>(in.values());
+		List<K> keys = new ArrayList<>(in.keySet());
+		List<V> values = new ArrayList<>(in.values());
 		for (int i = in.size()-1; i >= 0; i--)
 			m.put(keys.get(i), values.get(i));
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/DateUtils.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/DateUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/DateUtils.java
index bf07973..63ad26a 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/DateUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/DateUtils.java
@@ -185,8 +185,8 @@ public final class DateUtils {
 			final SoftReference<Map<String,SimpleDateFormat>> ref = THREADLOCAL_FORMATS.get();
 			Map<String,SimpleDateFormat> formats = ref.get();
 			if (formats == null) {
-				formats = new HashMap<String,SimpleDateFormat>();
-				THREADLOCAL_FORMATS.set(new SoftReference<Map<String,SimpleDateFormat>>(formats));
+				formats = new HashMap<>();
+				THREADLOCAL_FORMATS.set(new SoftReference<>(formats));
 			}
 			SimpleDateFormat format = formats.get(pattern);
 			if (format == null) {

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/DelegateBeanMap.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/DelegateBeanMap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/DelegateBeanMap.java
index 69563f3..8b41f09 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/DelegateBeanMap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/DelegateBeanMap.java
@@ -92,7 +92,7 @@ public class DelegateBeanMap<T> extends BeanMap<T> {
 
 	@Override /* BeanMap */
 	public BeanMeta<T> getMeta() {
-		return new BeanMetaFiltered<T>(super.getMeta(), keys);
+		return new BeanMetaFiltered<>(super.getMeta(), keys);
 	}
 
 	@Override /* Map */
@@ -113,7 +113,7 @@ public class DelegateBeanMap<T> extends BeanMap<T> {
 
 	@Override /* BeanMap */
 	public Collection<BeanPropertyMeta> getProperties() {
-		List<BeanPropertyMeta> l = new ArrayList<BeanPropertyMeta>(keys.size());
+		List<BeanPropertyMeta> l = new ArrayList<>(keys.size());
 		for (final String key : keys) {
 			BeanPropertyMeta p = this.getPropertyMeta(key);
 			if (overrideValues.containsKey(key))
@@ -125,10 +125,10 @@ public class DelegateBeanMap<T> extends BeanMap<T> {
 		return l;
 	}
 
-	private class BeanMapEntryOverride extends BeanMapEntry {
+	final class BeanMapEntryOverride extends BeanMapEntry {
 		Object value;
 
-		private BeanMapEntryOverride(BeanMap<?> bm, BeanPropertyMeta bpm, Object value) {
+		BeanMapEntryOverride(BeanMap<?> bm, BeanPropertyMeta bpm, Object value) {
 			super(bm, bpm, bpm.getName());
 			this.value = value;
 		}

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FileReaderBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FileReaderBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FileReaderBuilder.java
new file mode 100644
index 0000000..0664645
--- /dev/null
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FileReaderBuilder.java
@@ -0,0 +1,116 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
+// * with the License.  You may obtain a copy of the License at                                                              *
+// *                                                                                                                         *
+// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
+// *                                                                                                                         *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
+// * specific language governing permissions and limitations under the License.                                              *
+// ***************************************************************************************************************************
+package org.apache.juneau.internal;
+
+import java.io.*;
+import java.nio.charset.*;
+
+/**
+ * Utility class for creating {@link FileReader} objects.
+ */
+public final class FileReaderBuilder {
+	
+	private File file;
+	private Charset cs = Charset.defaultCharset();
+	private boolean allowNoFile;
+	
+	/**
+	 * Creates a new builder.
+	 * 
+	 * @return A new builder.
+	 */
+	public static FileReaderBuilder create() {
+		return new FileReaderBuilder();
+	}
+	
+	/**
+	 * Creates a new builder initialized with the specified file.
+	 * 
+	 * @param file The file being written to.
+	 * @return A new builder.
+	 */
+	public static FileReaderBuilder create(File file) {
+		return new FileReaderBuilder().file(file);
+	}
+	
+	/**
+	 * Sets the file being written from.
+	 * 
+	 * @param file The file being written from.
+	 * @return This object (for method chaining).
+	 */
+	public FileReaderBuilder file(File file) {
+		this.file = file;
+		return this;
+	}
+	
+	/**
+	 * Sets the path of the file being written from.
+	 * 
+	 * @param path The path of the file being written from.
+	 * @return This object (for method chaining).
+	 */
+	public FileReaderBuilder file(String path) {
+		this.file = new File(path);
+		return this;
+	}
+	
+	/**
+	 * Sets the character encoding of the file.
+	 * 
+	 * @param cs 
+	 * 	The character encoding.
+	 * 	The default is {@link Charset#defaultCharset()}.  
+	 * @return This object (for method chaining).
+	 */
+	public FileReaderBuilder charset(Charset cs) {
+		this.cs = cs;
+		return this;
+	}
+	
+	/**
+	 * Sets the character encoding of the file.
+	 * 
+	 * @param cs 
+	 * 	The character encoding.
+	 * 	The default is {@link Charset#defaultCharset()}.  
+	 * @return This object (for method chaining).
+	 */
+	public FileReaderBuilder charset(String cs) {
+		this.cs = Charset.forName(cs);
+		return this;
+	}
+	
+	/**
+	 * If called and the file is <jk>null</jk> or non-existent, then the {@link #build()} command will return an empty
+	 * reader instead of a {@link FileNotFoundException}.
+	 * 
+	 * @return This object (for method chaining).
+	 */
+	public FileReaderBuilder allowNoFile() {
+		this.allowNoFile = true;
+		return this;
+	}
+	
+	/**
+	 * Creates a new File reader.
+	 * 
+	 * @return A new File reader. 
+	 * @throws FileNotFoundException If file could not be found.
+	 */
+	public Reader build() throws FileNotFoundException {
+		if (allowNoFile && (file == null || ! file.exists()))
+			return new StringReader("");
+		return new InputStreamReader(new FileInputStream(file), cs);
+	}
+}

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FileWriterBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FileWriterBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FileWriterBuilder.java
new file mode 100644
index 0000000..dfb4f6d
--- /dev/null
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FileWriterBuilder.java
@@ -0,0 +1,123 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
+// * with the License.  You may obtain a copy of the License at                                                              *
+// *                                                                                                                         *
+// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
+// *                                                                                                                         *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
+// * specific language governing permissions and limitations under the License.                                              *
+// ***************************************************************************************************************************
+package org.apache.juneau.internal;
+
+import java.io.*;
+import java.nio.charset.*;
+
+/**
+ * Utility class for creating {@link FileWriter} objects.
+ */
+public final class FileWriterBuilder {
+	
+	private File file;
+	private Charset cs = Charset.defaultCharset();
+	private boolean append;
+	
+	/**
+	 * Creates a new builder.
+	 * 
+	 * @return A new builder.
+	 */
+	public static FileWriterBuilder create() {
+		return new FileWriterBuilder();
+	}
+	
+	/**
+	 * Creates a new builder initialized with the specified file.
+	 * 
+	 * @param file The file being written to.
+	 * @return A new builder.
+	 */
+	public static FileWriterBuilder create(File file) {
+		return new FileWriterBuilder().file(file);
+	}
+
+	/**
+	 * Creates a new builder initialized with the specified file path.
+	 * 
+	 * @param path The file path being written to.
+	 * @return A new builder.
+	 */
+	public static FileWriterBuilder create(String path) {
+		return new FileWriterBuilder().file(path);
+	}
+	
+	/**
+	 * Sets the file being written to.
+	 * 
+	 * @param file The file being written to.
+	 * @return This object (for method chaining).
+	 */
+	public FileWriterBuilder file(File file) {
+		this.file = file;
+		return this;
+	}
+	
+	/**
+	 * Sets the path of the file being written to.
+	 * 
+	 * @param path The path of the file being written to.
+	 * @return This object (for method chaining).
+	 */
+	public FileWriterBuilder file(String path) {
+		this.file = new File(path);
+		return this;
+	}
+	
+	/**
+	 * Sets the character encoding of the file.
+	 * 
+	 * @param cs 
+	 * 	The character encoding.
+	 * 	The default is {@link Charset#defaultCharset()}.  
+	 * @return This object (for method chaining).
+	 */
+	public FileWriterBuilder charset(Charset cs) {
+		this.cs = cs;
+		return this;
+	}
+	
+	/**
+	 * Sets the character encoding of the file.
+	 * 
+	 * @param cs 
+	 * 	The character encoding.
+	 * 	The default is {@link Charset#defaultCharset()}.  
+	 * @return This object (for method chaining).
+	 */
+	public FileWriterBuilder charset(String cs) {
+		this.cs = Charset.forName(cs);
+		return this;
+	}
+	
+	/**
+	 * Sets the append mode on the writer to <jk>true</jk>.
+	 * 
+	 * @return This object (for method chaining).
+	 */
+	public FileWriterBuilder append() {
+		this.append = true;
+		return this;
+	}
+		
+	/**
+	 * Creates a new File writer.
+	 * 
+	 * @return A new File writer. 
+	 * @throws FileNotFoundException If file could not be found.
+	 */
+	public Writer build() throws FileNotFoundException {
+		return new OutputStreamWriter(new FileOutputStream(file, append), cs);
+	}
+}

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FilteredMap.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FilteredMap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FilteredMap.java
index 1321112..41b8633 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FilteredMap.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/FilteredMap.java
@@ -43,11 +43,11 @@ public final class FilteredMap<K,V> extends AbstractMap<K,V> implements Delegate
 
 		this.classMeta = classMeta;
 		this.innerMap = innerMap;
-			List<Map.Entry<K,V>> l = new ArrayList<Map.Entry<K,V>>(keys.length);
+			List<Map.Entry<K,V>> l = new ArrayList<>(keys.length);
 			for (K k : keys)
 				if (innerMap.containsKey(k))
 					l.add(createEntry(k));
-			entries = new ListSet<Map.Entry<K,V>>(l);
+			entries = new ListSet<>(l);
 		}
 
 	private Map.Entry<K,V> createEntry(final K key) {

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/IOUtils.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/IOUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/IOUtils.java
index c8018bf..a17ae60 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/IOUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/IOUtils.java
@@ -49,8 +49,9 @@ public final class IOUtils {
 	public static String read(File in) throws IOException {
 		if (in == null || ! in.exists())
 			return null;
-		Reader r = new InputStreamReader(new FileInputStream(in), Charset.defaultCharset());
-		return read(r, 0, 1024);
+		try (Reader r = FileReaderBuilder.create(in).build()) {
+			return read(r, 0, 1024);
+		}
 	}
 
 	/**
@@ -95,11 +96,8 @@ public final class IOUtils {
 	public static int write(File out, Reader in) throws IOException {
 		assertFieldNotNull(out, "out");
 		assertFieldNotNull(in, "in");
-		Writer w = new OutputStreamWriter(new FileOutputStream(out), Charset.defaultCharset());
-		try {
-			return IOPipe.create(in, w).closeOut().run();
-		} finally {
-			w.close();
+		try (Writer w = FileWriterBuilder.create(out).build()) {
+			return IOPipe.create(in, w).run();
 		}
 	}
 
@@ -114,11 +112,8 @@ public final class IOUtils {
 	public static int write(File out, InputStream in) throws IOException {
 		assertFieldNotNull(out, "out");
 		assertFieldNotNull(in, "in");
-		OutputStream os = new FileOutputStream(out);
-		try {
-			return IOPipe.create(in, os).closeOut().run();
-		} finally {
-			os.close();
+		try (OutputStream os = new FileOutputStream(out)) {
+			return IOPipe.create(in, os).run();
 		}
 	}
 
@@ -197,11 +192,8 @@ public final class IOUtils {
 		if (f == null || ! (f.exists() && f.canRead()))
 			return null;
 
-		FileInputStream fis = new FileInputStream(f);
-		try {
+		try (FileInputStream fis = new FileInputStream(f)) {
 			return readBytes(fis, (int)f.length());
-		} finally {
-			fis.close();
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/JuneauLogger.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/JuneauLogger.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/JuneauLogger.java
index cb2344f..93db12a 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/JuneauLogger.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/JuneauLogger.java
@@ -39,7 +39,7 @@ public class JuneauLogger extends java.util.logging.Logger {
 		.simple()
 		.build();
 
-	private static final ConcurrentHashMap<Class<?>,String> rbMap = new ConcurrentHashMap<Class<?>,String>();
+	private static final ConcurrentHashMap<Class<?>,String> rbMap = new ConcurrentHashMap<>();
 
 	private final ResourceBundle rb;
 	private final java.util.logging.Logger innerLogger;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/MultiIterable.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/MultiIterable.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/MultiIterable.java
index 38852bb..c283076 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/MultiIterable.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/MultiIterable.java
@@ -23,7 +23,7 @@ import java.util.*;
  */
 public class MultiIterable<E> implements Iterable<E> {
 
-	final List<Iterator<E>> iterators = new LinkedList<Iterator<E>>();
+	final List<Iterator<E>> iterators = new LinkedList<>();
 
 	/**
 	 * Constructor.

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/MultiSet.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/MultiSet.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/MultiSet.java
index 32615a7..e79626f 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/MultiSet.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/MultiSet.java
@@ -24,7 +24,7 @@ import java.util.*;
 public class MultiSet<E> extends AbstractSet<E> {
 
 	/** Inner collections. */
-	private List<Collection<E>> l = new ArrayList<Collection<E>>();
+	private List<Collection<E>> l = new ArrayList<>();
 
 	/**
 	 * Create a new Set that consists as a coalesced set of the specified collections.

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/NoCloseOutputStream.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/NoCloseOutputStream.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/NoCloseOutputStream.java
new file mode 100644
index 0000000..a005e76
--- /dev/null
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/NoCloseOutputStream.java
@@ -0,0 +1,60 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
+// * with the License.  You may obtain a copy of the License at                                                              *
+// *                                                                                                                         *
+// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
+// *                                                                                                                         *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
+// * specific language governing permissions and limitations under the License.                                              *
+// ***************************************************************************************************************************
+package org.apache.juneau.internal;
+
+import java.io.*;
+
+/**
+ * Wraps an existing {@link OutputStream} where the {@link #close()} method is a no-op.
+ * 
+ * <p>
+ * Useful in cases where you're working with streams that should not be implicitly closed.
+ */
+public final class NoCloseOutputStream extends OutputStream {
+
+	private final OutputStream os;
+	
+	/**
+	 * Constructor.
+	 * 
+	 * @param os The output stream to wrap.
+	 */
+	public NoCloseOutputStream(OutputStream os) {
+		this.os = os;
+	}
+	
+	@Override /* OutputStream */
+	public void write(int b) throws IOException {
+		os.write(b);
+	}
+	
+	@Override /* OutputStream */
+	public void write(byte[] b) throws IOException {
+		os.write(b);
+	}
+	
+	@Override /* OutputStream */
+	public void write(byte[] b, int off, int len) throws IOException {
+		os.write(b, off, len);
+	}
+	
+	@Override /* OutputStream */
+	public void flush() throws IOException {
+		os.flush();
+	}
+	
+	@Override /* OutputStream */
+	public void close() throws IOException {
+		os.flush();
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/NoCloseWriter.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/NoCloseWriter.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/NoCloseWriter.java
new file mode 100644
index 0000000..c088879
--- /dev/null
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/NoCloseWriter.java
@@ -0,0 +1,85 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
+// * with the License.  You may obtain a copy of the License at                                                              *
+// *                                                                                                                         *
+// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
+// *                                                                                                                         *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
+// * specific language governing permissions and limitations under the License.                                              *
+// ***************************************************************************************************************************
+package org.apache.juneau.internal;
+
+import java.io.*;
+
+/**
+ * Wraps an existing {@link Writer} where the {@link #close()} method is a no-op.
+ * 
+ * <p>
+ * Useful in cases where you're working with streams that should not be implicitly closed.
+ */
+public final class NoCloseWriter extends Writer {
+
+	private final Writer w;
+	
+	/**
+	 * Constructor.
+	 * 
+	 * @param w The writer to wrap.
+	 */
+	public NoCloseWriter(Writer w) {
+		this.w = w;
+	}
+	
+	@Override /* Writer */
+	public Writer append(char c) throws IOException {
+		return w.append(c);
+	}
+	
+	@Override /* Writer */
+	public Writer append(CharSequence csq) throws IOException {
+		return w.append(csq);
+	}
+	
+	@Override /* Writer */
+	public Writer append(CharSequence csq, int start, int end) throws IOException {
+		return w.append(csq, start, end);
+	}
+	
+	@Override /* Writer */
+	public void close() throws IOException {
+		w.flush();
+	}
+	
+	@Override /* Writer */
+	public void flush() throws IOException {
+		w.flush();
+	}
+	
+	@Override /* Writer */
+	public void write(char[] cbuf) throws IOException {
+		w.write(cbuf);
+	}
+	
+	@Override /* Writer */
+	public void write(char[] cbuf, int off, int len) throws IOException {
+		w.write(cbuf, off, len);
+	}
+	
+	@Override /* Writer */
+	public void write(int c) throws IOException {
+		w.write(c);
+	}
+	
+	@Override /* Writer */
+	public void write(String str) throws IOException {
+		w.write(str);
+	}
+	
+	@Override /* Writer */
+	public void write(String str, int off, int len) throws IOException {
+		w.write(str, off, len);
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ReflectionUtils.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ReflectionUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ReflectionUtils.java
index 644ff3e..6d0e80b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ReflectionUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ReflectionUtils.java
@@ -84,7 +84,7 @@ public final class ReflectionUtils {
 	 * @return The found matches, or an empty array if annotation was not found.
 	 */
 	public static <T extends Annotation> List<T> findAnnotations(Class<T> a, Class<?> c) {
-		List<T> l = new LinkedList<T>();
+		List<T> l = new LinkedList<>();
 		appendAnnotations(a, c, l);
 		return l;
 	}
@@ -115,7 +115,7 @@ public final class ReflectionUtils {
 	 * @return The found matches, or an empty map if annotation was not found.
 	 */
 	public static <T extends Annotation> LinkedHashMap<Class<?>,T> findAnnotationsMap(Class<T> a, Class<?> c) {
-		LinkedHashMap<Class<?>,T> m = new LinkedHashMap<Class<?>,T>();
+		LinkedHashMap<Class<?>,T> m = new LinkedHashMap<>();
 		findAnnotationsMap(a, c, m);
 		return m;
 	}

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
index 8ad75c8..70109ca 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
@@ -313,10 +313,9 @@ public final class StringUtils {
 	 */
 	public static String getStackTrace(Throwable t) {
 		StringWriter sw = new StringWriter();
-		PrintWriter pw = new PrintWriter(sw);
-		t.printStackTrace(pw);
-		pw.flush();
-		pw.close();
+		try (PrintWriter pw = new PrintWriter(sw)) {
+			t.printStackTrace(pw);
+		}
 		return sw.toString();
 	}
 
@@ -504,7 +503,7 @@ public final class StringUtils {
 		if (s.indexOf(c) == -1)
 			return new String[]{s};
 
-		List<String> l = new LinkedList<String>();
+		List<String> l = new LinkedList<>();
 		char[] sArray = s.toCharArray();
 		int x1 = 0, escapeCount = 0;
 		for (int i = 0; i < sArray.length; i++) {
@@ -534,7 +533,7 @@ public final class StringUtils {
 	public static String[] split(String[] s, char c) {
 		if (s == null)
 			return null;
-		List<String> l = new LinkedList<String>();
+		List<String> l = new LinkedList<>();
 		for (String ss : s) {
 			if (ss == null || ss.indexOf(c) == -1)
 				l.add(ss);
@@ -560,7 +559,6 @@ public final class StringUtils {
 	 * @param trim Trim strings after parsing.
 	 * @return The parsed map.  Never <jk>null</jk>.
 	 */
-	@SuppressWarnings("unchecked")
 	public static Map<String,String> splitMap(String s, char delim, char eq, boolean trim) {
 
 		char[] unEscapeChars = new char[]{'\\', delim, eq};
@@ -570,7 +568,7 @@ public final class StringUtils {
 		if (isEmpty(s))
 			return Collections.EMPTY_MAP;
 
-		Map<String,String> m = new LinkedHashMap<String,String>();
+		Map<String,String> m = new LinkedHashMap<>();
 
 		int
 			S1 = 1,  // Found start of key, looking for equals.
@@ -1212,6 +1210,21 @@ public final class StringUtils {
 		return cs.decode(buff).toString();
 	}
 
+	/**
+	 * Converts a space-deliminted hexadecimal byte stream (e.g. "34 A5 BC") into a UTF-8 encoded string.
+	 *
+	 * @param hex The hexadecimal string.
+	 * @return The UTF-8 string.
+	 */
+	public static String fromSpacedHexToUTF8(String hex) {
+		ByteBuffer buff = ByteBuffer.allocate((hex.length()+1)/3);
+		for (int i = 0; i < hex.length(); i+=3)
+			buff.put((byte)Integer.parseInt(hex.substring(i, i+2), 16));
+		buff.rewind();
+		Charset cs = Charset.forName("UTF-8");
+		return cs.decode(buff).toString();
+	}
+
 	private final static char[] HEX = "0123456789ABCDEF".toCharArray();
 
 	/**
@@ -1222,7 +1235,24 @@ public final class StringUtils {
 	 */
 	public static String toHex(byte[] bytes) {
 		StringBuilder sb = new StringBuilder(bytes.length * 2);
-		for ( int j = 0; j < bytes.length; j++ ) {
+		for (int j = 0; j < bytes.length; j++) {
+			int v = bytes[j] & 0xFF;
+			sb.append(HEX[v >>> 4]).append(HEX[v & 0x0F]);
+		}
+		return sb.toString();
+	}
+
+	/**
+	 * Same as {@link #toHex(byte[])} but puts spaces between the byte strings.
+	 *
+	 * @param bytes The bytes to convert to hexadecimal.
+	 * @return A new string consisting of hexadecimal characters.
+	 */
+	public static String toSpacedHex(byte[] bytes) {
+		StringBuilder sb = new StringBuilder(bytes.length * 3);
+		for (int j = 0; j < bytes.length; j++) {
+			if (j > 0)
+				sb.append(' ');
 			int v = bytes[j] & 0xFF;
 			sb.append(HEX[v >>> 4]).append(HEX[v & 0x0F]);
 		}
@@ -1244,6 +1274,20 @@ public final class StringUtils {
 	}
 
 	/**
+	 * Same as {@link #fromHex(String)} except expects spaces between the byte strings.
+	 *
+	 * @param hex The string to convert to a byte array.
+	 * @return A new byte array.
+	 */
+	public static byte[] fromSpacedHex(String hex) {
+		ByteBuffer buff = ByteBuffer.allocate((hex.length()+1)/3);
+		for (int i = 0; i < hex.length(); i+=3)
+			buff.put((byte)Integer.parseInt(hex.substring(i, i+2), 16));
+		buff.rewind();
+		return buff.array();
+	}
+
+	/**
 	 * Creates a repeated pattern.
 	 *
 	 * @param count The number of times to repeat the pattern.

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/TeeOutputStream.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/TeeOutputStream.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/TeeOutputStream.java
index 96dfe73..0c312ab 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/TeeOutputStream.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/TeeOutputStream.java
@@ -92,7 +92,7 @@ public class TeeOutputStream extends OutputStream {
 	public TeeOutputStream add(String id, OutputStream os, boolean close) {
 		if (id != null) {
 			if (outputStreamMap == null)
-				outputStreamMap = new TreeMap<String,OutputStream>();
+				outputStreamMap = new TreeMap<>();
 			outputStreamMap.put(id, os);
 		}
 		return add(os, close);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/TeeWriter.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/TeeWriter.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/TeeWriter.java
index be48416..d0920e2 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/TeeWriter.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/TeeWriter.java
@@ -79,7 +79,7 @@ public class TeeWriter extends Writer {
 	public TeeWriter add(String id, Writer w, boolean close) {
 		if (id != null) {
 			if (writerMap == null)
-				writerMap = new TreeMap<String,Writer>();
+				writerMap = new TreeMap<>();
 			writerMap.put(id, w);
 		}
 		return add(w, close);

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializerSession.java
index 5aef62a..83b8c42 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializerSession.java
@@ -43,9 +43,8 @@ public class JsoSerializerSession extends OutputStreamSerializerSession {
 
 	@Override /* OutputStreamSerializerSession */
 	protected void doSerialize(SerializerPipe out, Object o) throws Exception {
-		ObjectOutputStream oos = new ObjectOutputStream(out.getOutputStream());
-		oos.writeObject(o);
-		oos.flush();
-		oos.close();
+		try (ObjectOutputStream oos = new ObjectOutputStream(out.getOutputStream())) {
+			oos.writeObject(o);
+		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
index 2373ac2..a5b61e7 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
@@ -81,34 +81,37 @@ public final class JsonParserSession 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/json/JsonSchemaSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSchemaSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSchemaSerializerSession.java
index 9a782ae..9ca88ea 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSchemaSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSchemaSerializerSession.java
@@ -120,7 +120,7 @@ public class JsonSchemaSerializerSession extends JsonSerializerSession {
 
 	@SuppressWarnings({ "unchecked", "rawtypes" })
 	private static List<String> getEnumStrings(Class<? extends Enum> c) {
-		List<String> l = new LinkedList<String>();
+		List<String> l = new LinkedList<>();
 		for (Object e : EnumSet.allOf(c))
 			l.add(e.toString());
 		return l;

http://git-wip-us.apache.org/repos/asf/juneau/blob/d1258753/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParserSession.java
index e559bb2..1361437 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParserSession.java
@@ -45,9 +45,9 @@ public final class MsgPackParserSession extends InputStreamParserSession {
 
 	@Override /* ParserSession */
 	protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception {
-		MsgPackInputStream is = new MsgPackInputStream(pipe);
-		T o = parseAnything(type, is, getOuter(), null);
-		return o;
+		try (MsgPackInputStream is = new MsgPackInputStream(pipe)) {
+			return parseAnything(type, is, getOuter(), null);
+		}
 	}
 
 	/*
@@ -56,7 +56,7 @@ public final class MsgPackParserSession extends InputStreamParserSession {
 	private <T> T parseAnything(ClassMeta<?> eType, MsgPackInputStream is, 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/msgpack/MsgPackSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java
index 5bf892c..28b0d31 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java
@@ -169,7 +169,7 @@ public final class MsgPackSerializerSession extends OutputStreamSerializerSessio
 
 		// The map size may change as we're iterating over it, so
 		// grab a snapshot of the entries in a separate list.
-		List<SimpleMapEntry> entries = new ArrayList<SimpleMapEntry>(m.size());
+		List<SimpleMapEntry> entries = new ArrayList<>(m.size());
 		for (Map.Entry e : (Set<Map.Entry>)m.entrySet())
 			entries.add(new SimpleMapEntry(e.getKey(), e.getValue()));
 
@@ -209,11 +209,11 @@ public final class MsgPackSerializerSession extends OutputStreamSerializerSessio
 		}
 	}
 
-	private static class SimpleMapEntry {
+	final static class SimpleMapEntry {
 		final Object key;
 		final Object value;
 
-		private SimpleMapEntry(Object key, Object value) {
+		SimpleMapEntry(Object key, Object value) {
 			this.key = key;
 			this.value = value;
 		}
@@ -223,7 +223,7 @@ public final class MsgPackSerializerSession extends OutputStreamSerializerSessio
 	private void serializeCollection(MsgPackOutputStream out, Collection c, ClassMeta<?> type) throws Exception {
 
 		ClassMeta<?> elementType = type.getElementType();
-		List<Object> l = new ArrayList<Object>(c.size());
+		List<Object> l = new ArrayList<>(c.size());
 
 		c = sort(c);
 		l.addAll(c);



Mime
View raw message