src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/Receiver.java
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/Receiver.java Wed Nov 29 16:59:38 2017 +0000
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/Receiver.java Thu Nov 30 13:35:26 2017 +0300
@@ -25,13 +25,13 @@
package jdk.incubator.http.internal.websocket;
+import jdk.incubator.http.internal.common.Demand;
+import jdk.incubator.http.internal.common.SequentialScheduler;
+
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
-import jdk.incubator.http.internal.common.Demand;
-import jdk.incubator.http.internal.common.SequentialScheduler;
-
/*
* Receives incoming data from the channel on demand and converts it into a
* stream of WebSocket messages which are then delivered to the supplied message
@@ -101,11 +101,9 @@
}
public void request(long n) {
- if (n <= 0L) {
- throw new IllegalArgumentException("Non-positive request: " + n);
+ if (demand.increase(n)) {
+ pushScheduler.runOrSchedule();
}
- demand.increase(n);
- pushScheduler.runOrSchedule();
}
/*