diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java index dbd1eecaa76f..7bf249f22064 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java @@ -639,14 +639,14 @@ public Mutable add(HttpField field) public Mutable add(HttpFields fields) { - if (fields.size() == 0) - return this; - if (_fields == null) _fields = new HttpField[fields.size() + 4]; else if (_size + fields.size() >= _fields.length) _fields = Arrays.copyOf(_fields, _size + fields.size() + 4); + if (fields.size() == 0) + return this; + if (fields instanceof Immutable) { Immutable b = (Immutable)fields; diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java index be2e871d40b1..04ebd3905d25 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java @@ -745,7 +745,7 @@ public void testAddNullName() @Test public void testAddHttpFields() { - HttpFields.Mutable fields = HttpFields.build(); + HttpFields.Mutable fields = new HttpFields.Mutable(new HttpFields.Mutable()); fields.add("One", "1"); fields = new HttpFields.Mutable(fields);