From 281b4507df17a7355ace0133e5c364e112390655 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 30 Jun 2009 09:39:07 +0000 Subject: [PATCH] HttpMessage.getHeaders() never returns null for convenience --- .../netty/handler/codec/http/DefaultHttpMessage.java | 8 +++++++- .../org/jboss/netty/handler/codec/http/HttpMessage.java | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java index cec5db3f1f..5c103d8775 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/DefaultHttpMessage.java @@ -23,6 +23,7 @@ package org.jboss.netty.handler.codec.http; import java.util.ArrayList; +import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -207,7 +208,12 @@ public class DefaultHttpMessage implements HttpMessage { } public List getHeaders(final String name) { - return headers.get(name); + List values = headers.get(name); + if (values == null) { + return Collections.emptyList(); + } else { + return values; + } } public boolean containsHeader(final String name) { diff --git a/src/main/java/org/jboss/netty/handler/codec/http/HttpMessage.java b/src/main/java/org/jboss/netty/handler/codec/http/HttpMessage.java index 722dd9b122..934d095f7a 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/HttpMessage.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/HttpMessage.java @@ -52,8 +52,8 @@ public interface HttpMessage { /** * Returns the header values with the specified header name. * - * @return the {@link List} of header values of {@code null} if there is - * no such header + * @return the {@link List} of header values. An empty list if there is no + * such header. */ List getHeaders(String name);