Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve the errorprone warning. #862

Merged
merged 4 commits into from
Sep 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/reactor/netty/ReactorNetty.java
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ public synchronized Throwable fillInStackTrace() {

static final ByteBuf BOUNDARY = Unpooled.EMPTY_BUFFER;

@SuppressWarnings("ReferenceEquality")
//Desigin to use reference comparison here
public static final Predicate<ByteBuf> PREDICATE_GROUP_FLUSH = b -> b == BOUNDARY;

}
1 change: 1 addition & 0 deletions src/main/java/reactor/netty/channel/BootstrapHandlers.java
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ public void handlerRemoved(ChannelHandlerContext ctx) {
"BootstrapHandlers.finalizeHandler() call");
}

@SuppressWarnings("deprecation")
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
throw Exceptions.propagate(cause);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import reactor.util.Logger;
import reactor.util.Loggers;

import java.util.Objects;

import static reactor.netty.ReactorNetty.format;

/**
Expand Down Expand Up @@ -100,7 +102,7 @@ final public void channelRead(ChannelHandlerContext ctx, Object msg) {
}
}
String loggingMsg;
if (msg instanceof ByteBufHolder && ((ByteBufHolder)msg).content() != Unpooled.EMPTY_BUFFER) {
if (msg instanceof ByteBufHolder && !Objects.equals(Unpooled.EMPTY_BUFFER,((ByteBufHolder) msg).content())) {
ByteBuf buffer = ((ByteBufHolder) msg).content();
loggingMsg = "\n"+ByteBufUtil.prettyHexDump(buffer);
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/reactor/netty/channel/MonoSendMany.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void subscribe(CoreSubscriber<? super Void> destination) {

@Override
@Nullable
@SuppressWarnings("rawtypes")
public Object scanUnsafe(Attr key) {
if (key == Attr.PREFETCH) return MAX_SIZE;
if (key == Attr.PARENT) return source;
Expand Down Expand Up @@ -388,6 +389,7 @@ void trySchedule(@Nullable Object data) {
}

@Override
@SuppressWarnings("rawtypes")
public Object scanUnsafe(Attr key) {
if (key == Attr.PARENT) return s;
if (key == Attr.ACTUAL) return actual;
Expand Down Expand Up @@ -437,6 +439,7 @@ public ChannelPromise addListener(GenericFutureListener<? extends Future<? super
throw new UnsupportedOperationException();
}

@SuppressWarnings("unchecked")
@Override
public ChannelPromise addListeners(GenericFutureListener<? extends Future<? super Void>>... listeners) {
throw new UnsupportedOperationException();
Expand All @@ -447,6 +450,7 @@ public ChannelPromise removeListener(GenericFutureListener<? extends Future<? su
return this;
}

@SuppressWarnings("unchecked")
@Override
public ChannelPromise removeListeners(GenericFutureListener<? extends Future<? super Void>>... listeners) {
return this;
Expand Down Expand Up @@ -609,8 +613,10 @@ public Void get(long timeout, TimeUnit unit) {
throw new UnsupportedOperationException();
}

@SuppressWarnings("rawtypes")
static final AtomicIntegerFieldUpdater<SendManyInner> WIP =
AtomicIntegerFieldUpdater.newUpdater(SendManyInner.class, "wip");
@SuppressWarnings("rawtypes")
static final AtomicReferenceFieldUpdater<SendManyInner, Subscription> SUBSCRIPTION =
AtomicReferenceFieldUpdater.newUpdater(SendManyInner.class, Subscription.class, "s");

Expand Down
1 change: 1 addition & 0 deletions src/main/java/reactor/netty/http/HttpOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ protected final boolean markSentHeaderAndBody() {
*/
protected abstract HttpMessage outboundHttpMessage();

@SuppressWarnings("rawtypes")
final static AtomicIntegerFieldUpdater<HttpOperations> HTTP_STATE =
AtomicIntegerFieldUpdater.newUpdater(HttpOperations.class,
"statusAndHeadersSent");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ void redirect(String to) {
this.redirectedFrom = addToRedirectedFromArray(redirectedFrom, from);
}

