You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
MimeMessage class has addHeader and removeHeader functions that throw MessagingException. But the underlying function does not throw these exceptions. This causes the callers to unnecessarily catch and discard the MessagingException or throw it back to callers.
Describe the solution you'd like
Java allows sub classes to remove checked exceptions on overridden methods. Can we remove MessagingException on addHeader and removeHeader?
Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered:
Removing the throws MessagingException from addHeader/removeHeader of MimeMessage is not possible due to IMAPMessage and POP3Messaging extending MimeMessage and overriding those functions to throw a checked exception.
Some possible alternatives are:
Add new public methods to MimeMessage that can add and remove headers that doesn't throw checked exceptions. It might have to declare some new type of unchecked exception.
Add a getter to expose the internal jakarta.mail.internet.InternetHeaders. This object has getHeader/removeHeader calls that doesn't throw checked exceptions. However, some more thought is needed to determine how to handle read only messages. Also need to determine if exposing this causes more issues than it solves.
Modify SMTPMessage override addHeader/removeHeader in the way you describe. Unfortunately, this was not done when the class was created so changing this compatibility issue. It still might be possible to modify this class instead of the larger MimeMessage.
Is your feature request related to a problem? Please describe.
MimeMessage class has addHeader and removeHeader functions that throw MessagingException. But the underlying function does not throw these exceptions. This causes the callers to unnecessarily catch and discard the MessagingException or throw it back to callers.
Describe the solution you'd like
Java allows sub classes to remove checked exceptions on overridden methods. Can we remove MessagingException on addHeader and removeHeader?
Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: