|
1 | 1 | /*
|
2 |
| - * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1997, 2025 Oracle and/or its affiliates. All rights reserved. |
3 | 3 | *
|
4 | 4 | * This program and the accompanying materials are made available under the
|
5 | 5 | * terms of the Eclipse Public License v. 2.0, which is available at
|
|
29 | 29 | import jakarta.mail.Multipart;
|
30 | 30 | import jakarta.mail.Session;
|
31 | 31 | import jakarta.mail.util.LineOutputStream;
|
32 |
| -import jakarta.mail.util.StreamProvider; |
33 | 32 |
|
34 | 33 | import java.io.BufferedInputStream;
|
35 | 34 | import java.io.ByteArrayInputStream;
|
|
45 | 44 | import java.util.Enumeration;
|
46 | 45 | import java.util.List;
|
47 | 46 | import java.util.Properties;
|
48 |
| -import java.util.ServiceConfigurationError; |
49 |
| - |
50 | 47 |
|
51 | 48 | /**
|
52 | 49 | * This class represents a MIME style email message. It implements
|
@@ -245,7 +242,7 @@ public MimeMessage(MimeMessage source) throws MessagingException {
|
245 | 242 | strict = source.strict;
|
246 | 243 | source.writeTo(bos);
|
247 | 244 | bos.close();
|
248 |
| - try (InputStream bis = provider().inputSharedByteArray(bos.toByteArray())) { |
| 245 | + try (InputStream bis = getStreamProvider().inputSharedByteArray(bos.toByteArray())) { |
249 | 246 | parse(bis);
|
250 | 247 | }
|
251 | 248 | saved = true;
|
@@ -1410,7 +1407,7 @@ protected InputStream getContentStream() throws MessagingException {
|
1410 | 1407 | if (contentStream != null)
|
1411 | 1408 | return ((SharedInputStream) contentStream).newStream(0, -1);
|
1412 | 1409 | if (content != null) {
|
1413 |
| - return provider().inputSharedByteArray(content); |
| 1410 | + return getStreamProvider().inputSharedByteArray(content); |
1414 | 1411 | }
|
1415 | 1412 | throw new MessagingException("No MimeMessage content");
|
1416 | 1413 | }
|
@@ -1917,7 +1914,7 @@ public void writeTo(OutputStream os, String[] ignoreList)
|
1917 | 1914 | // Else, the content is untouched, so we can just output it
|
1918 | 1915 | // First, write out the header
|
1919 | 1916 | Enumeration<String> hdrLines = getNonMatchingHeaderLines(ignoreList);
|
1920 |
| - LineOutputStream los = provider().outputLineStream(os, allowutf8); |
| 1917 | + LineOutputStream los = getStreamProvider().outputLineStream(os, allowutf8); |
1921 | 1918 | while (hdrLines.hasMoreElements())
|
1922 | 1919 | los.writeln(hdrLines.nextElement());
|
1923 | 1920 |
|
@@ -2322,23 +2319,4 @@ protected MimeMessage createMimeMessage(Session session)
|
2322 | 2319 | throws MessagingException {
|
2323 | 2320 | return new MimeMessage(session);
|
2324 | 2321 | }
|
2325 |
| - |
2326 |
| - private StreamProvider provider() throws MessagingException { |
2327 |
| - try { |
2328 |
| - try { |
2329 |
| - final Session s = this.session; |
2330 |
| - if (s != null) { |
2331 |
| - return s.getStreamProvider(); |
2332 |
| - } else { |
2333 |
| - return Session.getDefaultInstance(System.getProperties(), |
2334 |
| - null).getStreamProvider(); |
2335 |
| - } |
2336 |
| - } catch (ServiceConfigurationError sce) { |
2337 |
| - throw new IllegalStateException(sce); |
2338 |
| - } |
2339 |
| - } catch (RuntimeException re) { |
2340 |
| - throw new MessagingException("Unable to get " |
2341 |
| - + StreamProvider.class.getName(), re); |
2342 |
| - } |
2343 |
| - } |
2344 | 2322 | }
|
0 commit comments