Fix parameter namings + some more
This commit is contained in:
parent
6f2840193a
commit
36c8eb02e8
@ -999,8 +999,8 @@ public class HttpHeaders {
|
||||
return hash % BUCKET_SIZE;
|
||||
}
|
||||
|
||||
private final Entry[] entries = new Entry[BUCKET_SIZE];
|
||||
private final Entry head = new Entry(-1, null, null);
|
||||
private final HeaderEntry[] entries = new HeaderEntry[BUCKET_SIZE];
|
||||
private final HeaderEntry head = new HeaderEntry(-1, null, null);
|
||||
|
||||
HttpHeaders() {
|
||||
head.before = head.after = head;
|
||||
@ -1021,9 +1021,9 @@ public class HttpHeaders {
|
||||
|
||||
private void addHeader0(int h, int i, final String name, final String value) {
|
||||
// Update the hash table.
|
||||
Entry e = entries[i];
|
||||
Entry newEntry;
|
||||
entries[i] = newEntry = new Entry(h, name, value);
|
||||
HeaderEntry e = entries[i];
|
||||
HeaderEntry newEntry;
|
||||
entries[i] = newEntry = new HeaderEntry(h, name, value);
|
||||
newEntry.next = e;
|
||||
|
||||
// Update the linked list.
|
||||
@ -1040,7 +1040,7 @@ public class HttpHeaders {
|
||||
}
|
||||
|
||||
private void removeHeader0(int h, int i, String name) {
|
||||
Entry e = entries[i];
|
||||
HeaderEntry e = entries[i];
|
||||
if (e == null) {
|
||||
return;
|
||||
}
|
||||
@ -1048,7 +1048,7 @@ public class HttpHeaders {
|
||||
for (;;) {
|
||||
if (e.hash == h && eq(name, e.key)) {
|
||||
e.remove();
|
||||
Entry next = e.next;
|
||||
HeaderEntry next = e.next;
|
||||
if (next != null) {
|
||||
entries[i] = next;
|
||||
e = next;
|
||||
@ -1062,7 +1062,7 @@ public class HttpHeaders {
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
Entry next = e.next;
|
||||
HeaderEntry next = e.next;
|
||||
if (next == null) {
|
||||
break;
|
||||
}
|
||||
@ -1120,7 +1120,7 @@ public class HttpHeaders {
|
||||
|
||||
int h = hash(name);
|
||||
int i = index(h);
|
||||
Entry e = entries[i];
|
||||
HeaderEntry e = entries[i];
|
||||
while (e != null) {
|
||||
if (e.hash == h && eq(name, e.key)) {
|
||||
return e.value;
|
||||
@ -1140,7 +1140,7 @@ public class HttpHeaders {
|
||||
|
||||
int h = hash(name);
|
||||
int i = index(h);
|
||||
Entry e = entries[i];
|
||||
HeaderEntry e = entries[i];
|
||||
while (e != null) {
|
||||
if (e.hash == h && eq(name, e.key)) {
|
||||
values.addFirst(e.value);
|
||||
@ -1154,7 +1154,7 @@ public class HttpHeaders {
|
||||
List<Map.Entry<String, String>> all =
|
||||
new LinkedList<Map.Entry<String, String>>();
|
||||
|
||||
Entry e = head.after;
|
||||
HeaderEntry e = head.after;
|
||||
while (e != head) {
|
||||
all.add(e);
|
||||
e = e.after;
|
||||
@ -1170,7 +1170,7 @@ public class HttpHeaders {
|
||||
|
||||
Set<String> names = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
Entry e = head.after;
|
||||
HeaderEntry e = head.after;
|
||||
while (e != head) {
|
||||
names.add(e.key);
|
||||
e = e.after;
|
||||
@ -1197,14 +1197,14 @@ public class HttpHeaders {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
private static final class Entry implements Map.Entry<String, String> {
|
||||
private static final class HeaderEntry implements Map.Entry<String, String> {
|
||||
final int hash;
|
||||
final String key;
|
||||
String value;
|
||||
Entry next;
|
||||
Entry before, after;
|
||||
HeaderEntry next;
|
||||
HeaderEntry before, after;
|
||||
|
||||
Entry(int hash, String key, String value) {
|
||||
HeaderEntry(int hash, String key, String value) {
|
||||
this.hash = hash;
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
@ -1215,7 +1215,7 @@ public class HttpHeaders {
|
||||
after.before = before;
|
||||
}
|
||||
|
||||
void addBefore(Entry e) {
|
||||
void addBefore(HeaderEntry e) {
|
||||
after = e;
|
||||
before = e.before;
|
||||
before.after = this;
|
||||
|
@ -93,12 +93,12 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(InterfaceHttpData arg0) {
|
||||
if (!(arg0 instanceof Attribute)) {
|
||||
public int compareTo(InterfaceHttpData o) {
|
||||
if (!(o instanceof Attribute)) {
|
||||
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
||||
" with " + arg0.getHttpDataType());
|
||||
" with " + o.getHttpDataType());
|
||||
}
|
||||
return compareTo((Attribute) arg0);
|
||||
return compareTo((Attribute) o);
|
||||
}
|
||||
|
||||
public int compareTo(Attribute o) {
|
||||
|
@ -79,12 +79,12 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(InterfaceHttpData arg0) {
|
||||
if (!(arg0 instanceof FileUpload)) {
|
||||
public int compareTo(InterfaceHttpData o) {
|
||||
if (!(o instanceof FileUpload)) {
|
||||
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
||||
" with " + arg0.getHttpDataType());
|
||||
" with " + o.getHttpDataType());
|
||||
}
|
||||
return compareTo((FileUpload) arg0);
|
||||
return compareTo((FileUpload) o);
|
||||
}
|
||||
|
||||
public int compareTo(FileUpload o) {
|
||||
|
@ -2034,16 +2034,16 @@ public class HttpPostRequestDecoder {
|
||||
public ErrorDataDecoderException() {
|
||||
}
|
||||
|
||||
public ErrorDataDecoderException(String arg0) {
|
||||
super(arg0);
|
||||
public ErrorDataDecoderException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public ErrorDataDecoderException(Throwable arg0) {
|
||||
super(arg0);
|
||||
public ErrorDataDecoderException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public ErrorDataDecoderException(String arg0, Throwable arg1) {
|
||||
super(arg0, arg1);
|
||||
public ErrorDataDecoderException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,12 +70,12 @@ public class InternalAttribute implements InterfaceHttpData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(InterfaceHttpData arg0) {
|
||||
if (!(arg0 instanceof InternalAttribute)) {
|
||||
public int compareTo(InterfaceHttpData o) {
|
||||
if (!(o instanceof InternalAttribute)) {
|
||||
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
||||
" with " + arg0.getHttpDataType());
|
||||
" with " + o.getHttpDataType());
|
||||
}
|
||||
return compareTo((InternalAttribute) arg0);
|
||||
return compareTo((InternalAttribute) o);
|
||||
}
|
||||
|
||||
public int compareTo(InternalAttribute o) {
|
||||
|
@ -15,10 +15,10 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Default FileUpload implementation that stores file into memory.<br><br>
|
||||
*
|
||||
@ -73,12 +73,12 @@ public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUplo
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(InterfaceHttpData arg0) {
|
||||
if (!(arg0 instanceof FileUpload)) {
|
||||
public int compareTo(InterfaceHttpData o) {
|
||||
if (!(o instanceof FileUpload)) {
|
||||
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
||||
" with " + arg0.getHttpDataType());
|
||||
" with " + o.getHttpDataType());
|
||||
}
|
||||
return compareTo((FileUpload) arg0);
|
||||
return compareTo((FileUpload) o);
|
||||
}
|
||||
|
||||
public int compareTo(FileUpload o) {
|
||||
|
@ -35,14 +35,14 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSet(int ID) {
|
||||
Integer key = new Integer(ID);
|
||||
public boolean isSet(int id) {
|
||||
Integer key = Integer.valueOf(id);
|
||||
return settingsMap.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValue(int ID) {
|
||||
Integer key = new Integer(ID);
|
||||
public int getValue(int id) {
|
||||
Integer key = Integer.valueOf(id);
|
||||
if (settingsMap.containsKey(key)) {
|
||||
return settingsMap.get(key).getValue();
|
||||
} else {
|
||||
@ -51,16 +51,16 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(int ID, int value) {
|
||||
setValue(ID, value, false, false);
|
||||
public void setValue(int id, int value) {
|
||||
setValue(id, value, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(int ID, int value, boolean persistValue, boolean persisted) {
|
||||
if (ID <= 0 || ID > SpdyCodecUtil.SPDY_SETTINGS_MAX_ID) {
|
||||
throw new IllegalArgumentException("Setting ID is not valid: " + ID);
|
||||
public void setValue(int id, int value, boolean persistValue, boolean persisted) {
|
||||
if (id <= 0 || id > SpdyCodecUtil.SPDY_SETTINGS_MAX_ID) {
|
||||
throw new IllegalArgumentException("Setting ID is not valid: " + id);
|
||||
}
|
||||
Integer key = new Integer(ID);
|
||||
Integer key = Integer.valueOf(id);
|
||||
if (settingsMap.containsKey(key)) {
|
||||
Setting setting = settingsMap.get(key);
|
||||
setting.setValue(value);
|
||||
@ -72,16 +72,16 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeValue(int ID) {
|
||||
Integer key = new Integer(ID);
|
||||
public void removeValue(int id) {
|
||||
Integer key = Integer.valueOf(id);
|
||||
if (settingsMap.containsKey(key)) {
|
||||
settingsMap.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPersistValue(int ID) {
|
||||
Integer key = new Integer(ID);
|
||||
public boolean isPersistValue(int id) {
|
||||
Integer key = Integer.valueOf(id);
|
||||
if (settingsMap.containsKey(key)) {
|
||||
return settingsMap.get(key).isPersist();
|
||||
} else {
|
||||
@ -90,16 +90,16 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPersistValue(int ID, boolean persistValue) {
|
||||
Integer key = new Integer(ID);
|
||||
public void setPersistValue(int id, boolean persistValue) {
|
||||
Integer key = Integer.valueOf(id);
|
||||
if (settingsMap.containsKey(key)) {
|
||||
settingsMap.get(key).setPersist(persistValue);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPersisted(int ID) {
|
||||
Integer key = new Integer(ID);
|
||||
public boolean isPersisted(int id) {
|
||||
Integer key = Integer.valueOf(id);
|
||||
if (settingsMap.containsKey(key)) {
|
||||
return settingsMap.get(key).isPersisted();
|
||||
} else {
|
||||
@ -108,8 +108,8 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPersisted(int ID, boolean persisted) {
|
||||
Integer key = new Integer(ID);
|
||||
public void setPersisted(int id, boolean persisted) {
|
||||
Integer key = Integer.valueOf(id);
|
||||
if (settingsMap.containsKey(key)) {
|
||||
settingsMap.get(key).setPersisted(persisted);
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ final class SpdyCodecUtil {
|
||||
try {
|
||||
SPDY2_DICT_ = SPDY2_DICT_S.getBytes(CharsetUtil.US_ASCII);
|
||||
// dictionary is null terminated
|
||||
SPDY2_DICT_[SPDY2_DICT_.length - 1] = (byte) 0;
|
||||
SPDY2_DICT_[SPDY2_DICT_.length - 1] = 0;
|
||||
} catch (Exception e) {
|
||||
SPDY2_DICT_ = new byte[1];
|
||||
}
|
||||
@ -307,9 +307,9 @@ final class SpdyCodecUtil {
|
||||
/**
|
||||
* Returns {@code true} if ID is for a server initiated stream or ping.
|
||||
*/
|
||||
static boolean isServerId(int ID) {
|
||||
static boolean isServerId(int id) {
|
||||
// Server initiated streams and pings have even IDs
|
||||
return ID % 2 == 0;
|
||||
return id % 2 == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -527,8 +527,8 @@ public class SpdyHeaders {
|
||||
return hash % BUCKET_SIZE;
|
||||
}
|
||||
|
||||
private final Entry[] entries = new Entry[BUCKET_SIZE];
|
||||
private final Entry head = new Entry(-1, null, null);
|
||||
private final HeaderEntry[] entries = new HeaderEntry[BUCKET_SIZE];
|
||||
private final HeaderEntry head = new HeaderEntry(-1, null, null);
|
||||
|
||||
SpdyHeaders() {
|
||||
head.before = head.after = head;
|
||||
@ -546,9 +546,9 @@ public class SpdyHeaders {
|
||||
|
||||
private void addHeader0(int h, int i, final String name, final String value) {
|
||||
// Update the hash table.
|
||||
Entry e = entries[i];
|
||||
Entry newEntry;
|
||||
entries[i] = newEntry = new Entry(h, name, value);
|
||||
HeaderEntry e = entries[i];
|
||||
HeaderEntry newEntry;
|
||||
entries[i] = newEntry = new HeaderEntry(h, name, value);
|
||||
newEntry.next = e;
|
||||
|
||||
// Update the linked list.
|
||||
@ -566,7 +566,7 @@ public class SpdyHeaders {
|
||||
}
|
||||
|
||||
private void removeHeader0(int h, int i, String name) {
|
||||
Entry e = entries[i];
|
||||
HeaderEntry e = entries[i];
|
||||
if (e == null) {
|
||||
return;
|
||||
}
|
||||
@ -574,7 +574,7 @@ public class SpdyHeaders {
|
||||
for (;;) {
|
||||
if (e.hash == h && eq(name, e.key)) {
|
||||
e.remove();
|
||||
Entry next = e.next;
|
||||
HeaderEntry next = e.next;
|
||||
if (next != null) {
|
||||
entries[i] = next;
|
||||
e = next;
|
||||
@ -588,7 +588,7 @@ public class SpdyHeaders {
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
Entry next = e.next;
|
||||
HeaderEntry next = e.next;
|
||||
if (next == null) {
|
||||
break;
|
||||
}
|
||||
@ -648,7 +648,7 @@ public class SpdyHeaders {
|
||||
|
||||
int h = hash(name);
|
||||
int i = index(h);
|
||||
Entry e = entries[i];
|
||||
HeaderEntry e = entries[i];
|
||||
while (e != null) {
|
||||
if (e.hash == h && eq(name, e.key)) {
|
||||
return e.value;
|
||||
@ -668,7 +668,7 @@ public class SpdyHeaders {
|
||||
|
||||
int h = hash(name);
|
||||
int i = index(h);
|
||||
Entry e = entries[i];
|
||||
HeaderEntry e = entries[i];
|
||||
while (e != null) {
|
||||
if (e.hash == h && eq(name, e.key)) {
|
||||
values.addFirst(e.value);
|
||||
@ -682,7 +682,7 @@ public class SpdyHeaders {
|
||||
List<Map.Entry<String, String>> all =
|
||||
new LinkedList<Map.Entry<String, String>>();
|
||||
|
||||
Entry e = head.after;
|
||||
HeaderEntry e = head.after;
|
||||
while (e != head) {
|
||||
all.add(e);
|
||||
e = e.after;
|
||||
@ -697,7 +697,7 @@ public class SpdyHeaders {
|
||||
Set<String> getHeaderNames() {
|
||||
Set<String> names = new TreeSet<String>();
|
||||
|
||||
Entry e = head.after;
|
||||
HeaderEntry e = head.after;
|
||||
while (e != head) {
|
||||
names.add(e.key);
|
||||
e = e.after;
|
||||
@ -712,14 +712,14 @@ public class SpdyHeaders {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
private static final class Entry implements Map.Entry<String, String> {
|
||||
private static final class HeaderEntry implements Map.Entry<String, String> {
|
||||
final int hash;
|
||||
final String key;
|
||||
String value;
|
||||
Entry next;
|
||||
Entry before, after;
|
||||
HeaderEntry next;
|
||||
HeaderEntry before, after;
|
||||
|
||||
Entry(int hash, String key, String value) {
|
||||
HeaderEntry(int hash, String key, String value) {
|
||||
this.hash = hash;
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
@ -730,7 +730,7 @@ public class SpdyHeaders {
|
||||
after.before = before;
|
||||
}
|
||||
|
||||
void addBefore(Entry e) {
|
||||
void addBefore(HeaderEntry e) {
|
||||
after = e;
|
||||
before = e.before;
|
||||
before.after = this;
|
||||
|
@ -38,6 +38,7 @@ public class SpdySessionHandler
|
||||
private static final SpdyProtocolException STREAM_CLOSED = new SpdyProtocolException("Stream closed");
|
||||
|
||||
static {
|
||||
@SuppressWarnings("ZeroLengthArrayAllocation")
|
||||
StackTraceElement[] emptyTrace = new StackTraceElement[0];
|
||||
PROTOCOL_EXCEPTION.setStackTrace(emptyTrace);
|
||||
STREAM_CLOSED.setStackTrace(emptyTrace);
|
||||
@ -695,8 +696,8 @@ public class SpdySessionHandler
|
||||
* Helper functions
|
||||
*/
|
||||
|
||||
private boolean isRemoteInitiatedID(int ID) {
|
||||
boolean serverID = SpdyCodecUtil.isServerId(ID);
|
||||
private boolean isRemoteInitiatedID(int id) {
|
||||
boolean serverID = SpdyCodecUtil.isServerId(id);
|
||||
return server && !serverID || !server && serverID;
|
||||
}
|
||||
|
||||
|
@ -20,14 +20,12 @@ import io.netty.channel.ChannelInboundMessageHandlerAdapter;
|
||||
import io.netty.channel.embedded.EmbeddedMessageChannel;
|
||||
import io.netty.logging.InternalLogger;
|
||||
import io.netty.logging.InternalLoggerFactory;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SpdySessionHandlerTest {
|
||||
|
||||
@ -45,25 +43,25 @@ public class SpdySessionHandlerTest {
|
||||
for (String name: expected.getHeaderNames()) {
|
||||
List<String> expectedValues = expected.getHeaders(name);
|
||||
List<String> receivedValues = received.getHeaders(name);
|
||||
Assert.assertTrue(receivedValues.containsAll(expectedValues));
|
||||
assertTrue(receivedValues.containsAll(expectedValues));
|
||||
receivedValues.removeAll(expectedValues);
|
||||
Assert.assertTrue(receivedValues.isEmpty());
|
||||
assertTrue(receivedValues.isEmpty());
|
||||
received.removeHeader(name);
|
||||
}
|
||||
Assert.assertTrue(received.getHeaders().isEmpty());
|
||||
assertTrue(received.getHeaders().isEmpty());
|
||||
}
|
||||
|
||||
private static void assertDataFrame(Object msg, int streamID, boolean last) {
|
||||
Assert.assertNotNull(msg);
|
||||
Assert.assertTrue(msg instanceof SpdyDataFrame);
|
||||
assertNotNull(msg);
|
||||
assertTrue(msg instanceof SpdyDataFrame);
|
||||
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
|
||||
assertEquals(spdyDataFrame.getStreamId(), streamID);
|
||||
assertEquals(spdyDataFrame.isLast(), last);
|
||||
}
|
||||
|
||||
private static void assertSynReply(Object msg, int streamID, boolean last, SpdyHeaderBlock headers) {
|
||||
Assert.assertNotNull(msg);
|
||||
Assert.assertTrue(msg instanceof SpdySynReplyFrame);
|
||||
assertNotNull(msg);
|
||||
assertTrue(msg instanceof SpdySynReplyFrame);
|
||||
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
|
||||
assertEquals(spdySynReplyFrame.getStreamId(), streamID);
|
||||
assertEquals(spdySynReplyFrame.isLast(), last);
|
||||
@ -71,36 +69,36 @@ public class SpdySessionHandlerTest {
|
||||
}
|
||||
|
||||
private static void assertRstStream(Object msg, int streamID, SpdyStreamStatus status) {
|
||||
Assert.assertNotNull(msg);
|
||||
Assert.assertTrue(msg instanceof SpdyRstStreamFrame);
|
||||
assertNotNull(msg);
|
||||
assertTrue(msg instanceof SpdyRstStreamFrame);
|
||||
SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg;
|
||||
assertEquals(spdyRstStreamFrame.getStreamId(), streamID);
|
||||
assertEquals(spdyRstStreamFrame.getStatus(), status);
|
||||
}
|
||||
|
||||
private static void assertPing(Object msg, int ID) {
|
||||
Assert.assertNotNull(msg);
|
||||
Assert.assertTrue(msg instanceof SpdyPingFrame);
|
||||
private static void assertPing(Object msg, int id) {
|
||||
assertNotNull(msg);
|
||||
assertTrue(msg instanceof SpdyPingFrame);
|
||||
SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg;
|
||||
assertEquals(spdyPingFrame.getId(), ID);
|
||||
assertEquals(spdyPingFrame.getId(), id);
|
||||
}
|
||||
|
||||
private static void assertGoAway(Object msg, int lastGoodStreamID) {
|
||||
Assert.assertNotNull(msg);
|
||||
Assert.assertTrue(msg instanceof SpdyGoAwayFrame);
|
||||
assertNotNull(msg);
|
||||
assertTrue(msg instanceof SpdyGoAwayFrame);
|
||||
SpdyGoAwayFrame spdyGoAwayFrame = (SpdyGoAwayFrame) msg;
|
||||
assertEquals(spdyGoAwayFrame.getLastGoodStreamId(), lastGoodStreamID);
|
||||
}
|
||||
|
||||
private static void assertHeaders(Object msg, int streamID, SpdyHeaderBlock headers) {
|
||||
Assert.assertNotNull(msg);
|
||||
Assert.assertTrue(msg instanceof SpdyHeadersFrame);
|
||||
assertNotNull(msg);
|
||||
assertTrue(msg instanceof SpdyHeadersFrame);
|
||||
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
|
||||
assertEquals(spdyHeadersFrame.getStreamId(), streamID);
|
||||
assertHeaderBlock(spdyHeadersFrame, headers);
|
||||
}
|
||||
|
||||
private void testSpdySessionHandler(int version, boolean server) {
|
||||
private static void testSpdySessionHandler(int version, boolean server) {
|
||||
EmbeddedMessageChannel sessionHandler = new EmbeddedMessageChannel(
|
||||
new SpdySessionHandler(version, server), new EchoHandler(closeSignal, server));
|
||||
|
||||
@ -125,34 +123,34 @@ public class SpdySessionHandlerTest {
|
||||
// a data frame for a Stream-ID that is not open
|
||||
sessionHandler.writeInbound(new DefaultSpdyDataFrame(localStreamID));
|
||||
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.INVALID_STREAM);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
|
||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||
// a data frame for a Stream-ID before receiving a SYN_REPLY frame
|
||||
sessionHandler.writeInbound(new DefaultSpdyDataFrame(remoteStreamID));
|
||||
assertRstStream(sessionHandler.readOutbound(), remoteStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
remoteStreamID += 2;
|
||||
|
||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||
// multiple SYN_REPLY frames for the same active Stream-ID
|
||||
sessionHandler.writeInbound(new DefaultSpdySynReplyFrame(remoteStreamID));
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
sessionHandler.writeInbound(new DefaultSpdySynReplyFrame(remoteStreamID));
|
||||
assertRstStream(sessionHandler.readOutbound(), remoteStreamID, SpdyStreamStatus.STREAM_IN_USE);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
remoteStreamID += 2;
|
||||
|
||||
// Check if frame codec correctly compresses/uncompresses headers
|
||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||
assertSynReply(sessionHandler.readOutbound(), localStreamID, false, spdySynStreamFrame);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
SpdyHeadersFrame spdyHeadersFrame = new DefaultSpdyHeadersFrame(localStreamID);
|
||||
spdyHeadersFrame.addHeader("HEADER","test1");
|
||||
spdyHeadersFrame.addHeader("HEADER","test2");
|
||||
sessionHandler.writeInbound(spdyHeadersFrame);
|
||||
assertHeaders(sessionHandler.readOutbound(), localStreamID, spdyHeadersFrame);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
localStreamID += 2;
|
||||
|
||||
// Check if session handler closed the streams using the number
|
||||
@ -163,25 +161,25 @@ public class SpdySessionHandlerTest {
|
||||
spdySynStreamFrame.setUnidirectional(true);
|
||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
|
||||
// Check if session handler drops active streams if it receives
|
||||
// a RST_STREAM frame for that Stream-ID
|
||||
sessionHandler.writeInbound(new DefaultSpdyRstStreamFrame(remoteStreamID, 3));
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
remoteStreamID += 2;
|
||||
|
||||
// Check if session handler honors UNIDIRECTIONAL streams
|
||||
spdySynStreamFrame.setLast(false);
|
||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
spdySynStreamFrame.setUnidirectional(false);
|
||||
|
||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||
// multiple SYN_STREAM frames for the same active Stream-ID
|
||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
localStreamID += 2;
|
||||
|
||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||
@ -189,7 +187,7 @@ public class SpdySessionHandlerTest {
|
||||
spdySynStreamFrame.setStreamId(localStreamID - 1);
|
||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||
assertRstStream(sessionHandler.readOutbound(), localStreamID - 1, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
spdySynStreamFrame.setStreamId(localStreamID);
|
||||
|
||||
// Check if session handler correctly limits the number of
|
||||
@ -197,26 +195,26 @@ public class SpdySessionHandlerTest {
|
||||
SpdySettingsFrame spdySettingsFrame = new DefaultSpdySettingsFrame();
|
||||
spdySettingsFrame.setValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS, 2);
|
||||
sessionHandler.writeInbound(spdySettingsFrame);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
spdySettingsFrame.setValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS, 4);
|
||||
sessionHandler.writeInbound(spdySettingsFrame);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||
assertSynReply(sessionHandler.readOutbound(), localStreamID, false, spdySynStreamFrame);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
|
||||
// Check if session handler rejects HEADERS for closed streams
|
||||
int testStreamID = spdyDataFrame.getStreamId();
|
||||
sessionHandler.writeInbound(spdyDataFrame);
|
||||
assertDataFrame(sessionHandler.readOutbound(), testStreamID, spdyDataFrame.isLast());
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
spdyHeadersFrame.setStreamId(testStreamID);
|
||||
sessionHandler.writeInbound(spdyHeadersFrame);
|
||||
assertRstStream(sessionHandler.readOutbound(), testStreamID, SpdyStreamStatus.INVALID_STREAM);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
|
||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||
// an invalid HEADERS frame
|
||||
@ -224,21 +222,21 @@ public class SpdySessionHandlerTest {
|
||||
spdyHeadersFrame.setInvalid();
|
||||
sessionHandler.writeInbound(spdyHeadersFrame);
|
||||
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
|
||||
// Check if session handler returns identical local PINGs
|
||||
sessionHandler.writeInbound(localPingFrame);
|
||||
assertPing(sessionHandler.readOutbound(), localPingFrame.getId());
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
|
||||
// Check if session handler ignores un-initiated remote PINGs
|
||||
sessionHandler.writeInbound(remotePingFrame);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
|
||||
// Check if session handler sends a GOAWAY frame when closing
|
||||
sessionHandler.writeInbound(closeMessage);
|
||||
assertGoAway(sessionHandler.readOutbound(), localStreamID);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
localStreamID += 2;
|
||||
|
||||
// Check if session handler returns REFUSED_STREAM if it receives
|
||||
@ -246,13 +244,13 @@ public class SpdySessionHandlerTest {
|
||||
spdySynStreamFrame.setStreamId(localStreamID);
|
||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
|
||||
// Check if session handler ignores Data frames after sending
|
||||
// a GOAWAY frame
|
||||
spdyDataFrame.setStreamId(localStreamID);
|
||||
sessionHandler.writeInbound(spdyDataFrame);
|
||||
Assert.assertNull(sessionHandler.readOutbound());
|
||||
assertNull(sessionHandler.readOutbound());
|
||||
|
||||
sessionHandler.finish();
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ package io.netty.util.internal.jzlib;
|
||||
|
||||
import io.netty.util.internal.jzlib.JZlib.WrapperType;
|
||||
|
||||
@SuppressWarnings("MethodParameterNamingConvention")
|
||||
final class Deflate {
|
||||
|
||||
private static final class Config {
|
||||
|
@ -47,6 +47,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package io.netty.util.internal.jzlib;
|
||||
|
||||
@SuppressWarnings("MethodParameterNamingConvention")
|
||||
final class InfCodes {
|
||||
|
||||
private static final int[] inflate_mask = { 0x00000000, 0x00000001,
|
||||
|
@ -47,6 +47,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package io.netty.util.internal.jzlib;
|
||||
|
||||
@SuppressWarnings("MethodParameterNamingConvention")
|
||||
final class StaticTree {
|
||||
static final short[] static_ltree = { 12, 8, 140, 8, 76, 8, 204, 8, 44, 8,
|
||||
172, 8, 108, 8, 236, 8, 28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188,
|
||||
|
@ -47,6 +47,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package io.netty.util.internal.jzlib;
|
||||
|
||||
@SuppressWarnings("MethodParameterNamingConvention")
|
||||
final class Tree {
|
||||
// extra bits for each length code
|
||||
static final int[] extra_lbits = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2,
|
||||
|
@ -83,10 +83,10 @@ public class DiscardClientHandler extends ChannelInboundByteHandlerAdapter {
|
||||
|
||||
// Flush the outbound buffer to the socket.
|
||||
// Once flushed, generate the same amount of traffic again.
|
||||
ctx.flush().addListener(GENERATE_TRAFFIC);
|
||||
ctx.flush().addListener(trafficGenerator);
|
||||
}
|
||||
|
||||
private final ChannelFutureListener GENERATE_TRAFFIC = new ChannelFutureListener() {
|
||||
private final ChannelFutureListener trafficGenerator = new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future) throws Exception {
|
||||
if (future.isSuccess()) {
|
||||
|
@ -112,11 +112,11 @@ public class FactorialClientHandler extends ChannelInboundMessageHandlerAdapter<
|
||||
|
||||
ChannelFuture f = ctx.flush();
|
||||
if (!finished) {
|
||||
f.addListener(SEND_NUMBERS);
|
||||
f.addListener(numberSender);
|
||||
}
|
||||
}
|
||||
|
||||
private final ChannelFutureListener SEND_NUMBERS = new ChannelFutureListener() {
|
||||
private final ChannelFutureListener numberSender = new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future) throws Exception {
|
||||
if (future.isSuccess()) {
|
||||
|
@ -50,7 +50,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
public class LocalTransportThreadModelTest {
|
||||
|
||||
private static ServerBootstrap sb;
|
||||
private static LocalAddress ADDR;
|
||||
private static LocalAddress localAddr;
|
||||
|
||||
@BeforeClass
|
||||
public static void init() {
|
||||
@ -71,7 +71,7 @@ public class LocalTransportThreadModelTest {
|
||||
}
|
||||
});
|
||||
|
||||
ADDR = (LocalAddress) sb.bind().syncUninterruptibly().channel().localAddress();
|
||||
localAddr = (LocalAddress) sb.bind().syncUninterruptibly().channel().localAddress();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@ -103,7 +103,7 @@ public class LocalTransportThreadModelTest {
|
||||
// h3 will be always invoked by EventExecutor 'e2'.
|
||||
ch.pipeline().addLast(e2, h3);
|
||||
|
||||
l.register(ch).sync().channel().connect(ADDR).sync();
|
||||
l.register(ch).sync().channel().connect(localAddr).sync();
|
||||
|
||||
// Fire inbound events from all possible starting points.
|
||||
ch.pipeline().fireInboundBufferUpdated();
|
||||
@ -231,7 +231,7 @@ public class LocalTransportThreadModelTest {
|
||||
.addLast(e4, h5)
|
||||
.addLast(e5, h6);
|
||||
|
||||
l.register(ch).sync().channel().connect(ADDR).sync();
|
||||
l.register(ch).sync().channel().connect(localAddr).sync();
|
||||
|
||||
final int ROUNDS = 1024;
|
||||
final int ELEMS_PER_ROUNDS = 8192;
|
||||
|
Loading…
Reference in New Issue
Block a user