Skip to content
Permalink
Browse files
Upgrade to Java 1.8
  • Loading branch information
ok2c committed Mar 12, 2021
1 parent af4fda1 commit 6d2627d60b06f45b82b8ae3b0d24a104c0cf983a
Showing 113 changed files with 1,735 additions and 3,315 deletions.
@@ -36,10 +36,6 @@ script: mvn verify -B -P docker

jobs:
include:
- name: amd64-jdk7
arch: amd64
jdk: openjdk7
script: mvn verify -B
- name: arm64
arch: arm64
script: mvn verify -B
@@ -33,7 +33,7 @@ For building from source instructions please refer to [BUILDING.txt](./BUILDING.
Dependencies
------------

HttpCore requires Java 1.7 compatible runtime.
HttpCore requires Java 1.8 compatible runtime.

Licensing
---------
@@ -103,11 +103,7 @@ public void add(final HPackHeader header) {
}
final String key = header.getName();
final FifoLinkedList.InternalNode node = headers.addFirst(header);
LinkedList<HPackEntry> nodes = mapByName.get(key);
if (nodes == null) {
nodes = new LinkedList<>();
mapByName.put(key, nodes);
}
final LinkedList<HPackEntry> nodes = mapByName.computeIfAbsent(key, k -> new LinkedList<>());
nodes.addFirst(node);
currentSize += entrySize;
evict();
@@ -81,25 +81,30 @@ public HttpRequest convert(final List<Header> headers) throws HttpException {
throw new ProtocolException("Invalid sequence of headers (pseudo-headers must precede message headers)");
}

if (name.equals(H2PseudoRequestHeaders.METHOD)) {
if (method != null) {
throw new ProtocolException("Multiple '%s' request headers are illegal", name);
}
method = value;
} else if (name.equals(H2PseudoRequestHeaders.SCHEME)) {
if (scheme != null) {
throw new ProtocolException("Multiple '%s' request headers are illegal", name);
}
scheme = value;
} else if (name.equals(H2PseudoRequestHeaders.PATH)) {
if (path != null) {
throw new ProtocolException("Multiple '%s' request headers are illegal", name);
}
path = value;
} else if (name.equals(H2PseudoRequestHeaders.AUTHORITY)) {
authority = value;
} else {
throw new ProtocolException("Unsupported request header '%s'", name);
switch (name) {
case H2PseudoRequestHeaders.METHOD:
if (method != null) {
throw new ProtocolException("Multiple '%s' request headers are illegal", name);
}
method = value;
break;
case H2PseudoRequestHeaders.SCHEME:
if (scheme != null) {
throw new ProtocolException("Multiple '%s' request headers are illegal", name);
}
scheme = value;
break;
case H2PseudoRequestHeaders.PATH:
if (path != null) {
throw new ProtocolException("Multiple '%s' request headers are illegal", name);
}
path = value;
break;
case H2PseudoRequestHeaders.AUTHORITY:
authority = value;
break;
default:
throw new ProtocolException("Unsupported request header '%s'", name);
}
} else {
if (name.equalsIgnoreCase(HttpHeaders.CONNECTION)) {
@@ -26,7 +26,6 @@
*/
package org.apache.hc.core5.http2.impl.nio;

import javax.net.ssl.SSLSession;
import java.io.IOException;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
@@ -43,7 +42,8 @@
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.hc.core5.concurrent.Cancellable;
import javax.net.ssl.SSLSession;

import org.apache.hc.core5.concurrent.CancellableDependency;
import org.apache.hc.core5.http.ConnectionClosedException;
import org.apache.hc.core5.http.EndpointDetails;
@@ -628,14 +628,7 @@ private void processPendingCommands() throws IOException, HttpException {
}
final CancellableDependency cancellableDependency = executableCommand.getCancellableDependency();
if (cancellableDependency != null) {
cancellableDependency.setDependency(new Cancellable() {

@Override
public boolean cancel() {
return stream.abort();
}

});
cancellableDependency.setDependency(stream::abort);
}
if (!outputQueue.isEmpty()) {
return;
@@ -49,8 +49,6 @@
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
import org.apache.hc.core5.http.nio.DataStreamChannel;
import org.apache.hc.core5.http.nio.HandlerFactory;
import org.apache.hc.core5.http.nio.RequestChannel;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.http2.H2ConnectionException;
@@ -168,15 +166,7 @@ private void commitRequest(final HttpRequest request, final EntityDetails entity
public void produceOutput() throws HttpException, IOException {
switch (requestState) {
case HEADERS:
exchangeHandler.produceRequest(new RequestChannel() {

@Override
public void sendRequest(
final HttpRequest request, final EntityDetails entityDetails, final HttpContext httpContext) throws HttpException, IOException {
commitRequest(request, entityDetails);
}

}, context);
exchangeHandler.produceRequest((request, entityDetails, httpContext) -> commitRequest(request, entityDetails), context);
break;
case BODY:
exchangeHandler.produce(dataChannel);
@@ -48,7 +48,6 @@
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.impl.DefaultAddressResolver;
@@ -150,99 +149,92 @@ private void execute(
Args.notNull(timeout, "Timeout");
Args.notNull(context, "Context");
try {
exchangeHandler.produceRequest(new RequestChannel() {

@Override
public void sendRequest(
final HttpRequest request,
final EntityDetails entityDetails, final HttpContext httpContext) throws HttpException, IOException {
final String scheme = request.getScheme();
final URIAuthority authority = request.getAuthority();
if (authority == null) {
throw new ProtocolException("Request authority not specified");
}
final HttpHost target = new HttpHost(scheme, authority);
connPool.getSession(target, timeout, new FutureCallback<IOSession>() {

@Override
public void completed(final IOSession ioSession) {
ioSession.enqueue(new RequestExecutionCommand(new AsyncClientExchangeHandler() {

@Override
public void releaseResources() {
exchangeHandler.releaseResources();
}

@Override
public void produceRequest(final RequestChannel channel, final HttpContext httpContext) throws HttpException, IOException {
channel.sendRequest(request, entityDetails, httpContext);
}

@Override
public int available() {
return exchangeHandler.available();
}

@Override
public void produce(final DataStreamChannel channel) throws IOException {
exchangeHandler.produce(channel);
}

@Override
public void consumeInformation(final HttpResponse response, final HttpContext httpContext) throws HttpException, IOException {
exchangeHandler.consumeInformation(response, httpContext);
}

@Override
public void consumeResponse(
final HttpResponse response, final EntityDetails entityDetails, final HttpContext httpContext) throws HttpException, IOException {
exchangeHandler.consumeResponse(response, entityDetails, httpContext);
}

@Override
public void updateCapacity(final CapacityChannel capacityChannel) throws IOException {
exchangeHandler.updateCapacity(capacityChannel);
}

@Override
public void consume(final ByteBuffer src) throws IOException {
exchangeHandler.consume(src);
}

@Override
public void streamEnd(final List<? extends Header> trailers) throws HttpException, IOException {
exchangeHandler.streamEnd(trailers);
}

@Override
public void cancel() {
exchangeHandler.cancel();
}

@Override
public void failed(final Exception cause) {
exchangeHandler.failed(cause);
}

}, pushHandlerFactory, cancellableDependency, context), Command.Priority.NORMAL);
if (!ioSession.isOpen()) {
exchangeHandler.failed(new ConnectionClosedException());
exchangeHandler.produceRequest((request, entityDetails, httpContext) -> {
final String scheme = request.getScheme();
final URIAuthority authority = request.getAuthority();
if (authority == null) {
throw new ProtocolException("Request authority not specified");
}
final HttpHost target = new HttpHost(scheme, authority);
connPool.getSession(target, timeout, new FutureCallback<IOSession>() {

@Override
public void completed(final IOSession ioSession) {
ioSession.enqueue(new RequestExecutionCommand(new AsyncClientExchangeHandler() {

@Override
public void releaseResources() {
exchangeHandler.releaseResources();
}
}

@Override
public void failed(final Exception ex) {
exchangeHandler.failed(ex);
}
@Override
public void produceRequest(final RequestChannel channel, final HttpContext httpContext) throws HttpException, IOException {
channel.sendRequest(request, entityDetails, httpContext);
}

@Override
public int available() {
return exchangeHandler.available();
}

@Override
public void produce(final DataStreamChannel channel) throws IOException {
exchangeHandler.produce(channel);
}

@Override
public void consumeInformation(final HttpResponse response, final HttpContext httpContext) throws HttpException, IOException {
exchangeHandler.consumeInformation(response, httpContext);
}

@Override
public void consumeResponse(
final HttpResponse response, final EntityDetails entityDetails, final HttpContext httpContext) throws HttpException, IOException {
exchangeHandler.consumeResponse(response, entityDetails, httpContext);
}

@Override
public void updateCapacity(final CapacityChannel capacityChannel) throws IOException {
exchangeHandler.updateCapacity(capacityChannel);
}

@Override
public void consume(final ByteBuffer src) throws IOException {
exchangeHandler.consume(src);
}

@Override
public void streamEnd(final List<? extends Header> trailers) throws HttpException, IOException {
exchangeHandler.streamEnd(trailers);
}

@Override
public void cancel() {
exchangeHandler.cancel();
}

@Override
public void failed(final Exception cause) {
exchangeHandler.failed(cause);
}

@Override
public void cancelled() {
exchangeHandler.cancel();
}, pushHandlerFactory, cancellableDependency, context), Command.Priority.NORMAL);
if (!ioSession.isOpen()) {
exchangeHandler.failed(new ConnectionClosedException());
}
}

});
@Override
public void failed(final Exception ex) {
exchangeHandler.failed(ex);
}

}
@Override
public void cancelled() {
exchangeHandler.cancel();
}

});

}, context);
} catch (final IOException | HttpException ex) {
@@ -46,12 +46,9 @@
import org.apache.hc.core5.http2.impl.nio.H2StreamListener;
import org.apache.hc.core5.http2.nio.support.DefaultAsyncPushConsumerFactory;
import org.apache.hc.core5.http2.ssl.H2ClientTlsStrategy;
import org.apache.hc.core5.reactor.IOEventHandler;
import org.apache.hc.core5.reactor.IOEventHandlerFactory;
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.reactor.IOSession;
import org.apache.hc.core5.reactor.IOSessionListener;
import org.apache.hc.core5.reactor.ProtocolIOSession;
import org.apache.hc.core5.util.Args;

/**
@@ -210,14 +207,7 @@ public H2MultiplexingRequester create() {
streamListener);
return new H2MultiplexingRequester(
ioReactorConfig,
new IOEventHandlerFactory() {

@Override
public IOEventHandler createHandler(final ProtocolIOSession ioSession, final Object attachment) {
return new H2OnlyClientProtocolNegotiator(ioSession, http2StreamHandlerFactory, strictALPNHandshake);
}

},
(ioSession, attachment) -> new H2OnlyClientProtocolNegotiator(ioSession, http2StreamHandlerFactory, strictALPNHandshake),
ioSessionDecorator,
exceptionCallback,
sessionListener,
@@ -295,7 +295,7 @@ public H2AsyncRequester create() {
defaultMaxPerRoute > 0 ? defaultMaxPerRoute : 20,
timeToLive,
poolReusePolicy,
new DefaultDisposalCallback<IOSession>(),
new DefaultDisposalCallback<>(),
connPoolListener);
break;
case STRICT:
@@ -305,7 +305,7 @@ public H2AsyncRequester create() {
maxTotal > 0 ? maxTotal : 50,
timeToLive,
poolReusePolicy,
new DefaultDisposalCallback<IOSession>(),
new DefaultDisposalCallback<>(),
connPoolListener);
break;
}

0 comments on commit 6d2627d

Please sign in to comment.