Add more constructors in ClosedChannelException
aayush at ShieldBlaze.com
Tue Jan 24 06:14:28 UTC 2023
Hello JDK Community! 🙂
The current ClosedChannelException does not have any constructors to pass a message. We have to rely on 'initCause(...)' for passing extra messages regarding a ClosedChannelException but it's not a very good practice in my opinion. Because we will have to generate another Exception which will create another brand-new object in the heap and generates a stack trace. And all of this just to pass a simple message for ClosedChannelException.
When we log ClosedChannelException, we get something like this in our loggers:
Honestly, it's not helpful at all. Netty suffers from this same problem but we have added a new suppressed Stackless exception in ClosedChannelException which will help us give more context to users about the exception but this is really a workaround.
In my opinion, we can add extra constructors in ClosedChannelException which will accept messages and we can have a good exception at the end.
I'd like to have everyone's opinion on this and see how we can tackle this.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the discuss