--- old/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ResponseProcessors.java 2017-08-12 14:14:38.000000000 +0100 +++ new/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ResponseProcessors.java 2017-08-12 14:14:38.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,10 +72,12 @@ } @Override - public void onNext(ByteBuffer item) { - byte[] buf = new byte[item.remaining()]; - item.get(buf); - consumer.accept(Optional.of(buf)); + public void onNext(List items) { + for (ByteBuffer item : items) { + byte[] buf = new byte[item.remaining()]; + item.get(buf); + consumer.accept(Optional.of(buf)); + } subscription.request(1); } @@ -120,9 +122,9 @@ } @Override - public void onNext(ByteBuffer item) { + public void onNext(List items) { try { - out.write(item); + out.write(items.toArray(new ByteBuffer[0])); } catch (IOException ex) { Utils.close(out); subscription.cancel(); @@ -172,13 +174,12 @@ } @Override - public void onNext(ByteBuffer item) { + public void onNext(List items) { // incoming buffers are allocated by http client internally, // and won't be used anywhere except this place. // So it's free simply to store them for further processing. - if(item.hasRemaining()) { - received.add(item); - } + assert Utils.remaining(items) > 0; // TODO: is this really necessary? + received.addAll(items); } @Override @@ -304,9 +305,8 @@ } @Override - public void onNext(ByteBuffer item) { - // TODO: check whether this should consume the buffer, as in: - item.position(item.limit()); + public void onNext(List items) { + // NO-OP } @Override