Actually, I don't think there's a real problem here: the ByteBuffer passed from either Netty and Grizzly providers is a freshly allocated one, so remaining equals capacity. Also, it cannot be negative (it's the chunk size).