Skip to content

Commit

Permalink
[pegasus] Logs a warning if maxResponseSize greater than max int is s…
Browse files Browse the repository at this point in the history
…et to the HttpNettyChannelPoolFactory

RB=1005059
G=si-core-reviewers
R=fcapponi
A=dhoa,fcapponi
  • Loading branch information
ssheng committed Jul 14, 2017
1 parent 827891e commit c2d44a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,5 +1,7 @@
12.0.2
------
(RB=1005059)
Logs a warning if maxResponseSize greater than max int is set to the HttpNettyChannelPoolFactory

12.0.1
------
Expand Down
Expand Up @@ -23,6 +23,8 @@
import io.netty.channel.nio.NioEventLoopGroup;

import java.util.concurrent.ScheduledExecutorService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
Expand All @@ -33,6 +35,8 @@
*/
public class ChannelPoolManagerFactory
{
private static final Logger LOG = LoggerFactory.getLogger(ChannelPoolManagerFactory.class);

private final NioEventLoopGroup _eventLoopGroup;
private final ScheduledExecutorService _scheduler;
private final ChannelPoolManagerKey _channelPoolManagerKey;
Expand All @@ -55,6 +59,15 @@ public ChannelPoolManager buildRest()
{
DefaultChannelGroup channelGroup = new DefaultChannelGroup("R2 client channels", _eventLoopGroup.next());

// Logs a warning if the configured max response size exceeds the maximum integer value. Only the lower 32-bit
// of the long will be taken during the cast, potentially setting erroneous max response size.
if (_channelPoolManagerKey.getMaxResponseSize() > Integer.MAX_VALUE)
{
LOG.warn("The configured max response size {} has exceeded the max value allowed {} for the HTTP Rest client. "
+ "Consider using the streaming implementation instead.",
_channelPoolManagerKey.getMaxResponseSize(), Integer.MAX_VALUE);
}

return new ChannelPoolManager(
new HttpNettyChannelPoolFactory(
_channelPoolManagerKey.getMaxPoolSize(),
Expand Down

0 comments on commit c2d44a8

Please sign in to comment.