@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked","rawtypes"})
static Supplier<String>[] addToRedirectedFromArray(@Nullable Supplier<String>[] redirectedFrom,
UriEndpoint from) {
Supplier<String> fromUrlSupplier = from::toExternalForm;
Expand Down Expand Up @@ -955,6 +955,7 @@ else if (channelMetricsRecorder instanceof HttpClientMetricsRecorder) {

}

@SuppressWarnings("rawtypes")
static void openStream(Channel ch, ConnectionObserver listener,
HttpClientInitializer initializer) {
Http2StreamChannelBootstrap http2StreamChannelBootstrap =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ void _subscribe(CoreSubscriber<? super Void> s) {
}

static final int MAX_REDIRECTS = 50;
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked","rawtypes"})
static final Supplier<String>[] EMPTY_REDIRECTIONS = (Supplier<String>[])new Supplier[0];
static final Logger log = Loggers.getLogger(HttpClientOperations.class);
}
10 changes: 5 additions & 5 deletions src/main/java/reactor/netty/http/server/ConnectionInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static ConnectionInfo parseForwardedInfo(HttpRequest request, SocketChannel chan
InetSocketAddress hostAddress = channel.localAddress();
String scheme = secured ? "https" : "http";

String forwarded = request.headers().get(FORWARDED_HEADER).split(",")[0];
String forwarded = request.headers().get(FORWARDED_HEADER).split(",",2)[0];
Matcher hostMatcher = FORWARDED_HOST_PATTERN.matcher(forwarded);
if (hostMatcher.find()) {
hostAddress = parseAddress(hostMatcher.group(1), hostAddress.getPort());
Expand Down Expand Up @@ -141,18 +141,18 @@ static ConnectionInfo parseXForwardedInfo(HttpRequest request, SocketChannel cha
InetSocketAddress hostAddress = channel.localAddress();
String scheme = secured ? "https" : "http";
if (request.headers().contains(XFORWARDED_IP_HEADER)) {
String remoteIpValue = request.headers().get(XFORWARDED_IP_HEADER).split(",")[0];
String remoteIpValue = request.headers().get(XFORWARDED_IP_HEADER).split(",",2)[0];
remoteAddress = parseAddress(remoteIpValue, remoteAddress.getPort());
}
if(request.headers().contains(XFORWARDED_HOST_HEADER)) {
if(request.headers().contains(XFORWARDED_PORT_HEADER)) {
hostAddress = InetSocketAddressUtil.createUnresolved(
request.headers().get(XFORWARDED_HOST_HEADER).split(",")[0].trim(),
Integer.parseInt(request.headers().get(XFORWARDED_PORT_HEADER).split(",")[0].trim()));
request.headers().get(XFORWARDED_HOST_HEADER).split(",",2)[0].trim(),
Integer.parseInt(request.headers().get(XFORWARDED_PORT_HEADER).split(",",2)[0].trim()));
}
else {
hostAddress = InetSocketAddressUtil.createUnresolved(
request.headers().get(XFORWARDED_HOST_HEADER).split(",")[0].trim(),
request.headers().get(XFORWARDED_HOST_HEADER).split(",",2)[0].trim(),
channel.localAddress().getPort());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ else if (msg instanceof ByteBuf) {

if (msg instanceof LastHttpContent) {
promise.addListener(future -> {
ChannelOperations channelOps = ChannelOperations.get(ctx.channel());
ChannelOperations<?,?> channelOps = ChannelOperations.get(ctx.channel());
if (channelOps instanceof HttpServerOperations) {
HttpServerOperations ops = (HttpServerOperations) channelOps;
recorder.recordDataSentTime(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ public void handlerAdded(ChannelHandlerContext ctx) {
public void handlerRemoved(ChannelHandlerContext ctx) {
}

@SuppressWarnings("deprecation")
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ctx.pipeline().remove(this);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/reactor/netty/tcp/TcpServerBind.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ final static class ChildObserver implements ConnectionObserver {

@Override
public void onUncaughtException(Connection connection, Throwable error) {
ChannelOperations ops = ChannelOperations.get(connection.channel());
ChannelOperations<?, ?> ops = ChannelOperations.get(connection.channel());
if (ops == null && (error instanceof IOException || AbortedException.isConnectionReset(error))) {
if (log.isDebugEnabled()) {
log.debug(format(connection.channel(), "onUncaughtException(" + connection + ")"), error);
Expand Down