Fix parameter namings + some more
This commit is contained in:
parent
369574078b
commit
bcc088b3d7
@ -824,8 +824,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;
|
||||
@ -846,9 +846,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.
|
||||
@ -865,7 +865,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;
|
||||
}
|
||||
@ -873,7 +873,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;
|
||||
@ -887,7 +887,7 @@ public class HttpHeaders {
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
Entry next = e.next;
|
||||
HeaderEntry next = e.next;
|
||||
if (next == null) {
|
||||
break;
|
||||
}
|
||||
@ -945,7 +945,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;
|
||||
@ -965,7 +965,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);
|
||||
@ -979,7 +979,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;
|
||||
@ -995,7 +995,7 @@ public class HttpHeaders {
|
||||
Set<String> names =
|
||||
new TreeSet<String>(CaseIgnoringComparator.INSTANCE);
|
||||
|
||||
Entry e = head.after;
|
||||
HeaderEntry e = head.after;
|
||||
while (e != head) {
|
||||
names.add(e.key);
|
||||
e = e.after;
|
||||
@ -1010,14 +1010,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;
|
||||
@ -1028,7 +1028,7 @@ public class HttpHeaders {
|
||||
after.before = before;
|
||||
}
|
||||
|
||||
void addBefore(Entry e) {
|
||||
void addBefore(HeaderEntry e) {
|
||||
after = e;
|
||||
before = e.before;
|
||||
before.after = this;
|
||||
|
@ -87,12 +87,12 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
|
||||
return getName().equalsIgnoreCase(attribute.getName());
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -75,12 +75,12 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
|
||||
return getName().equalsIgnoreCase(attribute.getName());
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -68,12 +68,12 @@ public class InternalAttribute implements InterfaceHttpData {
|
||||
return getName().equalsIgnoreCase(attribute.getName());
|
||||
}
|
||||
|
||||
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 org.jboss.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.jboss.netty.handler.codec.http.HttpHeaders;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Default FileUpload implementation that stores file into memory.<br><br>
|
||||
*
|
||||
@ -69,12 +69,12 @@ public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUplo
|
||||
return getName().equalsIgnoreCase(attribute.getName());
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -37,13 +37,13 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
||||
return settingsMap.keySet();
|
||||
}
|
||||
|
||||
public boolean isSet(int ID) {
|
||||
Integer key = ID;
|
||||
public boolean isSet(int id) {
|
||||
Integer key = id;
|
||||
return settingsMap.containsKey(key);
|
||||
}
|
||||
|
||||
public int getValue(int ID) {
|
||||
Integer key = ID;
|
||||
public int getValue(int id) {
|
||||
Integer key = id;
|
||||
if (settingsMap.containsKey(key)) {
|
||||
return settingsMap.get(key).getValue();
|
||||
} else {
|
||||
@ -51,15 +51,15 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue(int ID, int value) {
|
||||
setValue(ID, value, false, false);
|
||||
public void setValue(int id, int value) {
|
||||
setValue(id, value, false, false);
|
||||
}
|
||||
|
||||
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 = ID;
|
||||
Integer key = id;
|
||||
if (settingsMap.containsKey(key)) {
|
||||
Setting setting = settingsMap.get(key);
|
||||
setting.setValue(value);
|
||||
@ -70,19 +70,19 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
||||
}
|
||||
}
|
||||
|
||||
public void removeValue(int ID) {
|
||||
Integer key = ID;
|
||||
public void removeValue(int id) {
|
||||
Integer key = id;
|
||||
if (settingsMap.containsKey(key)) {
|
||||
settingsMap.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean persistValue(int ID) {
|
||||
return isPersistValue(ID);
|
||||
public boolean persistValue(int id) {
|
||||
return isPersistValue(id);
|
||||
}
|
||||
|
||||
public boolean isPersistValue(int ID) {
|
||||
Integer key = ID;
|
||||
public boolean isPersistValue(int id) {
|
||||
Integer key = id;
|
||||
if (settingsMap.containsKey(key)) {
|
||||
return settingsMap.get(key).isPersist();
|
||||
} else {
|
||||
@ -90,15 +90,15 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
||||
}
|
||||
}
|
||||
|
||||
public void setPersistValue(int ID, boolean persistValue) {
|
||||
Integer key = ID;
|
||||
public void setPersistValue(int id, boolean persistValue) {
|
||||
Integer key = id;
|
||||
if (settingsMap.containsKey(key)) {
|
||||
settingsMap.get(key).setPersist(persistValue);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPersisted(int ID) {
|
||||
Integer key = ID;
|
||||
public boolean isPersisted(int id) {
|
||||
Integer key = id;
|
||||
if (settingsMap.containsKey(key)) {
|
||||
return settingsMap.get(key).isPersisted();
|
||||
} else {
|
||||
@ -106,8 +106,8 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
||||
}
|
||||
}
|
||||
|
||||
public void setPersisted(int ID, boolean persisted) {
|
||||
Integer key = ID;
|
||||
public void setPersisted(int id, boolean persisted) {
|
||||
Integer key = id;
|
||||
if (settingsMap.containsKey(key)) {
|
||||
settingsMap.get(key).setPersisted(persisted);
|
||||
}
|
||||
|
@ -15,16 +15,16 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.spdy;
|
||||
|
||||
import org.jboss.netty.handler.codec.http.HttpMethod;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
|
||||
import org.jboss.netty.handler.codec.http.HttpVersion;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.jboss.netty.handler.codec.http.HttpMethod;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
|
||||
import org.jboss.netty.handler.codec.http.HttpVersion;
|
||||
|
||||
/**
|
||||
* Provides the constants for the standard SPDY HTTP header names and commonly
|
||||
* used utility methods that access a {@link SpdyHeaderBlock}.
|
||||
@ -529,8 +529,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;
|
||||
@ -548,9 +548,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.
|
||||
@ -568,7 +568,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;
|
||||
}
|
||||
@ -576,7 +576,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;
|
||||
@ -590,7 +590,7 @@ public class SpdyHeaders {
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
Entry next = e.next;
|
||||
HeaderEntry next = e.next;
|
||||
if (next == null) {
|
||||
break;
|
||||
}
|
||||
@ -650,7 +650,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;
|
||||
@ -670,7 +670,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);
|
||||
@ -684,7 +684,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;
|
||||
@ -699,7 +699,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;
|
||||
@ -714,14 +714,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;
|
||||
@ -732,7 +732,7 @@ public class SpdyHeaders {
|
||||
after.before = before;
|
||||
}
|
||||
|
||||
void addBefore(Entry e) {
|
||||
void addBefore(HeaderEntry e) {
|
||||
after = e;
|
||||
before = e.before;
|
||||
before.after = this;
|
||||
|
@ -15,12 +15,6 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.spdy;
|
||||
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelDownstreamHandler;
|
||||
import org.jboss.netty.channel.ChannelEvent;
|
||||
@ -33,6 +27,12 @@ import org.jboss.netty.channel.ExceptionEvent;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
|
||||
/**
|
||||
* Manages streams within a SPDY session.
|
||||
*/
|
||||
@ -678,8 +678,8 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
|
||||
* Helper functions
|
||||
*/
|
||||
|
||||
private boolean isRemoteInitiatedID(int ID) {
|
||||
boolean serverID = isServerId(ID);
|
||||
private boolean isRemoteInitiatedID(int id) {
|
||||
boolean serverID = isServerId(id);
|
||||
return server && !serverID || !server && serverID;
|
||||
}
|
||||
|
||||
|
@ -46,19 +46,19 @@ public interface SpdySettingsFrame {
|
||||
/**
|
||||
* Returns {@code true} if the setting ID has a value.
|
||||
*/
|
||||
boolean isSet(int ID);
|
||||
boolean isSet(int id);
|
||||
|
||||
/**
|
||||
* Returns the value of the setting ID.
|
||||
* Returns -1 if the setting ID is not set.
|
||||
*/
|
||||
int getValue(int ID);
|
||||
int getValue(int id);
|
||||
|
||||
/**
|
||||
* Sets the value of the setting ID.
|
||||
* The ID must be positive and cannot exceed 16777215.
|
||||
*/
|
||||
void setValue(int ID, int value);
|
||||
void setValue(int id, int value);
|
||||
|
||||
/**
|
||||
* Sets the value of the setting ID.
|
||||
@ -66,45 +66,45 @@ public interface SpdySettingsFrame {
|
||||
* Sets if the setting is persisted (should only be set by the client).
|
||||
* The ID must be positive and cannot exceed 16777215.
|
||||
*/
|
||||
void setValue(int ID, int value, boolean persistVal, boolean persisted);
|
||||
void setValue(int id, int value, boolean persistVal, boolean persisted);
|
||||
|
||||
/**
|
||||
* Removes the value of the setting ID.
|
||||
* Removes all persistance information for the setting.
|
||||
*/
|
||||
void removeValue(int ID);
|
||||
void removeValue(int id);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #isPersistValue(int)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean persistValue(int ID);
|
||||
boolean persistValue(int id);
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this setting should be persisted.
|
||||
* Returns {@code false} if this setting should not be persisted
|
||||
* or if the setting ID has no value.
|
||||
*/
|
||||
boolean isPersistValue(int ID);
|
||||
boolean isPersistValue(int id);
|
||||
|
||||
/**
|
||||
* Sets if this setting should be persisted.
|
||||
* Has no effect if the setting ID has no value.
|
||||
*/
|
||||
void setPersistValue(int ID, boolean persistValue);
|
||||
void setPersistValue(int id, boolean persistValue);
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this setting is persisted.
|
||||
* Returns {@code false} if this setting should not be persisted
|
||||
* or if the setting ID has no value.
|
||||
*/
|
||||
boolean isPersisted(int ID);
|
||||
boolean isPersisted(int id);
|
||||
|
||||
/**
|
||||
* Sets if this setting is persisted.
|
||||
* Has no effect if the setting ID has no value.
|
||||
*/
|
||||
void setPersisted(int ID, boolean persisted);
|
||||
void setPersisted(int id, boolean persisted);
|
||||
|
||||
/**
|
||||
* Returns {@code true} if previously persisted settings should be cleared.
|
||||
|
@ -137,11 +137,11 @@ public abstract class CIDR implements Comparable<CIDR> {
|
||||
public abstract boolean contains(InetAddress inetAddress);
|
||||
|
||||
@Override
|
||||
public boolean equals(Object arg0) {
|
||||
if (!(arg0 instanceof CIDR)) {
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof CIDR)) {
|
||||
return false;
|
||||
}
|
||||
return compareTo((CIDR) arg0) == 0;
|
||||
return compareTo((CIDR) o) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -97,16 +97,16 @@ public class CIDR4 extends CIDR {
|
||||
* Given an IPv4 baseAddress length, return the block length. I.e., a
|
||||
* baseAddress length of 24 will return 256.
|
||||
*/
|
||||
private static int ipv4PrefixLengthToLength(int prefix_length) {
|
||||
return 1 << 32 - prefix_length;
|
||||
private static int ipv4PrefixLengthToLength(int prefixLength) {
|
||||
return 1 << 32 - prefixLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a baseAddress length, return a netmask. I.e, a baseAddress length
|
||||
* of 24 will return 0xFFFFFF00.
|
||||
*/
|
||||
private static int ipv4PrefixLengthToMask(int prefix_length) {
|
||||
return ~((1 << 32 - prefix_length) - 1);
|
||||
private static int ipv4PrefixLengthToMask(int prefixLength) {
|
||||
return ~((1 << 32 - prefixLength) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -349,13 +349,13 @@ public abstract class AbstractTrafficShapingHandler extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext arg0, MessageEvent arg1)
|
||||
public void messageReceived(ChannelHandlerContext ctx, MessageEvent evt)
|
||||
throws Exception {
|
||||
try {
|
||||
long curtime = System.currentTimeMillis();
|
||||
long size = objectSizeEstimator.estimateSize(arg1.getMessage());
|
||||
long size = objectSizeEstimator.estimateSize(evt.getMessage());
|
||||
if (trafficCounter != null) {
|
||||
trafficCounter.bytesRecvFlowControl(arg0, size);
|
||||
trafficCounter.bytesRecvFlowControl(ctx, size);
|
||||
if (readLimit == 0) {
|
||||
// no action
|
||||
return;
|
||||
@ -366,7 +366,7 @@ public abstract class AbstractTrafficShapingHandler extends
|
||||
trafficCounter.getLastTime(), curtime);
|
||||
if (wait >= MINIMAL_WAIT) { // At least 10ms seems a minimal
|
||||
// time in order to
|
||||
Channel channel = arg0.getChannel();
|
||||
Channel channel = ctx.getChannel();
|
||||
// try to limit the traffic
|
||||
if (channel != null && channel.isConnected()) {
|
||||
// Channel version
|
||||
@ -379,12 +379,12 @@ public abstract class AbstractTrafficShapingHandler extends
|
||||
Thread.sleep(wait);
|
||||
return;
|
||||
}
|
||||
if (arg0.getAttachment() == null) {
|
||||
if (ctx.getAttachment() == null) {
|
||||
// readSuspended = true;
|
||||
arg0.setAttachment(Boolean.TRUE);
|
||||
ctx.setAttachment(Boolean.TRUE);
|
||||
channel.setReadable(false);
|
||||
// logger.warn("Read will wakeup after "+wait+" ms "+this);
|
||||
TimerTask timerTask = new ReopenReadTimerTask(arg0);
|
||||
TimerTask timerTask = new ReopenReadTimerTask(ctx);
|
||||
timeout = timer.newTimeout(timerTask, wait,
|
||||
TimeUnit.MILLISECONDS);
|
||||
} else {
|
||||
@ -408,16 +408,16 @@ public abstract class AbstractTrafficShapingHandler extends
|
||||
}
|
||||
} finally {
|
||||
// The message is then just passed to the next handler
|
||||
super.messageReceived(arg0, arg1);
|
||||
super.messageReceived(ctx, evt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeRequested(ChannelHandlerContext arg0, MessageEvent arg1)
|
||||
public void writeRequested(ChannelHandlerContext ctx, MessageEvent evt)
|
||||
throws Exception {
|
||||
try {
|
||||
long curtime = System.currentTimeMillis();
|
||||
long size = objectSizeEstimator.estimateSize(arg1.getMessage());
|
||||
long size = objectSizeEstimator.estimateSize(evt.getMessage());
|
||||
if (trafficCounter != null) {
|
||||
trafficCounter.bytesWriteFlowControl(size);
|
||||
if (writeLimit == 0) {
|
||||
@ -438,7 +438,7 @@ public abstract class AbstractTrafficShapingHandler extends
|
||||
}
|
||||
} finally {
|
||||
// The message is then just passed to the next handler
|
||||
super.writeRequested(arg0, arg1);
|
||||
super.writeRequested(ctx, evt);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
|
@ -49,6 +49,7 @@ package org.jboss.netty.util.internal.jzlib;
|
||||
|
||||
import org.jboss.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 org.jboss.netty.util.internal.jzlib;
|
||||
|
||||
@SuppressWarnings("MethodParameterNamingConvention")
|
||||
final class InfCodes {
|
||||
|
||||
private static final int[] inflate_mask = { 0x00000000, 0x00000001,
|
||||
|
@ -15,21 +15,20 @@
|
||||
*/
|
||||
package org.jboss.netty.handler.codec.spdy;
|
||||
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelStateEvent;
|
||||
import org.jboss.netty.channel.Channels;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
||||
import org.jboss.netty.handler.codec.embedder.DecoderEmbedder;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jboss.netty.handler.codec.spdy.SpdyCodecUtil.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SpdySessionHandlerTest {
|
||||
|
||||
private static final int closeSignal = SPDY_SETTINGS_MAX_ID;
|
||||
@ -43,25 +42,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);
|
||||
@ -69,36 +68,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) {
|
||||
DecoderEmbedder<Object> sessionHandler =
|
||||
new DecoderEmbedder<Object>(
|
||||
new SpdySessionHandler(version, server), new EchoHandler(closeSignal, server));
|
||||
@ -121,34 +120,34 @@ public class SpdySessionHandlerTest {
|
||||
// a data frame for a Stream-ID that is not open
|
||||
sessionHandler.offer(new DefaultSpdyDataFrame(localStreamID));
|
||||
assertRstStream(sessionHandler.poll(), localStreamID, SpdyStreamStatus.INVALID_STREAM);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
|
||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||
// a data frame for a Stream-ID before receiving a SYN_REPLY frame
|
||||
sessionHandler.offer(new DefaultSpdyDataFrame(remoteStreamID));
|
||||
assertRstStream(sessionHandler.poll(), remoteStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
remoteStreamID += 2;
|
||||
|
||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||
// multiple SYN_REPLY frames for the same active Stream-ID
|
||||
sessionHandler.offer(new DefaultSpdySynReplyFrame(remoteStreamID));
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
sessionHandler.offer(new DefaultSpdySynReplyFrame(remoteStreamID));
|
||||
assertRstStream(sessionHandler.poll(), remoteStreamID, SpdyStreamStatus.STREAM_IN_USE);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
remoteStreamID += 2;
|
||||
|
||||
// Check if frame codec correctly compresses/uncompresses headers
|
||||
sessionHandler.offer(spdySynStreamFrame);
|
||||
assertSynReply(sessionHandler.poll(), localStreamID, false, spdySynStreamFrame);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
SpdyHeadersFrame spdyHeadersFrame = new DefaultSpdyHeadersFrame(localStreamID);
|
||||
spdyHeadersFrame.addHeader("HEADER","test1");
|
||||
spdyHeadersFrame.addHeader("HEADER","test2");
|
||||
sessionHandler.offer(spdyHeadersFrame);
|
||||
assertHeaders(sessionHandler.poll(), localStreamID, spdyHeadersFrame);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
localStreamID += 2;
|
||||
|
||||
// Check if session handler closed the streams using the number
|
||||
@ -159,25 +158,25 @@ public class SpdySessionHandlerTest {
|
||||
spdySynStreamFrame.setUnidirectional(true);
|
||||
sessionHandler.offer(spdySynStreamFrame);
|
||||
assertRstStream(sessionHandler.poll(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
|
||||
// Check if session handler drops active streams if it receives
|
||||
// a RST_STREAM frame for that Stream-ID
|
||||
sessionHandler.offer(new DefaultSpdyRstStreamFrame(remoteStreamID, 3));
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
remoteStreamID += 2;
|
||||
|
||||
// Check if session handler honors UNIDIRECTIONAL streams
|
||||
spdySynStreamFrame.setLast(false);
|
||||
sessionHandler.offer(spdySynStreamFrame);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
spdySynStreamFrame.setUnidirectional(false);
|
||||
|
||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||
// multiple SYN_STREAM frames for the same active Stream-ID
|
||||
sessionHandler.offer(spdySynStreamFrame);
|
||||
assertRstStream(sessionHandler.poll(), localStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
localStreamID += 2;
|
||||
|
||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||
@ -185,7 +184,7 @@ public class SpdySessionHandlerTest {
|
||||
spdySynStreamFrame.setStreamId(localStreamID - 1);
|
||||
sessionHandler.offer(spdySynStreamFrame);
|
||||
assertRstStream(sessionHandler.poll(), localStreamID - 1, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
spdySynStreamFrame.setStreamId(localStreamID);
|
||||
|
||||
// Check if session handler correctly limits the number of
|
||||
@ -193,26 +192,26 @@ public class SpdySessionHandlerTest {
|
||||
SpdySettingsFrame spdySettingsFrame = new DefaultSpdySettingsFrame();
|
||||
spdySettingsFrame.setValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS, 2);
|
||||
sessionHandler.offer(spdySettingsFrame);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
sessionHandler.offer(spdySynStreamFrame);
|
||||
assertRstStream(sessionHandler.poll(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
spdySettingsFrame.setValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS, 4);
|
||||
sessionHandler.offer(spdySettingsFrame);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
sessionHandler.offer(spdySynStreamFrame);
|
||||
assertSynReply(sessionHandler.poll(), localStreamID, false, spdySynStreamFrame);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
|
||||
// Check if session handler rejects HEADERS for closed streams
|
||||
int testStreamID = spdyDataFrame.getStreamId();
|
||||
sessionHandler.offer(spdyDataFrame);
|
||||
assertDataFrame(sessionHandler.poll(), testStreamID, spdyDataFrame.isLast());
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
spdyHeadersFrame.setStreamId(testStreamID);
|
||||
sessionHandler.offer(spdyHeadersFrame);
|
||||
assertRstStream(sessionHandler.poll(), testStreamID, SpdyStreamStatus.INVALID_STREAM);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
|
||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||
// an invalid HEADERS frame
|
||||
@ -220,21 +219,21 @@ public class SpdySessionHandlerTest {
|
||||
spdyHeadersFrame.setInvalid();
|
||||
sessionHandler.offer(spdyHeadersFrame);
|
||||
assertRstStream(sessionHandler.poll(), localStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
|
||||
// Check if session handler returns identical local PINGs
|
||||
sessionHandler.offer(localPingFrame);
|
||||
assertPing(sessionHandler.poll(), localPingFrame.getId());
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
|
||||
// Check if session handler ignores un-initiated remote PINGs
|
||||
sessionHandler.offer(remotePingFrame);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
|
||||
// Check if session handler sends a GOAWAY frame when closing
|
||||
sessionHandler.offer(closeMessage);
|
||||
assertGoAway(sessionHandler.poll(), localStreamID);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
localStreamID += 2;
|
||||
|
||||
// Check if session handler returns REFUSED_STREAM if it receives
|
||||
@ -242,13 +241,13 @@ public class SpdySessionHandlerTest {
|
||||
spdySynStreamFrame.setStreamId(localStreamID);
|
||||
sessionHandler.offer(spdySynStreamFrame);
|
||||
assertRstStream(sessionHandler.poll(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
|
||||
// Check if session handler ignores Data frames after sending
|
||||
// a GOAWAY frame
|
||||
spdyDataFrame.setStreamId(localStreamID);
|
||||
sessionHandler.offer(spdyDataFrame);
|
||||
Assert.assertNull(sessionHandler.peek());
|
||||
assertNull(sessionHandler.peek());
|
||||
|
||||
sessionHandler.finish();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user