diff --git a/api/src/main/java/jakarta/mail/BodyPart.java b/api/src/main/java/jakarta/mail/BodyPart.java index 876a2214..77ec3c2f 100644 --- a/api/src/main/java/jakarta/mail/BodyPart.java +++ b/api/src/main/java/jakarta/mail/BodyPart.java @@ -69,7 +69,7 @@ void setParent(Multipart parent) { } @Override - public StreamProvider getStreamProvider() throws MessagingException { + public StreamProvider getStreamProvider() throws NoSuchProviderException { if (parent != null) { return parent.getStreamProvider(); } else { diff --git a/api/src/main/java/jakarta/mail/Message.java b/api/src/main/java/jakarta/mail/Message.java index f6dd263c..e1f915d6 100644 --- a/api/src/main/java/jakarta/mail/Message.java +++ b/api/src/main/java/jakarta/mail/Message.java @@ -709,7 +709,7 @@ public boolean match(SearchTerm term) throws MessagingException { } @Override - public StreamProvider getStreamProvider() throws MessagingException { + public StreamProvider getStreamProvider() throws NoSuchProviderException { try { try { final Session s = this.session; @@ -722,7 +722,7 @@ public StreamProvider getStreamProvider() throws MessagingException { throw new IllegalStateException(sce); } } catch (RuntimeException re) { - throw new MessagingException("Unable to get " + StreamProvider.class.getName(), re); + throw new NoSuchProviderException("Unable to get " + StreamProvider.class.getName(), re); } } } diff --git a/api/src/main/java/jakarta/mail/Multipart.java b/api/src/main/java/jakarta/mail/Multipart.java index 73083e44..18750a24 100644 --- a/api/src/main/java/jakarta/mail/Multipart.java +++ b/api/src/main/java/jakarta/mail/Multipart.java @@ -267,11 +267,11 @@ public synchronized void setParent(Part parent) { * {@link Session#getDefaultInstance(java.util.Properties, Authenticator)}. * * @return the StreamProvider implementation from the session. - * @throws MessagingException if errors. + * @throws NoSuchProviderException if errors. * * @since JavaMail 2.2 */ - protected StreamProvider getStreamProvider() throws MessagingException { + protected StreamProvider getStreamProvider() throws NoSuchProviderException { Part parent = this.parent; if (parent != null) { return parent.getStreamProvider(); @@ -283,7 +283,7 @@ protected StreamProvider getStreamProvider() throws MessagingException { throw new IllegalStateException(sce); } } catch (RuntimeException re) { - throw new MessagingException("Unable to get " + StreamProvider.class.getName(), re); + throw new NoSuchProviderException("Unable to get " + StreamProvider.class.getName(), re); } } } diff --git a/api/src/main/java/jakarta/mail/Part.java b/api/src/main/java/jakarta/mail/Part.java index 4a18e28c..612e28ec 100644 --- a/api/src/main/java/jakarta/mail/Part.java +++ b/api/src/main/java/jakarta/mail/Part.java @@ -461,11 +461,11 @@ Enumeration
getNonMatchingHeaders(String[] header_names) * It defaults to {@link Session#getDefaultInstance(java.util.Properties, Authenticator)}. * * @return the StreamProvider. - * @throws MessagingException if errors. + * @throws NoSuchProviderException if errors. * * @since JavaMail 2.2 */ - default StreamProvider getStreamProvider() throws MessagingException { + default StreamProvider getStreamProvider() throws NoSuchProviderException { try { try { return Session.getDefaultInstance(System.getProperties(), null).getStreamProvider(); @@ -473,7 +473,7 @@ default StreamProvider getStreamProvider() throws MessagingException { throw new IllegalStateException(sce); } } catch (RuntimeException re) { - throw new MessagingException("Unable to get " + StreamProvider.class.getName(), re); + throw new NoSuchProviderException("Unable to get " + StreamProvider.class.getName(), re); } } }