From 369bc035fc3e8f491737ac7f7ee5433fd2a756f8 Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Fri, 27 Jul 2012 16:03:43 +0200 Subject: jetty-9: jetty-spdy refactored to match jetty-9. --- VERSION.txt | 12 +- .../jetty/server/jmx/Connector-mbean.properties | 4 +- jetty-spdy/pom.xml | 4 +- jetty-spdy/spdy-core/pom.xml | 43 ++-- .../org/eclipse/jetty/spdy/ByteBufferPool.java | 46 ---- .../java/org/eclipse/jetty/spdy/Controller.java | 31 +-- .../main/java/org/eclipse/jetty/spdy/ISession.java | 33 +-- .../main/java/org/eclipse/jetty/spdy/Promise.java | 4 +- .../eclipse/jetty/spdy/StandardByteBufferPool.java | 97 --------- .../org/eclipse/jetty/spdy/StandardSession.java | 99 ++++----- .../org/eclipse/jetty/spdy/StandardStream.java | 20 +- .../java/org/eclipse/jetty/spdy/api/Handler.java | 56 ----- .../java/org/eclipse/jetty/spdy/api/Session.java | 42 ++-- .../java/org/eclipse/jetty/spdy/api/Stream.java | 36 ++-- .../spdy/generator/ControlFrameGenerator.java | 2 +- .../jetty/spdy/generator/CredentialGenerator.java | 4 +- .../jetty/spdy/generator/DataFrameGenerator.java | 5 +- .../eclipse/jetty/spdy/generator/Generator.java | 2 +- .../jetty/spdy/generator/GoAwayGenerator.java | 4 +- .../jetty/spdy/generator/HeadersGenerator.java | 4 +- .../jetty/spdy/generator/NoOpGenerator.java | 4 +- .../jetty/spdy/generator/PingGenerator.java | 4 +- .../jetty/spdy/generator/RstStreamGenerator.java | 4 +- .../jetty/spdy/generator/SettingsGenerator.java | 4 +- .../jetty/spdy/generator/SynReplyGenerator.java | 4 +- .../jetty/spdy/generator/SynStreamGenerator.java | 4 +- .../spdy/generator/WindowUpdateGenerator.java | 4 +- .../org/eclipse/jetty/spdy/AsyncTimeoutTest.java | 21 +- .../eclipse/jetty/spdy/StandardSessionTest.java | 26 +-- .../org/eclipse/jetty/spdy/StandardStreamTest.java | 8 +- .../eclipse/jetty/spdy/api/ClientUsageTest.java | 5 +- .../eclipse/jetty/spdy/api/ServerUsageTest.java | 5 +- .../spdy/frames/CredentialGenerateParseTest.java | 2 +- .../jetty/spdy/frames/DataGenerateParseTest.java | 2 +- .../jetty/spdy/frames/GoAwayGenerateParseTest.java | 2 +- .../spdy/frames/HeadersGenerateParseTest.java | 2 +- .../jetty/spdy/frames/NoOpGenerateParseTest.java | 2 +- .../jetty/spdy/frames/PingGenerateParseTest.java | 2 +- .../spdy/frames/RstStreamGenerateParseTest.java | 14 +- .../spdy/frames/SettingsGenerateParseTest.java | 2 +- .../spdy/frames/SynReplyGenerateParseTest.java | 2 +- .../spdy/frames/SynStreamGenerateParseTest.java | 2 +- .../spdy/frames/WindowUpdateGenerateParseTest.java | 2 +- .../jetty/spdy/parser/UnknownControlFrameTest.java | 2 +- jetty-spdy/spdy-jetty-http-webapp/pom.xml | 2 +- jetty-spdy/spdy-jetty-http/pom.xml | 2 +- jetty-spdy/spdy-jetty/pom.xml | 3 +- .../eclipse/jetty/spdy/AsyncConnectionFactory.java | 2 +- .../eclipse/jetty/spdy/EmptyAsyncConnection.java | 74 +++---- .../org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java | 173 ++++----------- .../eclipse/jetty/spdy/SPDYAsyncConnection.java | 238 ++++++--------------- .../java/org/eclipse/jetty/spdy/SPDYClient.java | 106 +++++---- .../eclipse/jetty/spdy/SPDYServerConnector.java | 23 +- .../spdy/ServerSPDYAsyncConnectionFactory.java | 15 +- .../org/eclipse/jetty/spdy/ClosedStreamTest.java | 6 +- .../org/eclipse/jetty/spdy/IdleTimeoutTest.java | 39 ++-- .../test/java/org/eclipse/jetty/spdy/PingTest.java | 4 +- .../eclipse/jetty/spdy/ProtocolViolationsTest.java | 7 +- .../org/eclipse/jetty/spdy/PushStreamTest.java | 5 +- .../org/eclipse/jetty/spdy/ResetStreamTest.java | 6 +- .../jetty/spdy/SynDataReplyDataLoadTest.java | 4 +- .../java/org/eclipse/jetty/spdy/SynReplyTest.java | 6 +- .../eclipse/jetty/spdy/UnsupportedVersionTest.java | 1 + .../spdy-jetty/src/test/resources/log4j.properties | 4 +- pom.xml | 2 +- 65 files changed, 518 insertions(+), 881 deletions(-) delete mode 100644 jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ByteBufferPool.java delete mode 100644 jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardByteBufferPool.java delete mode 100644 jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Handler.java diff --git a/VERSION.txt b/VERSION.txt index a63a91e25f..2cbf59f074 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -6,7 +6,7 @@ jetty-7.6.6-SNAPSHOT + 376717 Balancer Servlet with round robin support, contribution, added missing license + 379250 Server is added to shutdown hook twice - + 380866 maxIdleTime set to 0 after session migration + + 380866 idleTimeout set to 0 after session migration + 381399 Unable to stop a jetty instance that has not finished starting + 381401 Print log warning when stop attempt made with incorrect STOP.KEY + 381402 Make ContextHandler take set of protected directories @@ -178,7 +178,7 @@ jetty-8.1.0.RC4 - 13 January 2012 + 367548 jetty-osgi-boot must not import the nested package twice + 367591 corrected configuration.xml version to 7.6 + 367635 Added support for start.d directory - + 367716 simplified maxIdleTime logic + + 367716 simplified idleTimeout logic + 368035 WebSocketClientFactory does not invoke super.doStop(). + 368060 do not encode sendRedirect URLs + 368112 NPE on element parsing web.xml @@ -257,7 +257,7 @@ jetty-7.6.0.RC4 - 13 January 2012 a Https-resource through a web-proxy. + 366774 removed XSS vulnerbility + 367099 Upgrade jetty-websocket for RFC 6455 - Addendum. - + 367716 simplified maxIdleTime logic + + 367716 simplified idleTimeout logic + 368035 WebSocketClientFactory does not invoke super.doStop(). + 368060 do not encode sendRedirect URLs + 368114 Protect against non-Strings in System properties for Log @@ -625,7 +625,7 @@ jetty-7.4.3.v20110701 - 01 July 2011 String) does not yield an empty map + 349738 set buffer sizes for http client in proxy servlet + 349870 proxy servlet protect continuation against fast failing exchanges - + 349896 SCEP supports zero maxIdleTime + + 349896 SCEP supports zero idleTimeout + 349897 draft -09 websockets + 349997 MBeanContainer uses weak references + 350533 Add "Origin" to the list of allowed headers in CrossOriginFilter @@ -1070,7 +1070,7 @@ jetty-7.1.4.v20100610 + 315748 Removed --fromDaemon from start.jar (replaced with --daemon) + 315925 Improved context xml configuration handling + 315995 Incorrect package name in system classes list - + 316119 Fixed maxIdleTime for SocketEndPoint + + 316119 Fixed idleTimeout for SocketEndPoint + 316254 Implement @DeclareRoles + 316334 Breaking change on org.eclipse.jetty.client.HttpExchange + 316399 Debug output in MultiPartFilter @@ -2492,7 +2492,7 @@ jetty-6.1.5rc0 - 15 July 0200 jetty-6.1.4 - 15 June 2007 + fixed early open() call in NIO connectors - + JETTY-370 ensure maxIdleTime<=0 means connections never expire + + JETTY-370 ensure idleTimeout<=0 means connections never expire + JETTY-371 Fixed chunked HEAD response + JETTY-372 make test for cookie caching more rigorous diff --git a/jetty-server/src/main/resources/org/eclipse/jetty/server/jmx/Connector-mbean.properties b/jetty-server/src/main/resources/org/eclipse/jetty/server/jmx/Connector-mbean.properties index efd5cef83c..add1cf55f8 100644 --- a/jetty-server/src/main/resources/org/eclipse/jetty/server/jmx/Connector-mbean.properties +++ b/jetty-server/src/main/resources/org/eclipse/jetty/server/jmx/Connector-mbean.properties @@ -10,7 +10,7 @@ confidentialPort: Port to use for confidential redirections confidentialScheme: Scheme to use for confidential redirections host: Host name to accept connections on port: TCP/IP port to accept connections on -maxIdleTime: Maximum time in ms that a connection can be idle before being closed +idleTimeout: Maximum time in ms that a connection can be idle before being closed statsOn: True if statistics collection is turned on. statsOnMs: Time in milliseconds stats have been collected for. statsReset(): Reset statistics. @@ -26,4 +26,4 @@ connectionsRequestsStdDev: Standard deviation of number of requests per connecti connectionsRequestsMax: Maximum number of requests per connection since statsReset() called. Undefined if setStatsOn(false). requests: Number of requests since statsReset() called. Undefined if setStatsOn(false). open(): Open the listening port -close(): Close the listening port (but allow existing connections to continue for graceful shutdown) \ No newline at end of file +close(): Close the listening port (but allow existing connections to continue for graceful shutdown) diff --git a/jetty-spdy/pom.xml b/jetty-spdy/pom.xml index bacc02bea1..59ac802667 100644 --- a/jetty-spdy/pom.xml +++ b/jetty-spdy/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty jetty-project - 8.1.6-SNAPSHOT + 9.0.0-SNAPSHOT 4.0.0 @@ -19,8 +19,10 @@ spdy-core spdy-jetty + diff --git a/jetty-spdy/spdy-core/pom.xml b/jetty-spdy/spdy-core/pom.xml index 14e6d533f4..00b04b007d 100644 --- a/jetty-spdy/spdy-core/pom.xml +++ b/jetty-spdy/spdy-core/pom.xml @@ -3,12 +3,12 @@ org.eclipse.jetty.spdy spdy-parent - 8.1.6-SNAPSHOT + 9.0.0-SNAPSHOT - 4.0.0 - spdy-core - Jetty :: SPDY :: Core + 4.0.0 + spdy-core + Jetty :: SPDY :: Core @@ -16,21 +16,26 @@ jetty-util ${project.version} - - junit - junit - test - - - org.hamcrest - hamcrest-all - test - - - org.mockito - mockito-core - test - + + org.eclipse.jetty + jetty-io + ${project.version} + + + junit + junit + test + + + org.hamcrest + hamcrest-all + test + + + org.mockito + mockito-core + test + org.slf4j slf4j-log4j12 diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ByteBufferPool.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ByteBufferPool.java deleted file mode 100644 index e2964cc0f0..0000000000 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ByteBufferPool.java +++ /dev/null @@ -1,46 +0,0 @@ -//======================================================================== -//Copyright 2012 Mort Bay Consulting Pty. Ltd. -//------------------------------------------------------------------------ -//All rights reserved. This program and the accompanying materials -//are made available under the terms of the Eclipse Public License v1.0 -//and Apache License v2.0 which accompanies this distribution. -//The Eclipse Public License is available at -//http://www.eclipse.org/legal/epl-v10.html -//The Apache License v2.0 is available at -//http://www.opensource.org/licenses/apache2.0.php -//You may elect to redistribute this code under either of these licenses. -//======================================================================== - -package org.eclipse.jetty.spdy; - -import java.nio.ByteBuffer; - -/** - *

A {@link ByteBuffer} pool.

- *

