Skip to content

Commit

Permalink
Merge branch 'master' into master_refactor_future_contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory authored Sep 23, 2024
2 parents 2edf387 + 0673585 commit a9cdfae
Show file tree
Hide file tree
Showing 121 changed files with 374 additions and 363 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
*/
public final class H2PseudoRequestHeaders {

public static final String METHOD = ":method";
public static final String SCHEME = ":scheme";
public static final String METHOD = ":method";
public static final String SCHEME = ":scheme";
public static final String AUTHORITY = ":authority";
public static final String PATH = ":path";
public static final String PATH = ":path";

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
*/
public final class H2PseudoResponseHeaders {

public static final String STATUS = ":status";
public static final String STATUS = ":status";

}
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ public static H2Config.Builder custom() {
return new Builder();
}

private static final int INIT_HEADER_TABLE_SIZE = 4096;
private static final boolean INIT_ENABLE_PUSH = true;
private static final int INIT_MAX_FRAME_SIZE = FrameConsts.MIN_FRAME_SIZE;
private static final int INIT_WINDOW_SIZE = 65535;
private static final int INIT_CONCURRENT_STREAM = 250;
private static final int INIT_HEADER_TABLE_SIZE = 4096;
private static final boolean INIT_ENABLE_PUSH = true;
private static final int INIT_MAX_FRAME_SIZE = FrameConsts.MIN_FRAME_SIZE;
private static final int INIT_WINDOW_SIZE = 65535;
private static final int INIT_CONCURRENT_STREAM = 250;

public static H2Config.Builder initial() {
return new Builder()
Expand Down Expand Up @@ -153,7 +153,7 @@ public static class Builder {
this.pushEnabled = INIT_ENABLE_PUSH;
this.maxConcurrentStreams = INIT_CONCURRENT_STREAM;
this.initialWindowSize = INIT_WINDOW_SIZE;
this.maxFrameSize = FrameConsts.MIN_FRAME_SIZE * 4;
this.maxFrameSize = FrameConsts.MIN_FRAME_SIZE * 4;
this.maxHeaderListSize = FrameConsts.MAX_FRAME_SIZE;
this.compressionEnabled = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
*/
public enum H2Param {

HEADER_TABLE_SIZE (0x1),
ENABLE_PUSH (0x2),
MAX_CONCURRENT_STREAMS (0x3),
INITIAL_WINDOW_SIZE (0x4),
MAX_FRAME_SIZE (0x5),
MAX_HEADER_LIST_SIZE (0x6);
HEADER_TABLE_SIZE(0x1),
ENABLE_PUSH(0x2),
MAX_CONCURRENT_STREAMS(0x3),
INITIAL_WINDOW_SIZE(0x4),
MAX_FRAME_SIZE(0x5),
MAX_HEADER_LIST_SIZE(0x6);

int code;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ public RawFrame createHeaders(final int streamId, final ByteBuffer payload, fina
@Override
public RawFrame createContinuation(final int streamId, final ByteBuffer payload, final boolean endHeaders) {
Args.positive(streamId, "Stream id");
final int flags = (endHeaders ? FrameFlag.END_HEADERS.value : 0);
final int flags = endHeaders ? FrameFlag.END_HEADERS.value : 0;
return new RawFrame(FrameType.CONTINUATION.getValue(), flags, streamId, payload);
}

@Override
public RawFrame createPushPromise(final int streamId, final ByteBuffer payload, final boolean endHeaders) {
Args.positive(streamId, "Stream id");
final int flags = (endHeaders ? FrameFlag.END_HEADERS.value : 0);
final int flags = endHeaders ? FrameFlag.END_HEADERS.value : 0;
return new RawFrame(FrameType.PUSH_PROMISE.getValue(), flags, streamId, payload);
}

@Override
public RawFrame createData(final int streamId, final ByteBuffer payload, final boolean endStream) {
Args.positive(streamId, "Stream id");
final int flags = (endStream ? FrameFlag.END_STREAM.value : 0);
final int flags = endStream ? FrameFlag.END_STREAM.value : 0;
return new RawFrame(FrameType.DATA.getValue(), flags, streamId, payload);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
*/
public enum FrameFlag {

END_STREAM (0x01),
ACK (0x01),
END_HEADERS (0x04),
PADDED (0x08),
PRIORITY (0x20);
END_STREAM(0x01),
ACK(0x01),
END_HEADERS(0x04),
PADDED(0x08),
PRIORITY(0x20);

final int value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
*/
public enum FrameType {

DATA (0x00),
HEADERS (0x01),
PRIORITY (0x02),
RST_STREAM (0x03),
SETTINGS (0x04),
PUSH_PROMISE (0x05),
PING (0x06),
GOAWAY (0x07),
WINDOW_UPDATE (0x08),
CONTINUATION (0x09);
DATA(0x00),
HEADERS(0x01),
PRIORITY(0x02),
RST_STREAM(0x03),
SETTINGS(0x04),
PUSH_PROMISE(0x05),
PING(0x06),
GOAWAY(0x07),
WINDOW_UPDATE(0x08),
CONTINUATION(0x09);

int value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ HPackHeader decodeLiteralHeader(
nameLen = decodeString(src, buf);
name = buf.toString();
} else {
final HPackHeader existing = this.dynamicTable.getHeader(index);
final HPackHeader existing = this.dynamicTable.getHeader(index);
if (existing == null) {
throw new HPackException("Invalid header index");
}
Expand All @@ -258,7 +258,7 @@ HPackHeader decodeLiteralHeader(
HPackHeader decodeIndexedHeader(final ByteBuffer src) throws HPackException {

final int index = decodeInt(src, 7);
final HPackHeader existing = this.dynamicTable.getHeader(index);
final HPackHeader existing = this.dynamicTable.getHeader(index);
if (existing == null) {
throw new HPackException("Invalid header index");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ void encode(final ByteArrayBuffer out, final ByteBuffer src) {
}

if (n > 0) {
current <<= (8 - n);
current |= (0xFF >>> n); // this should be EOS symbol
current <<= 8 - n;
current |= 0xFF >>> n; // this should be EOS symbol
out.append((int) current);
}
}
Expand All @@ -93,8 +93,8 @@ void encode(final ByteArrayBuffer out, final CharSequence src, final int off, fi
}

if (n > 0) {
current <<= (8 - n);
current |= (0xFF >>> n); // this should be EOS symbol
current <<= 8 - n;
current |= 0xFF >>> n; // this should be EOS symbol
out.append((int) current);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public List<Header> convert(final HttpRequest message) throws HttpException {
headers.add(new BasicHeader(H2PseudoRequestHeaders.METHOD, message.getMethod(), false));
if (optionMethod) {
headers.add(new BasicHeader(H2PseudoRequestHeaders.AUTHORITY, message.getAuthority(), false));
} else {
} else {
headers.add(new BasicHeader(H2PseudoRequestHeaders.SCHEME, message.getScheme(), false));
if (message.getAuthority() != null) {
headers.add(new BasicHeader(H2PseudoRequestHeaders.AUTHORITY, message.getAuthority(), false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ abstract class AbstractH2StreamMultiplexer implements Identifiable, HttpConnecti
private static final long LINGER_TIME = 1000; // 1 second
private static final long CONNECTION_WINDOW_LOW_MARK = 10 * 1024 * 1024; // 10 MiB

enum ConnectionHandshake { READY, ACTIVE, GRACEFUL_SHUTDOWN, SHUTDOWN}
enum ConnectionHandshake { READY, ACTIVE, GRACEFUL_SHUTDOWN, SHUTDOWN }
enum SettingsHandshake { READY, TRANSMITTED, ACKED }

private final ProtocolIOSession ioSession;
Expand Down Expand Up @@ -305,7 +305,7 @@ private void commitPushPromise(
buf.append((byte)(promisedStreamId >> 24));
buf.append((byte)(promisedStreamId >> 16));
buf.append((byte)(promisedStreamId >> 8));
buf.append((byte)(promisedStreamId));
buf.append((byte) promisedStreamId);

hPackEncoder.encodeHeaders(buf, headers, localConfig.isCompressionEnabled());

Expand Down Expand Up @@ -680,7 +680,7 @@ public final void onException(final Exception cause) {
final H2Error errorCode;
if (cause instanceof H2ConnectionException) {
errorCode = H2Error.getByCode(((H2ConnectionException) cause).getCode());
} else if (cause instanceof ProtocolException){
} else if (cause instanceof ProtocolException) {
errorCode = H2Error.PROTOCOL_ERROR;
} else {
errorCode = H2Error.INTERNAL_ERROR;
Expand Down Expand Up @@ -1532,7 +1532,7 @@ boolean localReset(final int code) throws IOException {
}

boolean localReset(final H2Error error) throws IOException {
return localReset(error!= null ? error.getCode() : H2Error.INTERNAL_ERROR.getCode());
return localReset(error != null ? error.getCode() : H2Error.INTERNAL_ERROR.getCode());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private void initialize() throws IOException {
/**
* @return true if the entire preface has been written out
*/
private boolean writeOutPreface(final IOSession session, final ByteBuffer preface) throws IOException {
private boolean writeOutPreface(final IOSession session, final ByteBuffer preface) throws IOException {
if (preface.hasRemaining()) {
session.write(preface);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void connected(final IOSession session) throws IOException {
startProtocol(httpVersion);
}
@Override
public void inputReady(final IOSession session, final ByteBuffer src) throws IOException {
public void inputReady(final IOSession session, final ByteBuffer src) throws IOException {
throw new ProtocolNegotiationException("Unexpected input");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private void commitResponse(
final List<Header> responseHeaders = DefaultH2ResponseConverter.INSTANCE.convert(response);

final boolean endStream = responseEntityDetails == null ||
(receivedRequest != null && Method.HEAD.isSame(receivedRequest.getMethod()));
receivedRequest != null && Method.HEAD.isSame(receivedRequest.getMethod());
outputChannel.submit(responseHeaders, endStream);
connMetrics.incrementResponseCount();
if (responseEntityDetails == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

class FilterEntry<T> {

enum Position {BEFORE, AFTER, REPLACE, FIRST, LAST}
enum Position { BEFORE, AFTER, REPLACE, FIRST, LAST }

final Position position;
final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
*
* @since 5.0
*/
public class H2MultiplexingRequester extends AsyncRequester{
public class H2MultiplexingRequester extends AsyncRequester {

private final H2ConnPool connPool;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public ConscryptServerTlsStrategy(final SSLContext sslContext) {
* @since 5.2
*/
public ConscryptServerTlsStrategy() {
this(SSLContexts.createSystemDefault(), (SSLBufferMode) null, null, null);
this(SSLContexts.createSystemDefault(), (SSLBufferMode) null, null, null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public int read() throws IOException {
public int read(final byte b[], final int off, final int len) throws IOException {
if (b == null) {
throw new NullPointerException();
} else if ((off < 0) || (off > b.length) || (len < 0) ||
((off + len) > b.length) || ((off + len) < 0)) {
} else if (off < 0 || off > b.length || len < 0 ||
(off + len) > b.length || (off + len) < 0) {
throw new IndexOutOfBoundsException();
}
if (len == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private void flushToSubscriber() {
return;
}
ByteBuffer next;
while (requests.get() > 0 && ((next = buffers.poll()) != null)) {
while (requests.get() > 0 && (next = buffers.poll()) != null) {
final int bytesFreed = next.remaining();
s.onNext(next);
requests.decrementAndGet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public String toString() {
", useAcceptGZip=" + useAcceptGZip +
", payloadText='" + payloadText + '\'' +
", soapAction='" + soapAction + '\'' +
", forceHttp2=" + forceHttp2+
", forceHttp2=" + forceHttp2 +
", disableSSLVerification=" + disableSSLVerification +
", trustStorePath='" + trustStorePath + '\'' +
", identityStorePath='" + identityStorePath + '\'' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ public void run() {
final Thread t2 = pumpStream(target.getInputStream(), output);
try {
t1.join();
} catch (final InterruptedException e) {
} catch (final InterruptedException ignored) {
}
try {
t2.join();
} catch (final InterruptedException e) {
} catch (final InterruptedException ignored) {
}
} catch (final IOException e) {
} catch (final IOException ignored) {
} finally {
parent.cleanupSocksProxyHandler(SocksProxyHandler.this);
}
Expand Down Expand Up @@ -178,7 +178,7 @@ private Thread pumpStream(final InputStream input, final OutputStream output) {
output.write(buffer, 0, read);
output.flush();
}
} catch (final IOException e) {
} catch (final IOException ignored) {
} finally {
shutdown();
}
Expand All @@ -193,12 +193,12 @@ private Thread pumpStream(final InputStream input, final OutputStream output) {
public void shutdown() {
try {
this.socket.close();
} catch (final IOException e) {
} catch (final IOException ignored) {
}
if (this.remote != null) {
try {
this.remote.close();
} catch (final IOException e) {
} catch (final IOException ignored) {
}
}
}
Expand Down Expand Up @@ -232,12 +232,12 @@ public void start() throws IOException {
final Socket socket = server.accept();
startSocksProxyHandler(socket);
}
} catch (final IOException e) {
} catch (final IOException ignored) {
} finally {
if (server != null) {
try {
server.close();
} catch (final IOException e) {
} catch (final IOException ignored) {
}
server = null;
}
Expand All @@ -258,7 +258,7 @@ public void shutdown(final TimeValue timeout) throws InterruptedException {
if (this.server != null) {
try {
this.server.close();
} catch (final IOException e) {
} catch (final IOException ignored) {
} finally {
this.server = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void wire(final String header, final byte[] b, final int pos, final int
buffer.insert(0, header);
this.log.debug("{} {}", this.id, buffer);
buffer.setLength(0);
} else if ((ch < Chars.SP) || (ch >= Chars.DEL)) {
} else if (ch < Chars.SP || ch >= Chars.DEL) {
buffer.append("[0x");
buffer.append(Integer.toHexString(ch));
buffer.append("]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ public Map<String, Object> execute(final String defaultURI, final Map<String, Ob
* See the documentation for the same method in {@link ClientPOJOAdapter}.
*/
public boolean isRequestSupported(final Map<String, Object> request) {
return (adapter == null) || adapter.checkRequestSupport(request) == null;
return adapter == null || adapter.checkRequestSupport(request) == null;
}

/**
* See the documentation for the same method in {@link ClientPOJOAdapter}.
*/
public Map<String, Object> modifyRequest(final Map<String, Object> request) {
return (adapter == null) ? request : adapter.modifyRequest(request);
return adapter == null ? request : adapter.modifyRequest(request);
}

/**
Expand Down
Loading

0 comments on commit a9cdfae

Please sign in to comment.