cshannon commented on code in PR #2474:
URL: https://github.com/apache/activemq/pull/2474#discussion_r3822292548
##########
activemq-client/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java:
##########
@@ -613,26 +613,36 @@ public void stop() throws Exception {
}
protected void initializeStreams() throws Exception {
+ // receiveCounter feeds AbstractInactivityMonitor.readCheck() so only
increment when there is data read
TcpBufferedInputStream buffIn = new
TcpBufferedInputStream(socket.getInputStream(), ioBufferSize) {
@Override
public int read() throws IOException {
- receiveCounter.incrementAndGet();
- return super.read();
+ int result = super.read();
+ if (result > 0) {
+ receiveCounter.incrementAndGet();
+ }
+ return result;
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
- receiveCounter.incrementAndGet();
- return super.read(b, off, len);
+ int result = super.read(b, off, len);
+ if (result > 0) {
+ receiveCounter.incrementAndGet();
Review Comment:
So it would be "more" correct here to add the actual bytes received, which
the other NIO transports do. We could change this but it doesn't matter much
either way. This value is only used to detect if data is received and the
inactivity monitor just does a != check to see if the old value is different
than the new value so the exact bytes don't matter.
In fact, this value is actually an integer so it likely overflows if there's
a lot of data but going negative is not an issue in this case and it just wraps
around and is fine.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact