I need to be able to add and remove the IdleStateHandler on the pipeline based on certain conditions. I create one instance of IdleStateHandler per channel and save the reference to that instance in a connection class.
However when I remove the handler and then add it back, I get an exception that the handler cannot be added multiple times because it is not Sharable.
I understand not being able to share the same handler across multiple channels. However, in my case, the handler instance is unique to each channel. Why would this require the handler to be sharable? Are there any workarounds for this? I know I can create a new instance each time, but we are trying to reduce the number of new objects we create.