From 3a4c7c9c93dc537d1f33d252a2ac7f18e211334b Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 12 Jul 2013 08:25:19 +0200 Subject: [PATCH] Also dissallow null elements on set --- .../io/netty/util/internal/RecyclableArrayList.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/io/netty/util/internal/RecyclableArrayList.java b/common/src/main/java/io/netty/util/internal/RecyclableArrayList.java index 9e1cac24d4..2f9668d497 100644 --- a/common/src/main/java/io/netty/util/internal/RecyclableArrayList.java +++ b/common/src/main/java/io/netty/util/internal/RecyclableArrayList.java @@ -25,7 +25,7 @@ import java.util.List; import java.util.RandomAccess; /** - * A simple list that holds the output of a codec. + * A simple list which is reyclable. This implementation does not allow {@code null} elements to be added. */ public final class RecyclableArrayList extends ArrayList { @@ -79,7 +79,7 @@ public final class RecyclableArrayList extends ArrayList { return super.addAll(index, c); } - private void checkNullElements(Collection c) { + private static void checkNullElements(Collection c) { if (c instanceof RandomAccess && c instanceof List) { // produce less garbage List list = (List) c; @@ -114,6 +114,14 @@ public final class RecyclableArrayList extends ArrayList { super.add(index, element); } + @Override + public Object set(int index, Object element) { + if (element == null) { + throw new NullPointerException("element"); + } + return super.set(index, element); + } + /** * Clear and recycle this instance. */