Acquired buffers may be {@link #release(ByteBuffer) released} but they do not need to; - * if they are released, they may be recycled and reused, otherwise they will be garbage - * collected as usual.

- */ -public interface ByteBufferPool -{ - /** - *

Requests a {@link ByteBuffer} of the given size.

- *

The returned buffer may have a bigger capacity than the size being - * requested but it will have the limit set to the given size.

- * - * @param size the size of the buffer - * @param direct whether the buffer must be direct or not - * @return the requested buffer - * @see #release(ByteBuffer) - */ - public ByteBuffer acquire(int size, boolean direct); - - /** - *

Returns a {@link ByteBuffer}, usually obtained with {@link #acquire(int, boolean)} - * (but not necessarily), making it available for recycling and reuse.

- * - * @param buffer the buffer to return - * @see #acquire(int, boolean) - */ - public void release(ByteBuffer buffer); -} diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Controller.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Controller.java index 75e26ef934..f86ed120fa 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Controller.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Controller.java @@ -1,25 +1,28 @@ -//======================================================================== -//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. -//------------------------------------------------------------------------ -//All rights reserved. This program and the accompanying materials -//are made available under the terms of the Eclipse Public License v1.0 -//and Apache License v2.0 which accompanies this distribution. -//The Eclipse Public License is available at -//http://www.eclipse.org/legal/epl-v10.html -//The Apache License v2.0 is available at -//http://www.opensource.org/licenses/apache2.0.php -//You may elect to redistribute this code under either of these licenses. -//======================================================================== +/* + * Copyright (c) 2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.eclipse.jetty.spdy; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.api.Handler; +import org.eclipse.jetty.util.Callback; public interface Controller { - public int write(ByteBuffer buffer, Handler handler, T context); + public int write(ByteBuffer buffer, Callback callback, T context); public void close(boolean onlyOutput); } diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ISession.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ISession.java index 41bbfd7da8..b00d885b06 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ISession.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/ISession.java @@ -1,24 +1,27 @@ -//======================================================================== -//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. -//------------------------------------------------------------------------ -//All rights reserved. This program and the accompanying materials -//are made available under the terms of the Eclipse Public License v1.0 -//and Apache License v2.0 which accompanies this distribution. -//The Eclipse Public License is available at -//http://www.eclipse.org/legal/epl-v10.html -//The Apache License v2.0 is available at -//http://www.opensource.org/licenses/apache2.0.php -//You may elect to redistribute this code under either of these licenses. -//======================================================================== +/* + * Copyright (c) 2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.eclipse.jetty.spdy; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.spdy.api.DataInfo; -import org.eclipse.jetty.spdy.api.Handler; import org.eclipse.jetty.spdy.api.Session; import org.eclipse.jetty.spdy.frames.ControlFrame; +import org.eclipse.jetty.util.Callback; public interface ISession extends Session { @@ -29,7 +32,7 @@ public interface ISession extends Session */ public void flush(); - public void control(IStream stream, ControlFrame frame, long timeout, TimeUnit unit, Handler handler, C context); + public void control(IStream stream, ControlFrame frame, long timeout, TimeUnit unit, Callback callback, C context); - public void data(IStream stream, DataInfo dataInfo, long timeout, TimeUnit unit, Handler handler, C context); + public void data(IStream stream, DataInfo dataInfo, long timeout, TimeUnit unit, Callback callback, C context); } diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Promise.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Promise.java index b08cde8c49..b6d2e13e1b 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Promise.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/Promise.java @@ -20,7 +20,7 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.eclipse.jetty.spdy.api.Handler; +import org.eclipse.jetty.util.Callback; /** *

A {@link Promise} is a {@link Future} that allows a result or a failure to be set, @@ -28,7 +28,7 @@ import org.eclipse.jetty.spdy.api.Handler; * * @param the type of the result object */ -public class Promise implements Handler, Future +public class Promise implements Callback, Future { private final CountDownLatch latch = new CountDownLatch(1); private boolean cancelled; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardByteBufferPool.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardByteBufferPool.java deleted file mode 100644 index 60b6190bf2..0000000000 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardByteBufferPool.java +++ /dev/null @@ -1,97 +0,0 @@ -//======================================================================== -//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. -//------------------------------------------------------------------------ -//All rights reserved. This program and the accompanying materials -//are made available under the terms of the Eclipse Public License v1.0 -//and Apache License v2.0 which accompanies this distribution. -//The Eclipse Public License is available at -//http://www.eclipse.org/legal/epl-v10.html -//The Apache License v2.0 is available at -//http://www.opensource.org/licenses/apache2.0.php -//You may elect to redistribute this code under either of these licenses. -//======================================================================== - -package org.eclipse.jetty.spdy; - -import java.nio.ByteBuffer; -import java.util.Queue; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.ConcurrentMap; - -public class StandardByteBufferPool implements ByteBufferPool -{ - private final ConcurrentMap> directBuffers = new ConcurrentHashMap<>(); - private final ConcurrentMap> heapBuffers = new ConcurrentHashMap<>(); - private final int factor; - - public StandardByteBufferPool() - { - this(1024); - } - - public StandardByteBufferPool(int factor) - { - this.factor = factor; - } - - public ByteBuffer acquire(int size, boolean direct) - { - int bucket = bucketFor(size); - ConcurrentMap> buffers = buffersFor(direct); - - ByteBuffer result = null; - Queue byteBuffers = buffers.get(bucket); - if (byteBuffers != null) - result = byteBuffers.poll(); - - if (result == null) - { - int capacity = bucket * factor; - result = direct ? ByteBuffer.allocateDirect(capacity) : ByteBuffer.allocate(capacity); - } - - result.clear(); - result.limit(size); - - return result; - } - - public void release(ByteBuffer buffer) - { - int bucket = bucketFor(buffer.capacity()); - ConcurrentMap> buffers = buffersFor(buffer.isDirect()); - - // Avoid to create a new queue every time, just to be discarded immediately - Queue byteBuffers = buffers.get(bucket); - if (byteBuffers == null) - { - byteBuffers = new ConcurrentLinkedQueue<>(); - Queue existing = buffers.putIfAbsent(bucket, byteBuffers); - if (existing != null) - byteBuffers = existing; - } - - buffer.clear(); - byteBuffers.offer(buffer); - } - - public void clear() - { - directBuffers.clear(); - heapBuffers.clear(); - } - - private int bucketFor(int size) - { - int bucket = size / factor; - if (size % factor > 0) - ++bucket; - return bucket; - } - - private ConcurrentMap> buffersFor(boolean direct) - { - return direct ? directBuffers : heapBuffers; - } -} diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java index d5524e2f61..a5ebe70b97 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardSession.java @@ -34,10 +34,10 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.api.ByteBufferDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.api.GoAwayInfo; -import org.eclipse.jetty.spdy.api.Handler; import org.eclipse.jetty.spdy.api.PingInfo; import org.eclipse.jetty.spdy.api.RstInfo; import org.eclipse.jetty.spdy.api.SPDYException; @@ -65,12 +65,13 @@ import org.eclipse.jetty.spdy.frames.WindowUpdateFrame; import org.eclipse.jetty.spdy.generator.Generator; import org.eclipse.jetty.spdy.parser.Parser; import org.eclipse.jetty.util.Atomics; +import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.component.AggregateLifeCycle; import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -public class StandardSession implements ISession, Parser.Listener, Handler, Dumpable +public class StandardSession implements ISession, Parser.Listener, Callback, Dumpable { private static final Logger logger = Log.getLogger(Session.class); private static final ThreadLocal handlerInvocations = new ThreadLocal() @@ -147,7 +148,7 @@ public class StandardSession implements ISession, Parser.Listener, Handler handler) + public void syn(SynInfo synInfo, StreamFrameListener listener, long timeout, TimeUnit unit, Callback callback) { // Synchronization is necessary. // SPEC v3, 2.3.1 requires that the stream creation be monotonically crescent @@ -165,7 +166,7 @@ public class StandardSession implements ISession, Parser.Listener, Handler handler) + public void rst(RstInfo rstInfo, long timeout, TimeUnit unit, Callback callback) { // SPEC v3, 2.2.2 if (goAwaySent.get()) { - complete(handler,null); + complete(callback,null); } else { int streamId = rstInfo.getStreamId(); IStream stream = streams.get(streamId); RstStreamFrame frame = new RstStreamFrame(version,streamId,rstInfo.getStreamStatus().getCode(version)); - control(stream,frame,timeout,unit,handler,null); + control(stream,frame,timeout,unit,callback,null); if (stream != null) { stream.process(frame); @@ -209,10 +210,10 @@ public class StandardSession implements ISession, Parser.Listener, Handler handler) + public void settings(SettingsInfo settingsInfo, long timeout, TimeUnit unit, Callback callback) { SettingsFrame frame = new SettingsFrame(version,settingsInfo.getFlags(),settingsInfo.getSettings()); - control(null, frame, timeout, unit, handler, null); + control(null, frame, timeout, unit, callback, null); } @Override @@ -224,12 +225,12 @@ public class StandardSession implements ISession, Parser.Listener, Handler handler) + public void ping(long timeout, TimeUnit unit, Callback callback) { int pingId = pingIds.getAndAdd(2); PingInfo pingInfo = new PingInfo(pingId); PingFrame frame = new PingFrame(version,pingId); - control(null,frame,timeout,unit,handler,pingInfo); + control(null,frame,timeout,unit,callback,pingInfo); } @Override @@ -246,23 +247,24 @@ public class StandardSession implements ISession, Parser.Listener, Handler handler) + public void goAway(long timeout, TimeUnit unit, Callback callback) { - goAway(SessionStatus.OK, timeout, unit, handler); + goAway(SessionStatus.OK, timeout, unit, callback); } - private void goAway(SessionStatus sessionStatus, long timeout, TimeUnit unit, Handler handler) + private void goAway(SessionStatus sessionStatus, long timeout, TimeUnit unit, Callback callback) { + new Exception().printStackTrace(); if (goAwaySent.compareAndSet(false,true)) { if (!goAwayReceived.get()) { GoAwayFrame frame = new GoAwayFrame(version,lastStreamId.get(),sessionStatus.getCode()); - control(null,frame,timeout,unit,handler,null); + control(null,frame,timeout,unit,callback,null); return; } } - complete(handler, null); + complete(callback, null); } @Override @@ -818,14 +820,15 @@ public class StandardSession implements ISession, Parser.Listener, Handler void control(IStream stream, ControlFrame frame, long timeout, TimeUnit unit, Handler handler, C context) + public void control(IStream stream, ControlFrame frame, long timeout, TimeUnit unit, Callback callback, C context) { - generateAndEnqueueControlFrame(stream,frame,timeout,unit,handler,context); + generateAndEnqueueControlFrame(stream,frame,timeout,unit,callback,context); flush(); } - private void generateAndEnqueueControlFrame(IStream stream, ControlFrame frame, long timeout, TimeUnit unit, Handler handler, C context) + private void generateAndEnqueueControlFrame(IStream stream, ControlFrame frame, long timeout, TimeUnit unit, Callback callback, C context) { try { @@ -836,7 +839,7 @@ public class StandardSession implements ISession, Parser.Listener, Handler frameBytes = new ControlFrameBytes<>(stream, handler, context, frame, buffer); + ControlFrameBytes frameBytes = new ControlFrameBytes<>(stream, callback, context, frame, buffer); if (timeout > 0) frameBytes.task = scheduler.schedule(frameBytes, timeout, unit); @@ -849,7 +852,7 @@ public class StandardSession implements ISession, Parser.Listener, Handler void data(IStream stream, DataInfo dataInfo, long timeout, TimeUnit unit, Handler handler, C context) + public void data(IStream stream, DataInfo dataInfo, long timeout, TimeUnit unit, Callback callback, C context) { logger.debug("Queuing {} on {}",dataInfo,stream); - DataFrameBytes frameBytes = new DataFrameBytes<>(stream,handler,context,dataInfo); + DataFrameBytes frameBytes = new DataFrameBytes<>(stream,callback,context,dataInfo); if (timeout > 0) frameBytes.task = scheduler.schedule(frameBytes,timeout,unit); append(frameBytes); @@ -1003,19 +1006,19 @@ public class StandardSession implements ISession, Parser.Listener, Handler handler, FrameBytes frameBytes) + protected void write(ByteBuffer buffer, Callback callback, FrameBytes frameBytes) { if (controller != null) { logger.debug("Writing {} frame bytes of {}",buffer.remaining(),frameBytes); - controller.write(buffer,handler,frameBytes); + controller.write(buffer,callback,frameBytes); } } - private void complete(final Handler handler, final C context) + private void complete(final Callback callback, final C context) { // Applications may send and queue up a lot of frames and - // if we call Handler.completed() only synchronously we risk + // if we call Callback.completed() only synchronously we risk // starvation (for the last frames sent) and stack overflow. // Therefore every some invocation, we dispatch to a new thread Integer invocations = handlerInvocations.get(); @@ -1026,8 +1029,8 @@ public class StandardSession implements ISession, Parser.Listener, Handler void notifyHandlerCompleted(Handler handler, C context) + private void notifyCallbackCompleted(Callback callback, C context) { try { - handler.completed(context); + callback.completed(context); } catch (Exception x) { - logger.info("Exception while notifying handler " + handler, x); + logger.info("Exception while notifying callback " + callback, x); } catch (Error x) { - logger.info("Exception while notifying handler " + handler, x); + logger.info("Exception while notifying callback " + callback, x); throw x; } } - private void notifyHandlerFailed(Handler handler, C context, Throwable x) + private void notifyCallbackFailed(Callback callback, C context, Throwable x) { try { - if (handler != null) - handler.failed(context, x); + if (callback != null) + callback.failed(context, x); } catch (Exception xx) { - logger.info("Exception while notifying handler " + handler, xx); + logger.info("Exception while notifying callback " + callback, xx); } catch (Error xx) { - logger.info("Exception while notifying handler " + handler, xx); + logger.info("Exception while notifying callback " + callback, xx); throw xx; } } @@ -1128,14 +1131,14 @@ public class StandardSession implements ISession, Parser.Listener, Handler implements FrameBytes, Runnable { private final IStream stream; - private final Handler handler; + private final Callback callback; private final C context; protected volatile ScheduledFuture task; - protected AbstractFrameBytes(IStream stream, Handler handler, C context) + protected AbstractFrameBytes(IStream stream, Callback callback, C context) { this.stream = stream; - this.handler = handler; + this.callback = callback; this.context = context; } @@ -1164,14 +1167,14 @@ public class StandardSession implements ISession, Parser.Listener, Handler handler, C context, ControlFrame frame, ByteBuffer buffer) + private ControlFrameBytes(IStream stream, Callback callback, C context, ControlFrame frame, ByteBuffer buffer) { - super(stream,handler,context); + super(stream,callback,context); this.frame = frame; this.buffer = buffer; } @@ -1239,7 +1242,7 @@ public class StandardSession implements ISession, Parser.Listener, Handler handler, C context, DataInfo dataInfo) + private DataFrameBytes(IStream stream, Callback handler, C context, DataInfo dataInfo) { super(stream,handler,context); this.dataInfo = dataInfo; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardStream.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardStream.java index 360a639591..3db6a14a34 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardStream.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/StandardStream.java @@ -22,7 +22,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.eclipse.jetty.spdy.api.DataInfo; -import org.eclipse.jetty.spdy.api.Handler; import org.eclipse.jetty.spdy.api.HeadersInfo; import org.eclipse.jetty.spdy.api.ReplyInfo; import org.eclipse.jetty.spdy.api.RstInfo; @@ -33,6 +32,7 @@ import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.frames.ControlFrame; import org.eclipse.jetty.spdy.frames.HeadersFrame; import org.eclipse.jetty.spdy.frames.SynReplyFrame; +import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -318,15 +318,15 @@ public class StandardStream implements IStream } @Override - public void syn(SynInfo synInfo, long timeout, TimeUnit unit, Handler handler) + public void syn(SynInfo synInfo, long timeout, TimeUnit unit, Callback callback) { if (isClosed() || isReset()) { - handler.failed(this, new StreamException(getId(), StreamStatus.STREAM_ALREADY_CLOSED)); + callback.failed(this, new StreamException(getId(), StreamStatus.STREAM_ALREADY_CLOSED)); return; } PushSynInfo pushSynInfo = new PushSynInfo(getId(), synInfo); - session.syn(pushSynInfo, null, timeout, unit, handler); + session.syn(pushSynInfo, null, timeout, unit, callback); } @Override @@ -338,14 +338,14 @@ public class StandardStream implements IStream } @Override - public void reply(ReplyInfo replyInfo, long timeout, TimeUnit unit, Handler handler) + public void reply(ReplyInfo replyInfo, long timeout, TimeUnit unit, Callback callback) { if (isUnidirectional()) throw new IllegalStateException("Protocol violation: cannot send SYN_REPLY frames in unidirectional streams"); openState = OpenState.REPLY_SENT; updateCloseState(replyInfo.isClose(), true); SynReplyFrame frame = new SynReplyFrame(session.getVersion(), replyInfo.getFlags(), getId(), replyInfo.getHeaders()); - session.control(this, frame, timeout, unit, handler, null); + session.control(this, frame, timeout, unit, callback, null); } @Override @@ -357,7 +357,7 @@ public class StandardStream implements IStream } @Override - public void data(DataInfo dataInfo, long timeout, TimeUnit unit, Handler handler) + public void data(DataInfo dataInfo, long timeout, TimeUnit unit, Callback callback) { if (!canSend()) { @@ -372,7 +372,7 @@ public class StandardStream implements IStream // Cannot update the close state here, because the data that we send may // be flow controlled, so we need the stream to update the window size. - session.data(this, dataInfo, timeout, unit, handler, null); + session.data(this, dataInfo, timeout, unit, callback, null); } @Override @@ -384,7 +384,7 @@ public class StandardStream implements IStream } @Override - public void headers(HeadersInfo headersInfo, long timeout, TimeUnit unit, Handler handler) + public void headers(HeadersInfo headersInfo, long timeout, TimeUnit unit, Callback callback) { if (!canSend()) { @@ -399,7 +399,7 @@ public class StandardStream implements IStream updateCloseState(headersInfo.isClose(), true); HeadersFrame frame = new HeadersFrame(session.getVersion(), headersInfo.getFlags(), getId(), headersInfo.getHeaders()); - session.control(this, frame, timeout, unit, handler, null); + session.control(this, frame, timeout, unit, callback, null); } @Override diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Handler.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Handler.java deleted file mode 100644 index b69467e368..0000000000 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Handler.java +++ /dev/null @@ -1,56 +0,0 @@ -//======================================================================== -//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. -//------------------------------------------------------------------------ -//All rights reserved. This program and the accompanying materials -//are made available under the terms of the Eclipse Public License v1.0 -//and Apache License v2.0 which accompanies this distribution. -//The Eclipse Public License is available at -//http://www.eclipse.org/legal/epl-v10.html -//The Apache License v2.0 is available at -//http://www.opensource.org/licenses/apache2.0.php -//You may elect to redistribute this code under either of these licenses. -//======================================================================== - -package org.eclipse.jetty.spdy.api; - -/** - *

A callback abstraction that handles completed/failed events of asynchronous operations.

- *

Instances of this class capture a context that is made available on the completion callback.

- * - * @param the type of the context object - */ -public interface Handler -{ - /** - *

Callback invoked when the operation completes.

- * - * @param context the context - * @see #failed(Object, Throwable) - */ - public abstract void completed(C context); - - /** - *

Callback invoked when the operation fails.

- * @param context the context - * @param x the reason for the operation failure - */ - public void failed(C context, Throwable x); - - /** - *

Empty implementation of {@link Handler}

- * - * @param the type of the context object - */ - public static class Adapter implements Handler - { - @Override - public void completed(C context) - { - } - - @Override - public void failed(C context, Throwable x) - { - } - } -} diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Session.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Session.java index bbe17fc729..39930905f2 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Session.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Session.java @@ -18,6 +18,8 @@ import java.util.Set; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.util.Callback; + /** *

A {@link Session} represents the client-side endpoint of a SPDY connection to a single origin server.

*

Once a {@link Session} has been obtained, it can be used to open SPDY streams:

@@ -69,23 +71,23 @@ public interface Session * @param synInfo the metadata to send on stream creation * @param listener the listener to invoke when events happen on the stream just created * @return a future for the stream that will be created - * @see #syn(SynInfo, StreamFrameListener, long, TimeUnit, Handler) + * @see #syn(SynInfo, StreamFrameListener, long, TimeUnit, Callback) */ public Future syn(SynInfo synInfo, StreamFrameListener listener); /** *

Sends asynchronously a SYN_FRAME to create a new {@link Stream SPDY stream}.

- *

Callers may pass a non-null completion handler to be notified of when the + *

Callers may pass a non-null completion callback to be notified of when the * stream has been created and use the stream, for example, to send data frames.

* * @param synInfo the metadata to send on stream creation * @param listener the listener to invoke when events happen on the stream just created * @param timeout the operation's timeout * @param unit the timeout's unit - * @param handler the completion handler that gets notified of stream creation + * @param callback the completion callback that gets notified of stream creation * @see #syn(SynInfo, StreamFrameListener) */ - public void syn(SynInfo synInfo, StreamFrameListener listener, long timeout, TimeUnit unit, Handler handler); + public void syn(SynInfo synInfo, StreamFrameListener listener, long timeout, TimeUnit unit, Callback callback); /** @@ -94,22 +96,22 @@ public interface Session * * @param rstInfo the metadata to reset the stream * @return a future to wait for the reset to be sent - * @see #rst(RstInfo, long, TimeUnit, Handler) + * @see #rst(RstInfo, long, TimeUnit, Callback) */ public Future rst(RstInfo rstInfo); /** *

Sends asynchronously a RST_STREAM to abort a stream.

- *

Callers may pass a non-null completion handler to be notified of when the + *

Callers may pass a non-null completion callback to be notified of when the * reset has been actually sent.

* * @param rstInfo the metadata to reset the stream * @param timeout the operation's timeout * @param unit the timeout's unit - * @param handler the completion handler that gets notified of reset's send + * @param callback the completion callback that gets notified of reset's send * @see #rst(RstInfo) */ - public void rst(RstInfo rstInfo, long timeout, TimeUnit unit, Handler handler); + public void rst(RstInfo rstInfo, long timeout, TimeUnit unit, Callback callback); /** *

Sends asynchronously a SETTINGS to configure the SPDY connection.

@@ -117,64 +119,64 @@ public interface Session * * @param settingsInfo the metadata to send * @return a future to wait for the settings to be sent - * @see #settings(SettingsInfo, long, TimeUnit, Handler) + * @see #settings(SettingsInfo, long, TimeUnit, Callback) */ public Future settings(SettingsInfo settingsInfo); /** *

Sends asynchronously a SETTINGS to configure the SPDY connection.

- *

Callers may pass a non-null completion handler to be notified of when the + *

Callers may pass a non-null completion callback to be notified of when the * settings has been actually sent.

* * @param settingsInfo the metadata to send * @param timeout the operation's timeout * @param unit the timeout's unit - * @param handler the completion handler that gets notified of settings' send + * @param callback the completion callback that gets notified of settings' send * @see #settings(SettingsInfo) */ - public void settings(SettingsInfo settingsInfo, long timeout, TimeUnit unit, Handler handler); + public void settings(SettingsInfo settingsInfo, long timeout, TimeUnit unit, Callback callback); /** *

Sends asynchronously a PING, normally to measure round-trip time.

*

Callers may use the returned future to wait for the ping to be sent.

* * @return a future for the metadata sent - * @see #ping(long, TimeUnit, Handler) + * @see #ping(long, TimeUnit, Callback) */ public Future ping(); /** *

Sends asynchronously a PING, normally to measure round-trip time.

- *

Callers may pass a non-null completion handler to be notified of when the + *

Callers may pass a non-null completion callback to be notified of when the * ping has been actually sent.

* * @param timeout the operation's timeout * @param unit the timeout's unit - * @param handler the completion handler that gets notified of ping's send + * @param callback the completion callback that gets notified of ping's send * @see #ping() */ - public void ping(long timeout, TimeUnit unit, Handler handler); + public void ping(long timeout, TimeUnit unit, Callback callback); /** *

Closes gracefully this session, sending a GO_AWAY frame and then closing the TCP connection.

*

Callers may use the returned future to wait for the go away to be sent.

* * @return a future to wait for the go away to be sent - * @see #goAway(long, TimeUnit, Handler) + * @see #goAway(long, TimeUnit, Callback) */ public Future goAway(); /** *

Closes gracefully this session, sending a GO_AWAY frame and then closing the TCP connection.

- *

Callers may pass a non-null completion handler to be notified of when the + *

Callers may pass a non-null completion callback to be notified of when the * go away has been actually sent.

* * @param timeout the operation's timeout * @param unit the timeout's unit - * @param handler the completion handler that gets notified of go away's send + * @param callback the completion callback that gets notified of go away's send * @see #goAway() */ - public void goAway(long timeout, TimeUnit unit, Handler handler); + public void goAway(long timeout, TimeUnit unit, Callback callback); /** * @return a snapshot of the streams currently active in this session diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Stream.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Stream.java index 092c7a3549..9d9d8ffb87 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Stream.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/api/Stream.java @@ -18,6 +18,8 @@ import java.util.Set; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.util.Callback; + /** *

A {@link Stream} represents a bidirectional exchange of data on top of a {@link Session}.

*

Differently from socket streams, where the input and output streams are permanently associated @@ -42,7 +44,7 @@ import java.util.concurrent.TimeUnit; * stream.data(StringDataInfo("chunk1", false), 5, TimeUnit.SECONDS, new Handler<Void>() { ... }); * stream.data(StringDataInfo("chunk2", true), 1, TimeUnit.SECONDS, new Handler<Void>() { ... }); * - *

where the second call to {@link #data(DataInfo, long, TimeUnit, Handler)} has a timeout smaller + *

where the second call to {@link #data(DataInfo, long, TimeUnit, Callback)} has a timeout smaller * than the previous call.

*

The behavior of such style of invocations is unspecified (it may even throw an exception - similar * to {@link WritePendingException}).

@@ -89,22 +91,22 @@ public interface Stream * * @param synInfo the metadata to send on stream creation * @return a future containing the stream once it got established - * @see #syn(SynInfo, long, TimeUnit, Handler) + * @see #syn(SynInfo, long, TimeUnit, Callback) */ public Future syn(SynInfo synInfo); /** *

Initiate a unidirectional spdy pushstream associated to this stream asynchronously

- *

Callers may pass a non-null completion handler to be notified of when the + *

Callers may pass a non-null completion callback to be notified of when the * pushstream has been established.

* * @param synInfo the metadata to send on stream creation * @param timeout the operation's timeout * @param unit the timeout's unit - * @param handler the completion handler that gets notified once the pushstream is established + * @param callback the completion callback that gets notified once the pushstream is established * @see #syn(SynInfo) */ - public void syn(SynInfo synInfo, long timeout, TimeUnit unit, Handler handler); + public void syn(SynInfo synInfo, long timeout, TimeUnit unit, Callback callback); /** *

Sends asynchronously a SYN_REPLY frame in response to a SYN_STREAM frame.

@@ -112,23 +114,23 @@ public interface Stream * * @param replyInfo the metadata to send * @return a future to wait for the reply to be sent - * @see #reply(ReplyInfo, long, TimeUnit, Handler) + * @see #reply(ReplyInfo, long, TimeUnit, Callback) * @see SessionFrameListener#onSyn(Stream, SynInfo) */ public Future reply(ReplyInfo replyInfo); /** *

Sends asynchronously a SYN_REPLY frame in response to a SYN_STREAM frame.

- *

Callers may pass a non-null completion handler to be notified of when the + *

Callers may pass a non-null completion callback to be notified of when the * reply has been actually sent.

* * @param replyInfo the metadata to send * @param timeout the operation's timeout * @param unit the timeout's unit - * @param handler the completion handler that gets notified of reply sent + * @param callback the completion callback that gets notified of reply sent * @see #reply(ReplyInfo) */ - public void reply(ReplyInfo replyInfo, long timeout, TimeUnit unit, Handler handler); + public void reply(ReplyInfo replyInfo, long timeout, TimeUnit unit, Callback callback); /** *

Sends asynchronously a DATA frame on this stream.

@@ -137,7 +139,7 @@ public interface Stream * * @param dataInfo the metadata to send * @return a future to wait for the data to be sent - * @see #data(DataInfo, long, TimeUnit, Handler) + * @see #data(DataInfo, long, TimeUnit, Callback) * @see #reply(ReplyInfo) */ public Future data(DataInfo dataInfo); @@ -145,16 +147,16 @@ public interface Stream /** *

Sends asynchronously a DATA frame on this stream.

*

DATA frames should always be sent after a SYN_REPLY frame.

- *

Callers may pass a non-null completion handler to be notified of when the + *

Callers may pass a non-null completion callback to be notified of when the * data has been actually sent.

* * @param dataInfo the metadata to send * @param timeout the operation's timeout * @param unit the timeout's unit - * @param handler the completion handler that gets notified of data sent + * @param callback the completion callback that gets notified of data sent * @see #data(DataInfo) */ - public void data(DataInfo dataInfo, long timeout, TimeUnit unit, Handler handler); + public void data(DataInfo dataInfo, long timeout, TimeUnit unit, Callback callback); /** *

Sends asynchronously a HEADER frame on this stream.

@@ -163,7 +165,7 @@ public interface Stream * * @param headersInfo the metadata to send * @return a future to wait for the headers to be sent - * @see #headers(HeadersInfo, long, TimeUnit, Handler) + * @see #headers(HeadersInfo, long, TimeUnit, Callback * @see #reply(ReplyInfo) */ public Future headers(HeadersInfo headersInfo); @@ -171,16 +173,16 @@ public interface Stream /** *

Sends asynchronously a HEADER frame on this stream.

*

HEADERS frames should always be sent after a SYN_REPLY frame.

- *

Callers may pass a non-null completion handler to be notified of when the + *

Callers may pass a non-null completion callback to be notified of when the * headers have been actually sent.

* * @param headersInfo the metadata to send * @param timeout the operation's timeout * @param unit the timeout's unit - * @param handler the completion handler that gets notified of headers sent + * @param callback the completion callback that gets notified of headers sent * @see #headers(HeadersInfo) */ - public void headers(HeadersInfo headersInfo, long timeout, TimeUnit unit, Handler handler); + public void headers(HeadersInfo headersInfo, long timeout, TimeUnit unit, Callback callback); /** * @return whether this stream is unidirectional or not diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/ControlFrameGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/ControlFrameGenerator.java index ff7302cfc7..d10614b79c 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/ControlFrameGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/ControlFrameGenerator.java @@ -15,7 +15,7 @@ package org.eclipse.jetty.spdy.generator; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.ByteBufferPool; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.frames.ControlFrame; public abstract class ControlFrameGenerator diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/CredentialGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/CredentialGenerator.java index f2064fb68f..df512229b5 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/CredentialGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/CredentialGenerator.java @@ -19,11 +19,12 @@ import java.security.cert.CertificateEncodingException; import java.util.ArrayList; import java.util.List; -import org.eclipse.jetty.spdy.ByteBufferPool; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.SessionException; import org.eclipse.jetty.spdy.api.SessionStatus; import org.eclipse.jetty.spdy.frames.ControlFrame; import org.eclipse.jetty.spdy.frames.CredentialFrame; +import org.eclipse.jetty.util.BufferUtil; public class CredentialGenerator extends ControlFrameGenerator { @@ -48,6 +49,7 @@ public class CredentialGenerator extends ControlFrameGenerator int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength; ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true); + BufferUtil.clearToFill(buffer); generateControlFrameHeader(credential, frameBodyLength, buffer); buffer.putShort(credential.getSlot()); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/DataFrameGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/DataFrameGenerator.java index aed8fbc758..2db81a9428 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/DataFrameGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/DataFrameGenerator.java @@ -14,9 +14,10 @@ package org.eclipse.jetty.spdy.generator; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.ByteBufferPool; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.frames.DataFrame; +import org.eclipse.jetty.util.BufferUtil; public class DataFrameGenerator { @@ -30,6 +31,8 @@ public class DataFrameGenerator public ByteBuffer generate(int streamId, int length, DataInfo dataInfo) { ByteBuffer buffer = bufferPool.acquire(DataFrame.HEADER_LENGTH + length, true); + BufferUtil.clearToFill(buffer); + buffer.limit(length + DataFrame.HEADER_LENGTH); //TODO: thomas show Simone :) buffer.position(DataFrame.HEADER_LENGTH); // Guaranteed to always be >= 0 int read = dataInfo.readInto(buffer); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/Generator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/Generator.java index cccbf15586..aa382face0 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/Generator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/Generator.java @@ -16,7 +16,7 @@ package org.eclipse.jetty.spdy.generator; import java.nio.ByteBuffer; import java.util.EnumMap; -import org.eclipse.jetty.spdy.ByteBufferPool; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.CompressionFactory; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.frames.ControlFrame; diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/GoAwayGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/GoAwayGenerator.java index dced42a64e..fe5a9b0c2e 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/GoAwayGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/GoAwayGenerator.java @@ -15,10 +15,11 @@ package org.eclipse.jetty.spdy.generator; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.ByteBufferPool; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.frames.ControlFrame; import org.eclipse.jetty.spdy.frames.GoAwayFrame; +import org.eclipse.jetty.util.BufferUtil; public class GoAwayGenerator extends ControlFrameGenerator { @@ -35,6 +36,7 @@ public class GoAwayGenerator extends ControlFrameGenerator int frameBodyLength = 8; int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength; ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true); + BufferUtil.clearToFill(buffer); generateControlFrameHeader(goAway, frameBodyLength, buffer); buffer.putInt(goAway.getLastStreamId() & 0x7F_FF_FF_FF); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersGenerator.java index 6f520d91ea..ec259299e2 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/HeadersGenerator.java @@ -15,12 +15,13 @@ package org.eclipse.jetty.spdy.generator; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.ByteBufferPool; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.SessionException; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.SessionStatus; import org.eclipse.jetty.spdy.frames.ControlFrame; import org.eclipse.jetty.spdy.frames.HeadersFrame; +import org.eclipse.jetty.util.BufferUtil; public class HeadersGenerator extends ControlFrameGenerator { @@ -55,6 +56,7 @@ public class HeadersGenerator extends ControlFrameGenerator int totalLength = ControlFrame.HEADER_LENGTH + frameLength; ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true); + BufferUtil.clearToFill(buffer); generateControlFrameHeader(headers, frameLength, buffer); buffer.putInt(headers.getStreamId() & 0x7F_FF_FF_FF); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/NoOpGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/NoOpGenerator.java index 86a2feb5c0..281a3d18be 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/NoOpGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/NoOpGenerator.java @@ -15,9 +15,10 @@ package org.eclipse.jetty.spdy.generator; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.ByteBufferPool; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.frames.ControlFrame; import org.eclipse.jetty.spdy.frames.NoOpFrame; +import org.eclipse.jetty.util.BufferUtil; public class NoOpGenerator extends ControlFrameGenerator { @@ -34,6 +35,7 @@ public class NoOpGenerator extends ControlFrameGenerator int frameBodyLength = 0; int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength; ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true); + BufferUtil.clearToFill(buffer); generateControlFrameHeader(noOp, frameBodyLength, buffer); buffer.flip(); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/PingGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/PingGenerator.java index 0ead892baa..73ef7c2be2 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/PingGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/PingGenerator.java @@ -15,9 +15,10 @@ package org.eclipse.jetty.spdy.generator; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.ByteBufferPool; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.frames.ControlFrame; import org.eclipse.jetty.spdy.frames.PingFrame; +import org.eclipse.jetty.util.BufferUtil; public class PingGenerator extends ControlFrameGenerator { @@ -34,6 +35,7 @@ public class PingGenerator extends ControlFrameGenerator int frameBodyLength = 4; int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength; ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true); + BufferUtil.clearToFill(buffer); generateControlFrameHeader(ping, frameBodyLength, buffer); buffer.putInt(ping.getPingId()); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/RstStreamGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/RstStreamGenerator.java index 63a014250e..ce7563001e 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/RstStreamGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/RstStreamGenerator.java @@ -15,9 +15,10 @@ package org.eclipse.jetty.spdy.generator; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.ByteBufferPool; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.frames.ControlFrame; import org.eclipse.jetty.spdy.frames.RstStreamFrame; +import org.eclipse.jetty.util.BufferUtil; public class RstStreamGenerator extends ControlFrameGenerator { @@ -34,6 +35,7 @@ public class RstStreamGenerator extends ControlFrameGenerator int frameBodyLength = 8; int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength; ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true); + BufferUtil.clearToFill(buffer); generateControlFrameHeader(rstStream, frameBodyLength, buffer); buffer.putInt(rstStream.getStreamId() & 0x7F_FF_FF_FF); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SettingsGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SettingsGenerator.java index 6004afa905..18f036931e 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SettingsGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SettingsGenerator.java @@ -15,11 +15,12 @@ package org.eclipse.jetty.spdy.generator; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.ByteBufferPool; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.Settings; import org.eclipse.jetty.spdy.frames.ControlFrame; import org.eclipse.jetty.spdy.frames.SettingsFrame; +import org.eclipse.jetty.util.BufferUtil; public class SettingsGenerator extends ControlFrameGenerator { @@ -38,6 +39,7 @@ public class SettingsGenerator extends ControlFrameGenerator int frameBodyLength = 4 + 8 * size; int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength; ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true); + BufferUtil.clearToFill(buffer); generateControlFrameHeader(settingsFrame, frameBodyLength, buffer); buffer.putInt(size); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynReplyGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynReplyGenerator.java index fc8f382700..e559c677ef 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynReplyGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynReplyGenerator.java @@ -15,12 +15,13 @@ package org.eclipse.jetty.spdy.generator; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.ByteBufferPool; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.SessionException; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.SessionStatus; import org.eclipse.jetty.spdy.frames.ControlFrame; import org.eclipse.jetty.spdy.frames.SynReplyFrame; +import org.eclipse.jetty.util.BufferUtil; public class SynReplyGenerator extends ControlFrameGenerator { @@ -53,6 +54,7 @@ public class SynReplyGenerator extends ControlFrameGenerator int totalLength = ControlFrame.HEADER_LENGTH + frameLength; ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true); + BufferUtil.clearToFill(buffer); generateControlFrameHeader(synReply, frameLength, buffer); buffer.putInt(synReply.getStreamId() & 0x7F_FF_FF_FF); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynStreamGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynStreamGenerator.java index ff6ace8699..5cc615b57c 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynStreamGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/SynStreamGenerator.java @@ -15,7 +15,7 @@ package org.eclipse.jetty.spdy.generator; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.ByteBufferPool; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.SessionException; import org.eclipse.jetty.spdy.StreamException; import org.eclipse.jetty.spdy.api.SPDY; @@ -23,6 +23,7 @@ import org.eclipse.jetty.spdy.api.SessionStatus; import org.eclipse.jetty.spdy.api.StreamStatus; import org.eclipse.jetty.spdy.frames.ControlFrame; import org.eclipse.jetty.spdy.frames.SynStreamFrame; +import org.eclipse.jetty.util.BufferUtil; public class SynStreamGenerator extends ControlFrameGenerator { @@ -55,6 +56,7 @@ public class SynStreamGenerator extends ControlFrameGenerator int totalLength = ControlFrame.HEADER_LENGTH + frameLength; ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true); + BufferUtil.clearToFill(buffer); generateControlFrameHeader(synStream, frameLength, buffer); int streamId = synStream.getStreamId(); diff --git a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/WindowUpdateGenerator.java b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/WindowUpdateGenerator.java index 38092803cf..6c6e3a97c4 100644 --- a/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/WindowUpdateGenerator.java +++ b/jetty-spdy/spdy-core/src/main/java/org/eclipse/jetty/spdy/generator/WindowUpdateGenerator.java @@ -15,9 +15,10 @@ package org.eclipse.jetty.spdy.generator; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.ByteBufferPool; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.frames.ControlFrame; import org.eclipse.jetty.spdy.frames.WindowUpdateFrame; +import org.eclipse.jetty.util.BufferUtil; public class WindowUpdateGenerator extends ControlFrameGenerator { @@ -34,6 +35,7 @@ public class WindowUpdateGenerator extends ControlFrameGenerator int frameBodyLength = 8; int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength; ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true); + BufferUtil.clearToFill(buffer); generateControlFrameHeader(windowUpdate, frameBodyLength, buffer); buffer.putInt(windowUpdate.getStreamId() & 0x7F_FF_FF_FF); diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/AsyncTimeoutTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/AsyncTimeoutTest.java index 16af7c7a51..2fe4b2adaa 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/AsyncTimeoutTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/AsyncTimeoutTest.java @@ -20,7 +20,8 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.spdy.api.Handler; +import org.eclipse.jetty.io.ByteBufferPool; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.SPDYException; import org.eclipse.jetty.spdy.api.Session; @@ -28,6 +29,7 @@ import org.eclipse.jetty.spdy.api.Stream; import org.eclipse.jetty.spdy.api.StringDataInfo; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.generator.Generator; +import org.eclipse.jetty.util.Callback; import org.junit.Assert; import org.junit.Test; @@ -61,7 +63,7 @@ public class AsyncTimeoutTest }; final CountDownLatch failedLatch = new CountDownLatch(1); - session.syn(new SynInfo(true), null, timeout, unit, new Handler() + session.syn(new SynInfo(true), null, timeout, unit, new Callback() { @Override public void completed(Stream stream) @@ -91,14 +93,14 @@ public class AsyncTimeoutTest Session session = new StandardSession(SPDY.V2, bufferPool, threadPool, scheduler, new TestController(), null, 1, null, generator, new FlowControlStrategy.None()) { @Override - protected void write(ByteBuffer buffer, Handler handler, FrameBytes frameBytes) + protected void write(ByteBuffer buffer, Callback callback, FrameBytes frameBytes) { try { // Wait if we're writing the data frame (control frame's first byte is 0x80) if (buffer.get(0) == 0) unit.sleep(2 * timeout); - super.write(buffer, handler, frameBytes); + super.write(buffer, callback, frameBytes); } catch (InterruptedException x) { @@ -109,13 +111,8 @@ public class AsyncTimeoutTest Stream stream = session.syn(new SynInfo(false), null).get(5, TimeUnit.SECONDS); final CountDownLatch failedLatch = new CountDownLatch(1); - stream.data(new StringDataInfo("data", true), timeout, unit, new Handler() + stream.data(new StringDataInfo("data", true), timeout, unit, new Callback.Empty() { - @Override - public void completed(Void context) - { - } - @Override public void failed(Void context, Throwable x) { @@ -129,9 +126,9 @@ public class AsyncTimeoutTest private static class TestController implements Controller { @Override - public int write(ByteBuffer buffer, Handler handler, StandardSession.FrameBytes context) + public int write(ByteBuffer buffer, Callback callback, StandardSession.FrameBytes context) { - handler.completed(context); + callback.completed(context); return buffer.remaining(); } diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java index 6406f623ae..7e0c2e7ad6 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardSessionTest.java @@ -23,10 +23,11 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.eclipse.jetty.io.ByteBufferPool; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.StandardSession.FrameBytes; import org.eclipse.jetty.spdy.api.ByteBufferDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; -import org.eclipse.jetty.spdy.api.Handler; import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.HeadersInfo; import org.eclipse.jetty.spdy.api.RstInfo; @@ -41,6 +42,7 @@ import org.eclipse.jetty.spdy.frames.DataFrame; import org.eclipse.jetty.spdy.frames.SynReplyFrame; import org.eclipse.jetty.spdy.frames.SynStreamFrame; import org.eclipse.jetty.spdy.generator.Generator; +import org.eclipse.jetty.util.Callback; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -86,19 +88,19 @@ public class StandardSessionTest @SuppressWarnings("unchecked") private void setControllerWriteExpectationToFail(final boolean fail) { - when(controller.write(any(ByteBuffer.class),any(Handler.class),any(StandardSession.FrameBytes.class))).thenAnswer(new Answer() + when(controller.write(any(ByteBuffer.class),any(Callback.class),any(StandardSession.FrameBytes.class))).thenAnswer(new Answer() { public Integer answer(InvocationOnMock invocation) { Object[] args = invocation.getArguments(); - Handler handler = (Handler)args[1]; + Callback callback = (Callback)args[1]; FrameBytes context = (FrameBytes)args[2]; if (fail) - handler.failed(context,new ClosedChannelException()); + callback.failed(context,new ClosedChannelException()); else - handler.completed(context); + callback.completed(context); return 0; } }); @@ -205,7 +207,7 @@ public class StandardSessionTest { final CountDownLatch failedLatch = new CountDownLatch(1); SynInfo synInfo = new SynInfo(headers,false,stream.getPriority()); - stream.syn(synInfo,5,TimeUnit.SECONDS,new Handler.Adapter() + stream.syn(synInfo,5,TimeUnit.SECONDS,new Callback.Empty() { @Override public void failed(Stream stream, Throwable x) @@ -404,22 +406,22 @@ public class StandardSessionTest SynStreamFrame synStreamFrame = new SynStreamFrame(SPDY.V2, SynInfo.FLAG_CLOSE, 1, 0, (byte)0, (short)0, null); IStream stream = new StandardStream(synStreamFrame.getStreamId(), synStreamFrame.getPriority(), session, null); stream.updateWindowSize(8192); - Handler.Adapter handler = new Handler.Adapter() + Callback.Empty callback = new Callback.Empty() { @Override - public void failed(Void context, Throwable x) + public void failed(Object context, Throwable x) { failedCalledLatch.countDown(); } }; // first data frame should fail on controller.write() - stream.data(new StringDataInfo("data", false), 5, TimeUnit.SECONDS, handler); + stream.data(new StringDataInfo("data", false), 5, TimeUnit.SECONDS, callback); // second data frame should fail without controller.writer() as the connection is expected to be broken after first controller.write() call failed. - stream.data(new StringDataInfo("data", false), 5, TimeUnit.SECONDS, handler); + stream.data(new StringDataInfo("data", false), 5, TimeUnit.SECONDS, callback); - verify(controller, times(1)).write(any(ByteBuffer.class), any(Handler.class), any(FrameBytes.class)); - assertThat("Handler.failed has been called twice", failedCalledLatch.await(5, TimeUnit.SECONDS), is(true)); + verify(controller, times(1)).write(any(ByteBuffer.class), any(Callback.class), any(FrameBytes.class)); + assertThat("Callback.failed has been called twice", failedCalledLatch.await(5, TimeUnit.SECONDS), is(true)); } private IStream createStream() throws InterruptedException, ExecutionException, TimeoutException diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardStreamTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardStreamTest.java index f75c723739..8dd0a370d3 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardStreamTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/StandardStreamTest.java @@ -21,13 +21,13 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.eclipse.jetty.spdy.api.DataInfo; -import org.eclipse.jetty.spdy.api.Handler; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.Stream; import org.eclipse.jetty.spdy.api.StreamFrameListener; import org.eclipse.jetty.spdy.api.StringDataInfo; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.frames.SynStreamFrame; +import org.eclipse.jetty.util.Callback; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentMatcher; @@ -67,7 +67,7 @@ public class StandardStreamTest SynInfo synInfo = new SynInfo(false); when(session.getStreams()).thenReturn(streams); stream.syn(synInfo); - verify(session).syn(argThat(new PushSynInfoMatcher(stream.getId(), synInfo)), any(StreamFrameListener.class), anyLong(), any(TimeUnit.class), any(Handler.class)); + verify(session).syn(argThat(new PushSynInfoMatcher(stream.getId(), synInfo)), any(StreamFrameListener.class), anyLong(), any(TimeUnit.class), any(Callback.class)); } private class PushSynInfoMatcher extends ArgumentMatcher @@ -107,7 +107,7 @@ public class StandardStreamTest stream.updateCloseState(true, false); assertThat("stream expected to be closed", stream.isClosed(), is(true)); final CountDownLatch failedLatch = new CountDownLatch(1); - stream.syn(new SynInfo(false), 1, TimeUnit.SECONDS, new Handler.Adapter() + stream.syn(new SynInfo(false), 1, TimeUnit.SECONDS, new Callback.Empty() { @Override public void failed(Stream stream, Throwable x) @@ -128,6 +128,6 @@ public class StandardStreamTest stream.updateCloseState(synStreamFrame.isClose(), true); assertThat("stream is half closed", stream.isHalfClosed(), is(true)); stream.data(new StringDataInfo("data on half closed stream", true)); - verify(session, never()).data(any(IStream.class), any(DataInfo.class), anyInt(), any(TimeUnit.class), any(Handler.class), any(void.class)); + verify(session, never()).data(any(IStream.class), any(DataInfo.class), anyInt(), any(TimeUnit.class), any(Callback.class), any(void.class)); } } diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ClientUsageTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ClientUsageTest.java index 9de7f49175..39e6252b02 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ClientUsageTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ClientUsageTest.java @@ -17,6 +17,7 @@ import java.nio.charset.Charset; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.spdy.StandardSession; +import org.eclipse.jetty.util.Callback; import org.junit.Ignore; import org.junit.Test; @@ -80,7 +81,7 @@ public class ClientUsageTest // Then issue another similar request stream.getSession().syn(new SynInfo(true), this); } - }, 0, TimeUnit.MILLISECONDS, new Handler.Adapter() + }, 0, TimeUnit.MILLISECONDS, new Callback.Empty() { @Override public void completed(Stream stream) @@ -135,7 +136,7 @@ public class ClientUsageTest } } - }, 0, TimeUnit.MILLISECONDS, new Handler.Adapter() + }, 0, TimeUnit.MILLISECONDS, new Callback.Empty() { @Override public void completed(Stream stream) diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ServerUsageTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ServerUsageTest.java index b1a326fc17..fe10404b8a 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ServerUsageTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/api/ServerUsageTest.java @@ -16,6 +16,7 @@ package org.eclipse.jetty.spdy.api; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; +import org.eclipse.jetty.util.Callback; import org.junit.Ignore; import org.junit.Test; @@ -66,7 +67,7 @@ public class ServerUsageTest // // However, the API may allow to initiate the stream - session.syn(new SynInfo(false), null, 0, TimeUnit.MILLISECONDS, new Handler.Adapter() + session.syn(new SynInfo(false), null, 0, TimeUnit.MILLISECONDS, new Callback.Empty() { @Override public void completed(Stream stream) @@ -96,7 +97,7 @@ public class ServerUsageTest Session session = stream.getSession(); // Since it's unidirectional, no need to pass the listener - session.syn(new SynInfo(new Headers(), false, (byte)0), null, 0, TimeUnit.MILLISECONDS, new Handler.Adapter() + session.syn(new SynInfo(new Headers(), false, (byte)0), null, 0, TimeUnit.MILLISECONDS, new Callback.Empty() { @Override public void completed(Stream pushStream) diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/CredentialGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/CredentialGenerateParseTest.java index e7db2c8c7a..cdd5d85d2b 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/CredentialGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/CredentialGenerateParseTest.java @@ -18,7 +18,7 @@ import java.nio.ByteBuffer; import java.security.KeyStore; import java.security.cert.Certificate; -import org.eclipse.jetty.spdy.StandardByteBufferPool; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.generator.Generator; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/DataGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/DataGenerateParseTest.java index 6f53b64c09..4f90dc007f 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/DataGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/DataGenerateParseTest.java @@ -15,7 +15,7 @@ package org.eclipse.jetty.spdy.frames; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.StandardByteBufferPool; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.api.StringDataInfo; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/GoAwayGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/GoAwayGenerateParseTest.java index c3ae26d436..01ebccb973 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/GoAwayGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/GoAwayGenerateParseTest.java @@ -15,7 +15,7 @@ package org.eclipse.jetty.spdy.frames; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.StandardByteBufferPool; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.generator.Generator; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/HeadersGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/HeadersGenerateParseTest.java index fd5a36de3d..67779be01d 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/HeadersGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/HeadersGenerateParseTest.java @@ -15,7 +15,7 @@ package org.eclipse.jetty.spdy.frames; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.StandardByteBufferPool; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.HeadersInfo; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/NoOpGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/NoOpGenerateParseTest.java index 9c248be4ed..4f0ff597eb 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/NoOpGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/NoOpGenerateParseTest.java @@ -15,7 +15,7 @@ package org.eclipse.jetty.spdy.frames; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.StandardByteBufferPool; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; import org.eclipse.jetty.spdy.generator.Generator; import org.eclipse.jetty.spdy.parser.Parser; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/PingGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/PingGenerateParseTest.java index 1bd87f8601..99ee7a0a15 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/PingGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/PingGenerateParseTest.java @@ -15,7 +15,7 @@ package org.eclipse.jetty.spdy.frames; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.StandardByteBufferPool; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.generator.Generator; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/RstStreamGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/RstStreamGenerateParseTest.java index df70d3695d..8635931c4c 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/RstStreamGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/RstStreamGenerateParseTest.java @@ -13,15 +13,9 @@ package org.eclipse.jetty.spdy.frames; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; - import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.StandardByteBufferPool; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.StreamStatus; @@ -30,6 +24,12 @@ import org.eclipse.jetty.spdy.parser.Parser; import org.junit.Assert; import org.junit.Test; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertThat; + public class RstStreamGenerateParseTest { @Test diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SettingsGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SettingsGenerateParseTest.java index 88b640d63c..5b1fbf1fee 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SettingsGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SettingsGenerateParseTest.java @@ -15,7 +15,7 @@ package org.eclipse.jetty.spdy.frames; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.StandardByteBufferPool; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.Settings; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynReplyGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynReplyGenerateParseTest.java index 6da3189c54..9f5e8ab0c2 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynReplyGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynReplyGenerateParseTest.java @@ -15,7 +15,7 @@ package org.eclipse.jetty.spdy.frames; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.StandardByteBufferPool; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.ReplyInfo; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynStreamGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynStreamGenerateParseTest.java index 5cf4b223c1..4fc2438eed 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynStreamGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/SynStreamGenerateParseTest.java @@ -15,7 +15,7 @@ package org.eclipse.jetty.spdy.frames; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.StandardByteBufferPool; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.SPDY; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/WindowUpdateGenerateParseTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/WindowUpdateGenerateParseTest.java index 41bdf676ac..1ca52b404b 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/WindowUpdateGenerateParseTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/frames/WindowUpdateGenerateParseTest.java @@ -15,7 +15,7 @@ package org.eclipse.jetty.spdy.frames; import java.nio.ByteBuffer; -import org.eclipse.jetty.spdy.StandardByteBufferPool; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.generator.Generator; diff --git a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameTest.java b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameTest.java index 12c470c40c..f9810149cf 100644 --- a/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameTest.java +++ b/jetty-spdy/spdy-core/src/test/java/org/eclipse/jetty/spdy/parser/UnknownControlFrameTest.java @@ -17,8 +17,8 @@ import java.nio.ByteBuffer; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.SessionException; -import org.eclipse.jetty.spdy.StandardByteBufferPool; import org.eclipse.jetty.spdy.StandardCompressionFactory; import org.eclipse.jetty.spdy.StreamException; import org.eclipse.jetty.spdy.api.Headers; diff --git a/jetty-spdy/spdy-jetty-http-webapp/pom.xml b/jetty-spdy/spdy-jetty-http-webapp/pom.xml index 491f1313ce..6616a1d786 100644 --- a/jetty-spdy/spdy-jetty-http-webapp/pom.xml +++ b/jetty-spdy/spdy-jetty-http-webapp/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.spdy spdy-parent - 8.1.6-SNAPSHOT + 9.0.0-SNAPSHOT 4.0.0 spdy-jetty-http-webapp diff --git a/jetty-spdy/spdy-jetty-http/pom.xml b/jetty-spdy/spdy-jetty-http/pom.xml index 948d342224..151cb9cee7 100644 --- a/jetty-spdy/spdy-jetty-http/pom.xml +++ b/jetty-spdy/spdy-jetty-http/pom.xml @@ -3,7 +3,7 @@ org.eclipse.jetty.spdy spdy-parent - 8.1.6-SNAPSHOT + 9.0.0-SNAPSHOT 4.0.0 spdy-jetty-http diff --git a/jetty-spdy/spdy-jetty/pom.xml b/jetty-spdy/spdy-jetty/pom.xml index 3c070948cc..d9891e0d73 100644 --- a/jetty-spdy/spdy-jetty/pom.xml +++ b/jetty-spdy/spdy-jetty/pom.xml @@ -3,8 +3,9 @@ org.eclipse.jetty.spdy spdy-parent - 8.1.6-SNAPSHOT + 9.0.0-SNAPSHOT + 4.0.0 spdy-jetty Jetty :: SPDY :: Jetty Binding diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/AsyncConnectionFactory.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/AsyncConnectionFactory.java index 97f9db59c4..e28b05024b 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/AsyncConnectionFactory.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/AsyncConnectionFactory.java @@ -16,8 +16,8 @@ package org.eclipse.jetty.spdy; import java.nio.channels.SocketChannel; +import org.eclipse.jetty.io.AsyncConnection; import org.eclipse.jetty.io.AsyncEndPoint; -import org.eclipse.jetty.io.nio.AsyncConnection; public interface AsyncConnectionFactory { diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncConnection.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncConnection.java index a2888ce88e..acb762f661 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncConnection.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncConnection.java @@ -1,63 +1,43 @@ -//======================================================================== -//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. -//------------------------------------------------------------------------ -//All rights reserved. This program and the accompanying materials -//are made available under the terms of the Eclipse Public License v1.0 -//and Apache License v2.0 which accompanies this distribution. -//The Eclipse Public License is available at -//http://www.eclipse.org/legal/epl-v10.html -//The Apache License v2.0 is available at -//http://www.opensource.org/licenses/apache2.0.php -//You may elect to redistribute this code under either of these licenses. -//======================================================================== - +/* + * Copyright (c) 2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.eclipse.jetty.spdy; -import java.io.IOException; +import java.util.concurrent.Executor; -import org.eclipse.jetty.io.AbstractConnection; +import org.eclipse.jetty.io.AbstractAsyncConnection; import org.eclipse.jetty.io.AsyncEndPoint; -import org.eclipse.jetty.io.Connection; -import org.eclipse.jetty.io.nio.AsyncConnection; -public class EmptyAsyncConnection extends AbstractConnection implements AsyncConnection +public class EmptyAsyncConnection extends AbstractAsyncConnection { public EmptyAsyncConnection(AsyncEndPoint endPoint) { - super(endPoint); - } - - public Connection handle() throws IOException - { - return this; - } - - @Override - public AsyncEndPoint getEndPoint() - { - return (AsyncEndPoint)super.getEndPoint(); + super(endPoint, new Executor() + { + @Override + public void execute(Runnable command) + { + command.run(); + } + }); } @Override - public boolean isIdle() + public void onFillable() { - return false; } - @Override - public boolean isSuspended() - { - return false; - } - - @Override - public void onClose() - { - } - - @Override - public void onInputShutdown() throws IOException - { - } } diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java index 58dbc8a9aa..a204867c2d 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java @@ -1,103 +1,59 @@ -//======================================================================== -//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. -//------------------------------------------------------------------------ -//All rights reserved. This program and the accompanying materials -//are made available under the terms of the Eclipse Public License v1.0 -//and Apache License v2.0 which accompanies this distribution. -//The Eclipse Public License is available at -//http://www.eclipse.org/legal/epl-v10.html -//The Apache License v2.0 is available at -//http://www.opensource.org/licenses/apache2.0.php -//You may elect to redistribute this code under either of these licenses. -//======================================================================== - +/* + * Copyright (c) 2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.eclipse.jetty.spdy; import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; +import java.nio.channels.ReadPendingException; +import java.nio.channels.WritePendingException; +import org.eclipse.jetty.io.AsyncConnection; import org.eclipse.jetty.io.AsyncEndPoint; -import org.eclipse.jetty.io.Buffer; -import org.eclipse.jetty.io.Connection; -import org.eclipse.jetty.util.thread.Timeout; +import org.eclipse.jetty.util.Callback; public class EmptyAsyncEndPoint implements AsyncEndPoint { private boolean checkForIdle; - private Connection connection; + private AsyncConnection connection; private boolean oshut; - private boolean ishut; private boolean closed; - private int maxIdleTime; - - @Override - public void dispatch() - { - } - - @Override - public void asyncDispatch() - { - } - - @Override - public void scheduleWrite() - { - } - - @Override - public void onIdleExpired(long idleForMs) - { - } - - @Override - public void setCheckForIdle(boolean check) - { - this.checkForIdle = check; - } + private long maxIdleTime; @Override - public boolean isCheckForIdle() - { - return checkForIdle; - } - - @Override - public boolean isWritable() - { - return false; - } - - @Override - public boolean hasProgressed() - { - return false; - } - - @Override - public void scheduleTimeout(Timeout.Task task, long timeoutMs) - { - } - - @Override - public void cancelTimeout(Timeout.Task task) + public long getCreatedTimeStamp() { + return 0; } @Override - public Connection getConnection() + public AsyncConnection getAsyncConnection() { return connection; } @Override - public void setConnection(Connection connection) + public void setAsyncConnection(AsyncConnection connection) { this.connection = connection; } @Override - public void shutdownOutput() throws IOException + public void shutdownOutput() { oshut = true; } @@ -108,122 +64,83 @@ public class EmptyAsyncEndPoint implements AsyncEndPoint return oshut; } - @Override - public void shutdownInput() throws IOException - { - ishut = true; - } - @Override public boolean isInputShutdown() { - return ishut; + return false; } @Override - public void close() throws IOException + public void close() { closed = true; } @Override - public int fill(Buffer buffer) throws IOException - { - return 0; - } - - @Override - public int flush(Buffer buffer) throws IOException + public int fill(ByteBuffer buffer) throws IOException { return 0; } @Override - public int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException + public int flush(ByteBuffer... buffer) throws IOException { return 0; } @Override - public String getLocalAddr() + public InetSocketAddress getLocalAddress() { return null; } @Override - public String getLocalHost() + public InetSocketAddress getRemoteAddress() { return null; } @Override - public int getLocalPort() - { - return -1; - } - - @Override - public String getRemoteAddr() + public boolean isOpen() { - return null; + return !closed; } @Override - public String getRemoteHost() + public Object getTransport() { return null; } @Override - public int getRemotePort() - { - return -1; - } - - @Override - public boolean isBlocking() - { - return false; - } - - @Override - public boolean blockReadable(long millisecs) throws IOException - { - return false; - } - - @Override - public boolean blockWritable(long millisecs) throws IOException + public long getIdleTimeout() { - return false; + return maxIdleTime; } @Override - public boolean isOpen() + public void setIdleTimeout(long timeMs) { - return !closed; + this.maxIdleTime = timeMs; } @Override - public Object getTransport() + public void onOpen() { - return null; } @Override - public void flush() throws IOException + public void onClose() { } @Override - public int getMaxIdleTime() + public void fillInterested(C context, Callback callback) throws ReadPendingException { - return maxIdleTime; } @Override - public void setMaxIdleTime(int timeMs) throws IOException + public void write(C context, Callback callback, ByteBuffer... buffers) throws WritePendingException { - this.maxIdleTime = timeMs; } } diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java index bb6b45cd5e..cf57aff253 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java @@ -1,228 +1,131 @@ -//======================================================================== -//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd. -//------------------------------------------------------------------------ -//All rights reserved. This program and the accompanying materials -//are made available under the terms of the Eclipse Public License v1.0 -//and Apache License v2.0 which accompanies this distribution. -//The Eclipse Public License is available at -//http://www.eclipse.org/legal/epl-v10.html -//The Apache License v2.0 is available at -//http://www.opensource.org/licenses/apache2.0.php -//You may elect to redistribute this code under either of these licenses. -//======================================================================== - +/* + * Copyright (c) 2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.eclipse.jetty.spdy; import java.io.IOException; import java.nio.ByteBuffer; +import java.util.concurrent.Executor; -import org.eclipse.jetty.io.AbstractConnection; +import org.eclipse.jetty.io.AbstractAsyncConnection; import org.eclipse.jetty.io.AsyncEndPoint; -import org.eclipse.jetty.io.Buffer; -import org.eclipse.jetty.io.Connection; -import org.eclipse.jetty.io.nio.AsyncConnection; -import org.eclipse.jetty.io.nio.DirectNIOBuffer; -import org.eclipse.jetty.io.nio.IndirectNIOBuffer; -import org.eclipse.jetty.io.nio.NIOBuffer; -import org.eclipse.jetty.spdy.api.Handler; +import org.eclipse.jetty.io.ByteBufferPool; +import org.eclipse.jetty.io.RuntimeIOException; import org.eclipse.jetty.spdy.api.Session; import org.eclipse.jetty.spdy.parser.Parser; +import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -public class SPDYAsyncConnection extends AbstractConnection implements AsyncConnection, Controller, IdleListener +public class SPDYAsyncConnection extends AbstractAsyncConnection implements Controller, IdleListener { private static final Logger logger = Log.getLogger(SPDYAsyncConnection.class); private final ByteBufferPool bufferPool; private final Parser parser; private volatile Session session; - private ByteBuffer writeBuffer; - private Handler writeHandler; - private StandardSession.FrameBytes writeContext; - private volatile boolean writePending; + private volatile boolean idle = false; - public SPDYAsyncConnection(AsyncEndPoint endPoint, ByteBufferPool bufferPool, Parser parser) + public SPDYAsyncConnection(AsyncEndPoint endPoint, ByteBufferPool bufferPool, Parser parser, Executor executor) { - super(endPoint); + super(endPoint, executor); this.bufferPool = bufferPool; this.parser = parser; onIdle(true); } @Override - public Connection handle() throws IOException + public void onFillable() { - AsyncEndPoint endPoint = getEndPoint(); - boolean progress = true; - while (endPoint.isOpen() && progress) - { - int filled = fill(); - progress = filled > 0; - - int flushed = flush(); - progress |= flushed > 0; - - endPoint.flush(); - - progress |= endPoint.hasProgressed(); - - if (!progress && filled < 0) - { - onInputShutdown(); - close(false); - } - } - return this; - } - - public int fill() throws IOException - { - ByteBuffer buffer = bufferPool.acquire(8192, true); - NIOBuffer jettyBuffer = new DirectNIOBuffer(buffer, false); - jettyBuffer.setPutIndex(jettyBuffer.getIndex()); - AsyncEndPoint endPoint = getEndPoint(); - int filled = endPoint.fill(jettyBuffer); - logger.debug("Filled {} from {}", filled, endPoint); - if (filled <= 0) - return filled; - - buffer.limit(jettyBuffer.putIndex()); - buffer.position(jettyBuffer.getIndex()); - parser.parse(buffer); - + ByteBuffer buffer = bufferPool.acquire(8192, true); //TODO: 8k window? + boolean readMore = read(buffer) == 0; bufferPool.release(buffer); - - return filled; - } - - public int flush() - { - int result = 0; - // Volatile read to ensure visibility of buffer and handler - if (writePending) - result = write(writeBuffer, writeHandler, writeContext); - logger.debug("Flushed {} to {}", result, getEndPoint()); - return result; + if (readMore) + fillInterested(); } - @Override - public int write(ByteBuffer buffer, Handler handler, StandardSession.FrameBytes context) + protected int read(ByteBuffer buffer) { - int remaining = buffer.remaining(); - Buffer jettyBuffer = buffer.isDirect() ? new DirectNIOBuffer(buffer, false) : new IndirectNIOBuffer(buffer, false); AsyncEndPoint endPoint = getEndPoint(); - try - { - int written = endPoint.flush(jettyBuffer); - logger.debug("Written {} bytes, {} remaining", written, jettyBuffer.length()); - } - catch (Exception x) + while (true) { - close(false); - handler.failed(context, x); - return -1; - } - finally - { - buffer.limit(jettyBuffer.putIndex()); - buffer.position(jettyBuffer.getIndex()); - } - - if (buffer.hasRemaining()) - { - // Save buffer and handler in order to finish the write later in flush() - this.writeBuffer = buffer; - this.writeHandler = handler; - this.writeContext = context; - // Volatile write to ensure visibility of write fields - writePending = true; - endPoint.scheduleWrite(); - } - else - { - if (writePending) + int filled = fill(endPoint, buffer); + if (filled == 0) + { + return 0; + } + else if (filled < 0) { - this.writeBuffer = null; - this.writeHandler = null; - this.writeContext = null; - // Volatile write to ensure visibility of write fields - writePending = false; + close(false); + return -1; + } + else + { + parser.parse(buffer); } - handler.completed(context); } - - return remaining - buffer.remaining(); } - @Override - public void close(boolean onlyOutput) + private int fill(AsyncEndPoint endPoint, ByteBuffer buffer) { try { - AsyncEndPoint endPoint = getEndPoint(); - try - { - // We need to gently close first, to allow - // SSL close alerts to be sent by Jetty - logger.debug("Shutting down output {}", endPoint); - endPoint.shutdownOutput(); - if (!onlyOutput) - { - logger.debug("Closing {}", endPoint); - endPoint.close(); - } - } - catch (IOException x) - { - endPoint.close(); - } + return endPoint.fill(buffer); } catch (IOException x) { - logger.ignore(x); + endPoint.close(); + throw new RuntimeIOException(x); } } @Override - public void onIdle(boolean idle) - { - getEndPoint().setCheckForIdle(idle); - } - - @Override - public AsyncEndPoint getEndPoint() + public int write(ByteBuffer buffer, final Callback callback, StandardSession.FrameBytes context) { - return (AsyncEndPoint)super.getEndPoint(); - } - - @Override - public boolean isIdle() - { - return false; - } - - @Override - public boolean isSuspended() - { - return false; + AsyncEndPoint endPoint = getEndPoint(); + endPoint.write(context, callback, buffer); + return -1; //TODO: void or have endPoint.write return int } @Override - public void onClose() + public void close(boolean onlyOutput) { + AsyncEndPoint endPoint = getEndPoint(); + // We need to gently close first, to allow + // SSL close alerts to be sent by Jetty + logger.debug("Shutting down output {}", endPoint); + endPoint.shutdownOutput(); + if (!onlyOutput) + { + logger.debug("Closing {}", endPoint); + endPoint.close(); + } } @Override - public void onInputShutdown() throws IOException + public void onIdle(boolean idle) { + this.idle = idle; } @Override - public void onIdleExpired(long idleForMs) + protected boolean onReadTimeout() { - logger.debug("Idle timeout expired for {}", getEndPoint()); - session.goAway(); + if(idle) + session.goAway(); + return idle; } protected Session getSession() @@ -234,9 +137,4 @@ public class SPDYAsyncConnection extends AbstractConnection implements AsyncConn { this.session = session; } - - public String toString() - { - return String.format("%s@%x{endp=%s@%x}",getClass().getSimpleName(),hashCode(),getEndPoint().getClass().getSimpleName(),getEndPoint().hashCode()); - } } diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java index 65ecc2f53a..0b66e05ab4 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYClient.java @@ -29,18 +29,17 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ScheduledExecutorService; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLException; +import org.eclipse.jetty.io.AsyncConnection; import org.eclipse.jetty.io.AsyncEndPoint; -import org.eclipse.jetty.io.ConnectedEndPoint; -import org.eclipse.jetty.io.Connection; -import org.eclipse.jetty.io.nio.AsyncConnection; -import org.eclipse.jetty.io.nio.SelectChannelEndPoint; -import org.eclipse.jetty.io.nio.SelectorManager; -import org.eclipse.jetty.io.nio.SslConnection; +import org.eclipse.jetty.io.ByteBufferPool; +import org.eclipse.jetty.io.SelectChannelEndPoint; +import org.eclipse.jetty.io.SelectorManager; +import org.eclipse.jetty.io.StandardByteBufferPool; +import org.eclipse.jetty.io.ssl.SslConnection; import org.eclipse.jetty.npn.NextProtoNego; import org.eclipse.jetty.spdy.api.Session; import org.eclipse.jetty.spdy.api.SessionFrameListener; @@ -56,7 +55,7 @@ public class SPDYClient private final short version; private final Factory factory; private SocketAddress bindAddress; - private long maxIdleTime = -1; + private long idleTimeout = -1; private volatile int initialWindowSize = 65536; protected SPDYClient(short version, Factory factory) @@ -97,19 +96,19 @@ public class SPDYClient SessionPromise result = new SessionPromise(channel, this, listener); channel.connect(address); - factory.selector.register(channel, result); + factory.selector.connect(channel, result); return result; } - public long getMaxIdleTime() + public long getIdleTimeout() { - return maxIdleTime; + return idleTimeout; } - public void setMaxIdleTime(long maxIdleTime) + public void setIdleTimeout(long idleTimeout) { - this.maxIdleTime = maxIdleTime; + this.idleTimeout = idleTimeout; } public int getInitialWindowSize() @@ -190,24 +189,43 @@ public class SPDYClient private final Executor threadPool; private final SslContextFactory sslContextFactory; private final SelectorManager selector; + private final long defaultTimeout = 30000; + private final long idleTimeout; + //TODO: Replace with Builder?! public Factory() { - this(null, null); + this(null, null, 30000); } public Factory(SslContextFactory sslContextFactory) { - this(null, sslContextFactory); + this(null, sslContextFactory, 30000); + } + + public Factory(SslContextFactory sslContextFactory, long idleTimeout) + { + this(null, sslContextFactory, idleTimeout); } public Factory(Executor threadPool) { - this(threadPool, null); + this(threadPool, null, 30000); + } + + public Factory(Executor threadPool, long idleTimeout) + { + this(threadPool, null, idleTimeout); } public Factory(Executor threadPool, SslContextFactory sslContextFactory) { + this(threadPool, sslContextFactory, 30000); + } + + public Factory(Executor threadPool, SslContextFactory sslContextFactory, long idleTimeout) + { + this.idleTimeout = idleTimeout; if (threadPool == null) threadPool = new QueuedThreadPool(); this.threadPool = threadPool; @@ -275,50 +293,24 @@ public class SPDYClient private class ClientSelectorManager extends SelectorManager { - @Override - public boolean dispatch(Runnable task) - { - try - { - threadPool.execute(task); - return true; - } - catch (RejectedExecutionException x) - { - return false; - } - } @Override - protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey key) throws IOException + protected AsyncEndPoint newEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey key) throws IOException { SessionPromise attachment = (SessionPromise)key.attachment(); - long maxIdleTime = attachment.client.getMaxIdleTime(); - if (maxIdleTime < 0) - maxIdleTime = getMaxIdleTime(); - SelectChannelEndPoint result = new SelectChannelEndPoint(channel, selectSet, key, (int)maxIdleTime); - - AsyncConnection connection = newConnection(channel, result, attachment); - result.setConnection(connection); + long clientIdleTimeout = attachment.client.getIdleTimeout(); + if (clientIdleTimeout < 0) + clientIdleTimeout = idleTimeout; + AsyncEndPoint result = new SelectChannelEndPoint(channel, selectSet, key, scheduler, clientIdleTimeout); return result; } @Override - protected void endPointOpened(SelectChannelEndPoint endpoint) - { - } - - @Override - protected void endPointUpgraded(ConnectedEndPoint endpoint, Connection oldConnection) - { - } - - @Override - protected void endPointClosed(SelectChannelEndPoint endpoint) + protected void execute(Runnable task) { - endpoint.getConnection().onClose(); + threadPool.execute(task); } @Override @@ -332,7 +324,7 @@ public class SPDYClient if (sslContextFactory != null) { final SSLEngine engine = client.newSSLEngine(sslContextFactory, channel); - SslConnection sslConnection = new SslConnection(engine, endPoint) + SslConnection sslConnection = new SslConnection(bufferPool, threadPool, endPoint, engine) { @Override public void onClose() @@ -341,7 +333,7 @@ public class SPDYClient super.onClose(); } }; - endPoint.setConnection(sslConnection); + endPoint.setAsyncConnection(sslConnection); final AsyncEndPoint sslEndPoint = sslConnection.getSslEndPoint(); NextProtoNego.put(engine, new NextProtoNego.ClientProvider() { @@ -357,7 +349,7 @@ public class SPDYClient // Server does not support NPN, but this is a SPDY client, so hardcode SPDY ClientSPDYAsyncConnectionFactory connectionFactory = new ClientSPDYAsyncConnectionFactory(); AsyncConnection connection = connectionFactory.newAsyncConnection(channel, sslEndPoint, attachment); - sslEndPoint.setConnection(connection); + sslEndPoint.setAsyncConnection(connection); } @Override @@ -369,13 +361,13 @@ public class SPDYClient AsyncConnectionFactory connectionFactory = client.getAsyncConnectionFactory(protocol); AsyncConnection connection = connectionFactory.newAsyncConnection(channel, sslEndPoint, attachment); - sslEndPoint.setConnection(connection); + sslEndPoint.setAsyncConnection(connection); return protocol; } }); AsyncConnection connection = new EmptyAsyncConnection(sslEndPoint); - sslEndPoint.setConnection(connection); + sslEndPoint.setAsyncConnection(connection); startHandshake(engine); @@ -385,7 +377,7 @@ public class SPDYClient { AsyncConnectionFactory connectionFactory = new ClientSPDYAsyncConnectionFactory(); AsyncConnection connection = connectionFactory.newAsyncConnection(channel, endPoint, attachment); - endPoint.setConnection(connection); + endPoint.setAsyncConnection(connection); return connection; } } @@ -453,7 +445,7 @@ public class SPDYClient Generator generator = new Generator(factory.bufferPool, compressionFactory.newCompressor()); SPDYAsyncConnection connection = new ClientSPDYAsyncConnection(endPoint, factory.bufferPool, parser, factory); - endPoint.setConnection(connection); + endPoint.setAsyncConnection(connection); FlowControlStrategy flowControlStrategy = client.newFlowControlStrategy(); @@ -474,7 +466,7 @@ public class SPDYClient public ClientSPDYAsyncConnection(AsyncEndPoint endPoint, ByteBufferPool bufferPool, Parser parser, Factory factory) { - super(endPoint, bufferPool, parser); + super(endPoint, bufferPool, parser, factory.threadPool); this.factory = factory; } diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java index f85327189e..6dc2ab9dff 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYServerConnector.java @@ -32,9 +32,11 @@ import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLException; +import org.eclipse.jetty.io.AsyncConnection; import org.eclipse.jetty.io.AsyncEndPoint; -import org.eclipse.jetty.io.nio.AsyncConnection; -import org.eclipse.jetty.io.nio.SslConnection; +import org.eclipse.jetty.io.ByteBufferPool; +import org.eclipse.jetty.io.StandardByteBufferPool; +import org.eclipse.jetty.io.ssl.SslConnection; import org.eclipse.jetty.npn.NextProtoNego; import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.spdy.api.SPDY; @@ -44,7 +46,6 @@ import org.eclipse.jetty.util.component.AggregateLifeCycle; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.ssl.SslContextFactory; -import org.eclipse.jetty.util.thread.ThreadPool; public class SPDYServerConnector extends SelectChannelConnector { @@ -188,7 +189,7 @@ public class SPDYServerConnector extends SelectChannelConnector if (sslContextFactory != null) { final SSLEngine engine = newSSLEngine(sslContextFactory, channel); - SslConnection sslConnection = new SslConnection(engine, endPoint) + SslConnection sslConnection = new SslConnection(bufferPool, findExecutor(), endPoint, engine) { @Override public void onClose() @@ -197,7 +198,7 @@ public class SPDYServerConnector extends SelectChannelConnector super.onClose(); } }; - endPoint.setConnection(sslConnection); + endPoint.setAsyncConnection(sslConnection); final AsyncEndPoint sslEndPoint = sslConnection.getSslEndPoint(); NextProtoNego.put(engine, new NextProtoNego.ServerProvider() { @@ -206,7 +207,7 @@ public class SPDYServerConnector extends SelectChannelConnector { AsyncConnectionFactory connectionFactory = getDefaultAsyncConnectionFactory(); AsyncConnection connection = connectionFactory.newAsyncConnection(channel, sslEndPoint, SPDYServerConnector.this); - sslEndPoint.setConnection(connection); + sslEndPoint.setAsyncConnection(connection); } @Override @@ -220,12 +221,12 @@ public class SPDYServerConnector extends SelectChannelConnector { AsyncConnectionFactory connectionFactory = getAsyncConnectionFactory(protocol); AsyncConnection connection = connectionFactory.newAsyncConnection(channel, sslEndPoint, SPDYServerConnector.this); - sslEndPoint.setConnection(connection); + sslEndPoint.setAsyncConnection(connection); } }); AsyncConnection connection = new EmptyAsyncConnection(sslEndPoint); - sslEndPoint.setConnection(connection); + sslEndPoint.setAsyncConnection(connection); startHandshake(engine); @@ -235,7 +236,7 @@ public class SPDYServerConnector extends SelectChannelConnector { AsyncConnectionFactory connectionFactory = getDefaultAsyncConnectionFactory(); AsyncConnection connection = connectionFactory.newAsyncConnection(channel, endPoint, this); - endPoint.setConnection(connection); + endPoint.setAsyncConnection(connection); return connection; } } @@ -306,10 +307,10 @@ public class SPDYServerConnector extends SelectChannelConnector @Override public void execute(Runnable command) { - ThreadPool threadPool = getThreadPool(); + Executor threadPool = findExecutor(); if (threadPool == null) throw new RejectedExecutionException(); - threadPool.dispatch(command); + threadPool.execute(command); } } diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java index 4e45eedf74..626c89cdca 100644 --- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java +++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/ServerSPDYAsyncConnectionFactory.java @@ -14,14 +14,13 @@ package org.eclipse.jetty.spdy; -import java.io.IOException; import java.nio.channels.SocketChannel; import java.util.concurrent.Executor; import java.util.concurrent.ScheduledExecutorService; +import org.eclipse.jetty.io.AsyncConnection; import org.eclipse.jetty.io.AsyncEndPoint; -import org.eclipse.jetty.io.Connection; -import org.eclipse.jetty.io.nio.AsyncConnection; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; import org.eclipse.jetty.spdy.generator.Generator; import org.eclipse.jetty.spdy.parser.Parser; @@ -64,12 +63,12 @@ public class ServerSPDYAsyncConnectionFactory implements AsyncConnectionFactory ServerSessionFrameListener listener = provideServerSessionFrameListener(endPoint, attachment); SPDYAsyncConnection connection = new ServerSPDYAsyncConnection(endPoint, bufferPool, parser, listener, connector); - endPoint.setConnection(connection); + endPoint.setAsyncConnection(connection); FlowControlStrategy flowControlStrategy = connector.newFlowControlStrategy(version); StandardSession session = new StandardSession(version, bufferPool, threadPool, scheduler, connection, connection, 2, listener, generator, flowControlStrategy); - session.setAttribute("org.eclipse.jetty.spdy.remoteAddress", endPoint.getRemoteAddr()); + session.setAttribute("org.eclipse.jetty.spdy.remoteAddress", endPoint.getRemoteAddress()); session.setWindowSize(connector.getInitialWindowSize()); parser.addListener(session); connection.setSession(session); @@ -92,13 +91,13 @@ public class ServerSPDYAsyncConnectionFactory implements AsyncConnectionFactory private ServerSPDYAsyncConnection(AsyncEndPoint endPoint, ByteBufferPool bufferPool, Parser parser, ServerSessionFrameListener listener, SPDYServerConnector connector) { - super(endPoint, bufferPool, parser); + super(endPoint, bufferPool, parser, connector.findExecutor()); this.listener = listener; this.connector = connector; } @Override - public Connection handle() throws IOException + public void onOpen() { if (!connected) { @@ -107,7 +106,7 @@ public class ServerSPDYAsyncConnectionFactory implements AsyncConnectionFactory listener.onConnect(getSession()); connected = true; } - return super.handle(); + super.onOpen(); } @Override diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ClosedStreamTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ClosedStreamTest.java index a6108a3aa6..b7659c7932 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ClosedStreamTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ClosedStreamTest.java @@ -21,6 +21,7 @@ import java.nio.channels.SocketChannel; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.api.BytesDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.api.GoAwayInfo; @@ -140,6 +141,7 @@ public class ClosedStreamTest extends AbstractTest @Override public void onReply(Stream stream, ReplyInfo replyInfo) { + System.out.println("ONREPLY CLIENT CALLED"); replyReceivedLatch.countDown(); } @@ -149,11 +151,11 @@ public class ClosedStreamTest extends AbstractTest clientReceivedDataLatch.countDown(); } }).get(); - assertThat("reply has been received by client",replyReceivedLatch.await(5,TimeUnit.SECONDS),is(true)); + assertThat("reply has been received by client",replyReceivedLatch.await(500,TimeUnit.SECONDS),is(true)); assertThat("stream is half closed from server",stream.isHalfClosed(),is(true)); assertThat("client has not received any data sent after stream was half closed by server",clientReceivedDataLatch.await(1,TimeUnit.SECONDS), is(false)); - assertThat("sending data threw an exception",exceptionWhenSendingData.await(5,TimeUnit.SECONDS),is(true)); + assertThat("sending data threw an exception",exceptionWhenSendingData.await(500,TimeUnit.SECONDS),is(true)); //thomas } @Test diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/IdleTimeoutTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/IdleTimeoutTest.java index 2611bf28c9..8f4c34383d 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/IdleTimeoutTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/IdleTimeoutTest.java @@ -33,6 +33,9 @@ import org.junit.Test; public class IdleTimeoutTest extends AbstractTest { + + private final int idleTimeout = 1000; + @Test public void testServerEnforcingIdleTimeout() throws Exception { @@ -45,8 +48,7 @@ public class IdleTimeoutTest extends AbstractTest return null; } }); - int maxIdleTime = 1000; - connector.setMaxIdleTime(maxIdleTime); + connector.setIdleTimeout(idleTimeout); final CountDownLatch latch = new CountDownLatch(1); Session session = startClient(startServer(null), new SessionFrameListener.Adapter() @@ -60,15 +62,14 @@ public class IdleTimeoutTest extends AbstractTest session.syn(new SynInfo(true), null); - Assert.assertTrue(latch.await(2 * maxIdleTime, TimeUnit.MILLISECONDS)); + Assert.assertTrue(latch.await(2 * idleTimeout, TimeUnit.MILLISECONDS)); } @Test public void testServerEnforcingIdleTimeoutWithUnrespondedStream() throws Exception { connector = newSPDYServerConnector(null); - int maxIdleTime = 1000; - connector.setMaxIdleTime(maxIdleTime); + connector.setIdleTimeout(idleTimeout); final CountDownLatch latch = new CountDownLatch(1); Session session = startClient(startServer(null), new SessionFrameListener.Adapter() @@ -83,13 +84,12 @@ public class IdleTimeoutTest extends AbstractTest // The SYN is not replied, and the server should idle timeout session.syn(new SynInfo(true), null); - Assert.assertTrue(latch.await(2 * maxIdleTime, TimeUnit.MILLISECONDS)); + Assert.assertTrue(latch.await(2 * idleTimeout, TimeUnit.MILLISECONDS)); } @Test public void testServerNotEnforcingIdleTimeoutWithPendingStream() throws Exception { - final int maxIdleTime = 1000; connector = newSPDYServerConnector(new ServerSessionFrameListener.Adapter() { @Override @@ -97,7 +97,7 @@ public class IdleTimeoutTest extends AbstractTest { try { - Thread.sleep(2 * maxIdleTime); + Thread.sleep(2 * idleTimeout); stream.reply(new ReplyInfo(true)); return null; } @@ -108,7 +108,7 @@ public class IdleTimeoutTest extends AbstractTest } } }); - connector.setMaxIdleTime(maxIdleTime); + connector.setIdleTimeout(idleTimeout); final CountDownLatch latch = new CountDownLatch(1); Session session = startClient(startServer(null), new SessionFrameListener.Adapter() @@ -130,7 +130,7 @@ public class IdleTimeoutTest extends AbstractTest } }); - Assert.assertTrue(replyLatch.await(3 * maxIdleTime, TimeUnit.MILLISECONDS)); + Assert.assertTrue(replyLatch.await(3 * idleTimeout, TimeUnit.MILLISECONDS)); Assert.assertFalse(latch.await(1000, TimeUnit.MILLISECONDS)); } @@ -159,13 +159,12 @@ public class IdleTimeoutTest extends AbstractTest clientFactory = newSPDYClientFactory(threadPool); clientFactory.start(); SPDYClient client = clientFactory.newSPDYClient(SPDY.V2); - long maxIdleTime = 1000; - client.setMaxIdleTime(maxIdleTime); + client.setIdleTimeout(idleTimeout); Session session = client.connect(address, null).get(5, TimeUnit.SECONDS); session.syn(new SynInfo(true), null); - Assert.assertTrue(latch.await(2 * maxIdleTime, TimeUnit.MILLISECONDS)); + Assert.assertTrue(latch.await(2 * idleTimeout, TimeUnit.MILLISECONDS)); } @Test @@ -186,19 +185,17 @@ public class IdleTimeoutTest extends AbstractTest clientFactory = newSPDYClientFactory(threadPool); clientFactory.start(); SPDYClient client = clientFactory.newSPDYClient(SPDY.V2); - long maxIdleTime = 1000; - client.setMaxIdleTime(maxIdleTime); + client.setIdleTimeout(idleTimeout); Session session = client.connect(address, null).get(5, TimeUnit.SECONDS); session.syn(new SynInfo(true), null); - Assert.assertTrue(latch.await(2 * maxIdleTime, TimeUnit.MILLISECONDS)); + Assert.assertTrue(latch.await(2 * idleTimeout, TimeUnit.MILLISECONDS)); } @Test public void testClientNotEnforcingIdleTimeoutWithPendingStream() throws Exception { - final long maxIdleTime = 1000; final CountDownLatch latch = new CountDownLatch(1); InetSocketAddress address = startServer(new ServerSessionFrameListener.Adapter() { @@ -221,7 +218,7 @@ public class IdleTimeoutTest extends AbstractTest clientFactory = newSPDYClientFactory(threadPool); clientFactory.start(); SPDYClient client = clientFactory.newSPDYClient(SPDY.V2); - client.setMaxIdleTime(maxIdleTime); + client.setIdleTimeout(idleTimeout); Session session = client.connect(address, null).get(5, TimeUnit.SECONDS); final CountDownLatch replyLatch = new CountDownLatch(1); @@ -232,7 +229,7 @@ public class IdleTimeoutTest extends AbstractTest { try { - Thread.sleep(2 * maxIdleTime); + Thread.sleep(2 * idleTimeout); replyLatch.countDown(); } catch (InterruptedException e) @@ -242,7 +239,7 @@ public class IdleTimeoutTest extends AbstractTest } }); - Assert.assertFalse(latch.await(2 * maxIdleTime, TimeUnit.MILLISECONDS)); - Assert.assertTrue(replyLatch.await(3 * maxIdleTime, TimeUnit.MILLISECONDS)); + Assert.assertFalse(latch.await(2 * idleTimeout, TimeUnit.MILLISECONDS)); + Assert.assertTrue(replyLatch.await(3 * idleTimeout, TimeUnit.MILLISECONDS)); } } diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PingTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PingTest.java index 9229e7e883..dc4dd2a2c4 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PingTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PingTest.java @@ -18,11 +18,11 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jetty.spdy.api.Handler; import org.eclipse.jetty.spdy.api.PingInfo; import org.eclipse.jetty.spdy.api.Session; import org.eclipse.jetty.spdy.api.SessionFrameListener; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; +import org.eclipse.jetty.util.Callback; import org.junit.Assert; import org.junit.Test; @@ -63,7 +63,7 @@ public class PingTest extends AbstractTest @Override public void onConnect(Session session) { - session.ping(0, TimeUnit.MILLISECONDS, new Handler.Adapter() + session.ping(0, TimeUnit.MILLISECONDS, new Callback.Empty() { @Override public void completed(PingInfo pingInfo) diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ProtocolViolationsTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ProtocolViolationsTest.java index b0c19f7fe5..9499c164e4 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ProtocolViolationsTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ProtocolViolationsTest.java @@ -13,9 +13,6 @@ package org.eclipse.jetty.spdy; -import static org.junit.Assert.*; -import static org.hamcrest.Matchers.*; - import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.nio.channels.ServerSocketChannel; @@ -23,6 +20,7 @@ import java.nio.channels.SocketChannel; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.api.BytesDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.api.Headers; @@ -43,6 +41,9 @@ import org.eclipse.jetty.spdy.generator.Generator; import org.junit.Assert; import org.junit.Test; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + public class ProtocolViolationsTest extends AbstractTest { @Test diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PushStreamTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PushStreamTest.java index cd21fe5fc5..0fbc9cdd30 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PushStreamTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/PushStreamTest.java @@ -28,10 +28,10 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.api.BytesDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; import org.eclipse.jetty.spdy.api.GoAwayInfo; -import org.eclipse.jetty.spdy.api.Handler; import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.ReplyInfo; import org.eclipse.jetty.spdy.api.RstInfo; @@ -54,6 +54,7 @@ import org.eclipse.jetty.spdy.frames.WindowUpdateFrame; import org.eclipse.jetty.spdy.generator.Generator; import org.eclipse.jetty.spdy.parser.Parser; import org.eclipse.jetty.spdy.parser.Parser.Listener; +import org.eclipse.jetty.util.Callback; import org.junit.Assert; import org.junit.Test; @@ -237,7 +238,7 @@ public class PushStreamTest extends AbstractTest public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { stream.reply(new ReplyInfo(true)); - stream.syn(new SynInfo(false),1,TimeUnit.SECONDS,new Handler.Adapter() + stream.syn(new SynInfo(false),1,TimeUnit.SECONDS,new Callback.Empty() { @Override public void failed(Stream stream, Throwable x) diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ResetStreamTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ResetStreamTest.java index 3430ff441c..28773746fc 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ResetStreamTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/ResetStreamTest.java @@ -18,7 +18,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.jetty.spdy.api.DataInfo; -import org.eclipse.jetty.spdy.api.Handler; import org.eclipse.jetty.spdy.api.RstInfo; import org.eclipse.jetty.spdy.api.Session; import org.eclipse.jetty.spdy.api.SessionFrameListener; @@ -28,6 +27,7 @@ import org.eclipse.jetty.spdy.api.StreamStatus; import org.eclipse.jetty.spdy.api.StringDataInfo; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; +import org.eclipse.jetty.util.Callback; import org.junit.Test; import static org.hamcrest.Matchers.is; @@ -129,7 +129,7 @@ public class ResetStreamTest extends AbstractTest }); Stream stream = session.syn(new SynInfo(false),null).get(5,TimeUnit.SECONDS); - stream.data(new StringDataInfo("data",true),5,TimeUnit.SECONDS,new Handler.Adapter() + stream.data(new StringDataInfo("data",true),5,TimeUnit.SECONDS,new Callback.Empty() { @Override public void completed(Void context) @@ -179,7 +179,7 @@ public class ResetStreamTest extends AbstractTest assertThat("syn is received by server", synLatch.await(5,TimeUnit.SECONDS),is(true)); stream.data(new StringDataInfo("data",false),5,TimeUnit.SECONDS,null); assertThat("stream is reset",rstLatch.await(5,TimeUnit.SECONDS),is(true)); - stream.data(new StringDataInfo("2nd dataframe",false),5L,TimeUnit.SECONDS,new Handler.Adapter() + stream.data(new StringDataInfo("2nd dataframe",false),5L,TimeUnit.SECONDS,new Callback.Empty() { @Override public void failed(Void context, Throwable x) diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynDataReplyDataLoadTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynDataReplyDataLoadTest.java index fe9d070add..d094b2199b 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynDataReplyDataLoadTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynDataReplyDataLoadTest.java @@ -29,7 +29,6 @@ import java.util.concurrent.atomic.AtomicInteger; import org.eclipse.jetty.spdy.api.ByteBufferDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; -import org.eclipse.jetty.spdy.api.Handler; import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.ReplyInfo; import org.eclipse.jetty.spdy.api.Session; @@ -38,6 +37,7 @@ import org.eclipse.jetty.spdy.api.StreamFrameListener; import org.eclipse.jetty.spdy.api.StringDataInfo; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; +import org.eclipse.jetty.util.Callback; import org.junit.Assert; import org.junit.Test; @@ -167,7 +167,7 @@ public class SynDataReplyDataLoadTest extends AbstractTest latch.countDown(); } } - }, 0, TimeUnit.SECONDS, new Handler.Adapter() + }, 0, TimeUnit.SECONDS, new Callback.Empty() { @Override public void completed(Stream stream) diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynReplyTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynReplyTest.java index 7d5db72cb0..d6cd49f92e 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynReplyTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/SynReplyTest.java @@ -24,7 +24,6 @@ import java.util.concurrent.atomic.AtomicReference; import org.eclipse.jetty.spdy.api.BytesDataInfo; import org.eclipse.jetty.spdy.api.DataInfo; -import org.eclipse.jetty.spdy.api.Handler; import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.ReplyInfo; import org.eclipse.jetty.spdy.api.Session; @@ -34,6 +33,7 @@ import org.eclipse.jetty.spdy.api.StreamFrameListener; import org.eclipse.jetty.spdy.api.StringDataInfo; import org.eclipse.jetty.spdy.api.SynInfo; import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener; +import org.eclipse.jetty.util.Callback; import org.junit.Assert; import org.junit.Test; @@ -194,7 +194,7 @@ public class SynReplyTest extends AbstractTest Assert.assertTrue(stream.isHalfClosed()); stream.reply(new ReplyInfo(false)); - stream.data(new StringDataInfo(data1, false), 5, TimeUnit.SECONDS, new Handler.Adapter() + stream.data(new StringDataInfo(data1, false), 5, TimeUnit.SECONDS, new Callback.Empty() { @Override public void completed(Void context) @@ -273,7 +273,7 @@ public class SynReplyTest extends AbstractTest Assert.assertEquals(clientData, data); clientDataLatch.countDown(); } - }, 0, TimeUnit.MILLISECONDS, new Handler.Adapter() + }, 0, TimeUnit.MILLISECONDS, new Callback.Empty() { @Override public void completed(Stream stream) diff --git a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/UnsupportedVersionTest.java b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/UnsupportedVersionTest.java index 0f996bb9e6..755e3ba884 100644 --- a/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/UnsupportedVersionTest.java +++ b/jetty-spdy/spdy-jetty/src/test/java/org/eclipse/jetty/spdy/UnsupportedVersionTest.java @@ -19,6 +19,7 @@ import java.nio.channels.SocketChannel; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.spdy.api.Headers; import org.eclipse.jetty.spdy.api.SPDY; import org.eclipse.jetty.spdy.api.Stream; diff --git a/jetty-spdy/spdy-jetty/src/test/resources/log4j.properties b/jetty-spdy/spdy-jetty/src/test/resources/log4j.properties index aa88d6427e..c7c11c1d80 100644 --- a/jetty-spdy/spdy-jetty/src/test/resources/log4j.properties +++ b/jetty-spdy/spdy-jetty/src/test/resources/log4j.properties @@ -11,4 +11,6 @@ log4j.appender.CONSOLE.target=System.err # Level tuning log4j.logger.org.eclipse.jetty=INFO -#log4j.logger.org.eclipse.jetty.spdy=DEBUG +#log4j.logger.org.eclipse.jetty.io=DEBUG +log4j.logger.org.eclipse.jetty.spdy=DEBUG +# thomas diff --git a/pom.xml b/pom.xml index 4755226c87..e951ee6e7d 100644 --- a/pom.xml +++ b/pom.xml @@ -374,8 +374,8 @@ -