Skip to content

Commit f892d46

Browse files
committed
Merge with master
Signed-off-by: Jorge Bescos Gascon <[email protected]>
2 parents 98cb55e + fedabff commit f892d46

20 files changed

+384
-86
lines changed

.github/workflows/maven.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2021 Contributors to the Eclipse Foundation
2+
# Copyright (c) 2021, 2022 Contributors to the Eclipse Foundation
33
#
44
# This program and the accompanying materials are made available under the
55
# terms of the Eclipse Public License v. 2.0 which is available at
@@ -42,4 +42,4 @@ jobs:
4242
- name: Verify
4343
run: |
4444
cd api
45-
mvn -B -U -C -V clean verify org.glassfish.copyright:glassfish-copyright-maven-plugin:check -Poss-release,staging -Dgpg.skip=true
45+
mvn -B -U -C -V clean verify org.glassfish.copyright:glassfish-copyright-maven-plugin:check -Poss-release,staging -Dcopyright.ignoreyear=true -Dgpg.skip=true

Jenkinsfile

+10-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ spec:
1919
- "james.local"
2020
containers:
2121
- name: mail-ci
22-
image: jakartaee/cts-javamail-base:0.1
22+
image: jakartaee/cts-javamail-base:0.3
2323
command:
2424
- cat
2525
tty: true
@@ -49,11 +49,17 @@ spec:
4949
}
5050
parameters {
5151
string(name: 'JAF_BUNDLE_URL',
52-
defaultValue: 'https://repo1.maven.org/maven2/com/sun/activation/jakarta.activation/2.0.0-RC3/jakarta.activation-2.0.0-RC3.jar',
52+
defaultValue: 'https://repo1.maven.org/maven2/jakarta/activation/jakarta.activation-api/2.1.0/jakarta.activation-api-2.1.0.jar',
53+
description: 'URL required for downloading JAF API jar' )
54+
string(name: 'ANGUS_JAF_BUNDLE_URL',
55+
defaultValue: 'https://repo1.maven.org/maven2/org/eclipse/angus/angus-activation/1.0.0/angus-activation-1.0.0.jar',
5356
description: 'URL required for downloading JAF implementation jar' )
5457
string(name: 'MAIL_TCK_BUNDLE_URL',
5558
defaultValue: 'https://ci.eclipse.org/mail/job/mail-tck/job/2.0.0/lastSuccessfulBuild/artifact/bundles/mail-tck-2.0.0-rc1.zip',
5659
description: 'URL required for downloading Jakarta Mail TCK zip' )
60+
string(name: 'ANGUS_MAIL_BUNDLE_URL',
61+
defaultValue: 'https://repo1.maven.org/maven2/org/eclipse/angus/angus-mail/1.0.0/angus-mail-1.0.0.jar',
62+
description: 'URL required for downloading Angus Mail jar' )
5763
}
5864
environment {
5965
ANT_OPTS = "-Djavax.xml.accessExternalStylesheet=all -Djavax.xml.accessExternalSchema=all -Djavax.xml.accessExternalDTD=file,http"
@@ -71,8 +77,8 @@ spec:
7177
cd ..
7278
bash -x ${WORKSPACE}/docker/build_jakartamail.sh
7379
"""
74-
archiveArtifacts artifacts: 'mail/target/*.jar'
75-
stash includes: 'mail/target/*.jar', name: 'mail-bundles'
80+
archiveArtifacts artifacts: '**/target/*.jar'
81+
stash includes: '**/target/*.jar', name: 'mail-bundles'
7682
}
7783
}
7884
}

api/pom.xml

+20-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<modelVersion>4.0.0</modelVersion>
3131
<groupId>jakarta.mail</groupId>
3232
<artifactId>jakarta.mail-api</artifactId>
33-
<version>2.1.0-SNAPSHOT</version>
33+
<version>2.1.1-SNAPSHOT</version>
3434
<name>Jakarta Mail API</name>
3535
<description>${project.name} ${spec.version} Specification API</description>
3636

@@ -78,15 +78,20 @@
7878
<spotbugs.threshold>Low</spotbugs.threshold>
7979
<spotbugs.exclude>${project.basedir}/../spotbugs-exclude.xml</spotbugs.exclude>
8080
<!--Maven plugins version-->
81-
<spotbugs.version>4.3.0</spotbugs.version>
81+
<spotbugs.version>4.4.2.2</spotbugs.version>
8282
</properties>
8383

8484
<dependencyManagement>
8585
<dependencies>
8686
<dependency>
8787
<groupId>jakarta.activation</groupId>
8888
<artifactId>jakarta.activation-api</artifactId>
89-
<version>2.1.0-RC1</version>
89+
<version>2.1.0</version>
90+
</dependency>
91+
<dependency>
92+
<groupId>org.eclipse.angus</groupId>
93+
<artifactId>angus-activation</artifactId>
94+
<version>1.0.0-M2</version>
9095
</dependency>
9196
<dependency>
9297
<groupId>junit</groupId>
@@ -106,6 +111,11 @@
106111
<artifactId>junit</artifactId>
107112
<scope>test</scope>
108113
</dependency>
114+
<dependency>
115+
<groupId>org.eclipse.angus</groupId>
116+
<artifactId>angus-activation</artifactId>
117+
<scope>test</scope>
118+
</dependency>
109119
</dependencies>
110120

111121
<build>
@@ -143,7 +153,6 @@
143153
<configuration>
144154
<skip>${spotbugs.skip}</skip>
145155
<threshold>${spotbugs.threshold}</threshold>
146-
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
147156
<excludeFilterFile>${spotbugs.exclude}</excludeFilterFile>
148157
<fork>true</fork>
149158
</configuration>
@@ -176,7 +185,7 @@
176185
<plugin>
177186
<groupId>org.apache.maven.plugins</groupId>
178187
<artifactId>maven-javadoc-plugin</artifactId>
179-
<version>3.3.0</version>
188+
<version>3.3.1</version>
180189
</plugin>
181190
<plugin>
182191
<groupId>org.apache.maven.plugins</groupId>
@@ -350,6 +359,10 @@
350359
<Implementation-Title>${project.name}</Implementation-Title>
351360
<Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
352361
<Implementation-Build-Id>${buildNumber}</Implementation-Build-Id>
362+
<Import-Package>
363+
!org.glassfish.hk2.osgiresourcelocator,
364+
*
365+
</Import-Package>
353366
</instructions>
354367
</configuration>
355368
<executions>
@@ -379,6 +392,7 @@
379392
<artifactId>maven-javadoc-plugin</artifactId>
380393
<configuration>
381394
<release>11</release>
395+
<quiet>true</quiet>
382396
<nodeprecated>false</nodeprecated>
383397
<notimestamp>true</notimestamp>
384398
<nosince>true</nosince>
@@ -404,8 +418,7 @@ Use is subject to <a href="{@docRoot}/doc-files/speclicense.html" target="_top">
404418
<configuration>
405419
<forkCount>2</forkCount>
406420
<reuseForks>false</reuseForks>
407-
<!-- Test service loader is not loaded if modules are enabled -->
408-
<useModulePath>false</useModulePath>
421+
<trimStackTrace>false</trimStackTrace>
409422
</configuration>
410423
</plugin>
411424
<plugin>

api/src/main/java/jakarta/mail/BodyPart.java

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package jakarta.mail;
1818

19+
import jakarta.mail.util.StreamProvider;
20+
1921
/**
2022
* This class models a Part that is contained within a Multipart.
2123
* This is an abstract class. Subclasses provide actual implementations.<p>
@@ -36,6 +38,13 @@ public abstract class BodyPart implements Part {
3638
*/
3739
protected Multipart parent;
3840

41+
/**
42+
* Instance of stream provider.
43+
*
44+
* @since JavaMail 2.1
45+
*/
46+
protected final StreamProvider streamProvider = StreamProvider.provider();
47+
3948
/**
4049
* Creates a default {@code BodyPart}.
4150
*/

api/src/main/java/jakarta/mail/Multipart.java

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.OutputStream;
2222
import java.io.IOException;
2323
import jakarta.activation.DataSource;
24+
import jakarta.mail.util.StreamProvider;
2425

2526
/**
2627
* Multipart is a container that holds multiple body parts. Multipart
@@ -60,6 +61,13 @@ public abstract class Multipart {
6061
*/
6162
protected Part parent;
6263

64+
/**
65+
* Instance of stream provider.
66+
*
67+
* @since JavaMail 2.1
68+
*/
69+
protected final StreamProvider streamProvider = StreamProvider.provider();
70+
6371
/**
6472
* Default constructor. An empty Multipart object is created.
6573
*/

api/src/main/java/jakarta/mail/Session.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import java.util.Collections;
3636
import java.util.HashMap;
3737
import java.util.Hashtable;
38-
import java.util.Iterator;
3938
import java.util.List;
4039
import java.util.Map;
4140
import java.util.Properties;
@@ -203,8 +202,8 @@ public final class Session {
203202

204203
// Support legacy @DefaultProvider
205204
private static final String DEFAULT_PROVIDER = "com.sun.mail.util.DefaultProvider";
206-
public static final StreamProvider STREAM_PROVIDER;
207205

206+
private final StreamProvider streamProvider;
208207
private final Properties props;
209208
private final Authenticator authenticator;
210209
private final Hashtable<URLName, PasswordAuthentication> authTable
@@ -246,13 +245,13 @@ public String run() {
246245
// ignore any exceptions
247246
}
248247
confDir = dir;
249-
STREAM_PROVIDER = getStreamProvider();
250248
}
251249

252250
// Constructor is not public
253251
private Session(Properties props, Authenticator authenticator) {
254252
this.props = props;
255253
this.authenticator = authenticator;
254+
this.streamProvider = StreamProvider.provider();
256255

257256
if (Boolean.valueOf(props.getProperty("mail.debug")).booleanValue())
258257
debug = true;
@@ -272,14 +271,15 @@ private Session(Properties props, Authenticator authenticator) {
272271
q = new EventQueue((Executor)props.get("mail.event.executor"));
273272
}
274273

275-
private static StreamProvider getStreamProvider() {
276-
ServiceLoader<StreamProvider> sl = ServiceLoader.load(StreamProvider.class);
277-
Iterator<StreamProvider> iter = sl.iterator();
278-
if (iter.hasNext()) {
279-
return iter.next();
280-
} else {
281-
throw new IllegalStateException("Not provider of " + StreamProvider.class.getName() + " was found");
282-
}
274+
/**
275+
* Get the stream provider instance of the session.
276+
*
277+
* @return the stream provider
278+
*
279+
* @since JavaMail 2.1
280+
*/
281+
public StreamProvider getStreamProvider() {
282+
return streamProvider;
283283
}
284284

285285
private final synchronized void initLogger() {
@@ -1036,7 +1036,7 @@ public void load(InputStream is) throws IOException {
10361036

10371037
private void loadProvidersFromStream(InputStream is) throws IOException {
10381038
if (is != null) {
1039-
LineInputStream lis = Session.STREAM_PROVIDER.inputLineStream(is, false);
1039+
LineInputStream lis = streamProvider.inputLineStream(is, false);
10401040
String currLine;
10411041

10421042
// load and process one line at a time using LineInputStream

api/src/main/java/jakarta/mail/internet/InternetHeaders.java

+6-9
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,19 @@
1616

1717
package jakarta.mail.internet;
1818

19-
import jakarta.mail.Header;
20-
import jakarta.mail.MessagingException;
21-
import jakarta.mail.Session;
22-
import jakarta.mail.util.LineInputStream;
23-
import jakarta.mail.util.StreamProvider;
24-
2519
import java.io.IOException;
2620
import java.io.InputStream;
2721
import java.util.ArrayList;
2822
import java.util.Enumeration;
29-
import java.util.HashMap;
3023
import java.util.Iterator;
3124
import java.util.List;
32-
import java.util.Map;
3325
import java.util.NoSuchElementException;
3426

27+
import jakarta.mail.Header;
28+
import jakarta.mail.MessagingException;
29+
import jakarta.mail.util.LineInputStream;
30+
import jakarta.mail.util.StreamProvider;
31+
3532

3633

3734
/**
@@ -407,7 +404,7 @@ public void load(InputStream is, boolean allowutf8)
407404
// Read header lines until a blank line. It is valid
408405
// to have BodyParts with no header lines.
409406
String line;
410-
LineInputStream lis = Session.STREAM_PROVIDER.inputLineStream(is, allowutf8);
407+
LineInputStream lis = StreamProvider.provider().inputLineStream(is, allowutf8);
411408
String prevline = null; // the previous header line, as a string
412409
// a buffer to accumulate the header in, when we know it's needed
413410
StringBuilder lineBuffer = new StringBuilder();

api/src/main/java/jakarta/mail/internet/MimeBodyPart.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ static void writeTo(MimePart part, OutputStream os, String[] ignoreList, boolean
16931693
} else {
16941694
Map<String, Object> params = new HashMap<>();
16951695
params.put("allowutf8", allowutf8);
1696-
los = Session.STREAM_PROVIDER.outputLineStream(os, allowutf8);
1696+
los = StreamProvider.provider().outputLineStream(os, allowutf8);
16971697
}
16981698

16991699
// First, write out the header

api/src/main/java/jakarta/mail/internet/MimeMessage.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public MimeMessage(MimeMessage source) throws MessagingException {
258258
strict = source.strict;
259259
source.writeTo(bos);
260260
bos.close();
261-
InputStream bis = Session.STREAM_PROVIDER.inputSharedByteArray(bos.toByteArray());
261+
InputStream bis = session.getStreamProvider().inputSharedByteArray(bos.toByteArray());
262262
parse(bis);
263263
bis.close();
264264
saved = true;
@@ -1425,7 +1425,7 @@ protected InputStream getContentStream() throws MessagingException {
14251425
if (contentStream != null)
14261426
return ((SharedInputStream)contentStream).newStream(0, -1);
14271427
if (content != null) {
1428-
return Session.STREAM_PROVIDER.inputSharedByteArray(content);
1428+
return session.getStreamProvider().inputSharedByteArray(content);
14291429
}
14301430
throw new MessagingException("No MimeMessage content");
14311431
}
@@ -1932,7 +1932,7 @@ public void writeTo(OutputStream os, String[] ignoreList)
19321932
// Else, the content is untouched, so we can just output it
19331933
// First, write out the header
19341934
Enumeration<String> hdrLines = getNonMatchingHeaderLines(ignoreList);
1935-
LineOutputStream los = Session.STREAM_PROVIDER.outputLineStream(os, allowutf8Headers);
1935+
LineOutputStream los = session.getStreamProvider().outputLineStream(os, allowutf8Headers);
19361936
while (hdrLines.hasMoreElements())
19371937
los.writeln(hdrLines.nextElement());
19381938

api/src/main/java/jakarta/mail/internet/MimeMultipart.java

+10-12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616

1717
package jakarta.mail.internet;
1818

19+
import java.io.BufferedInputStream;
20+
import java.io.ByteArrayInputStream;
21+
import java.io.ByteArrayOutputStream;
22+
import java.io.EOFException;
23+
import java.io.IOException;
24+
import java.io.InputStream;
25+
import java.io.OutputStream;
26+
1927
import jakarta.activation.DataSource;
2028
import jakarta.mail.BodyPart;
2129
import jakarta.mail.IllegalWriteException;
@@ -25,18 +33,8 @@
2533
import jakarta.mail.Multipart;
2634
import jakarta.mail.MultipartDataSource;
2735
import jakarta.mail.Session;
28-
import jakarta.mail.internet.MimeUtility;
2936
import jakarta.mail.util.LineInputStream;
3037
import jakarta.mail.util.LineOutputStream;
31-
import jakarta.mail.util.StreamProvider;
32-
33-
import java.io.BufferedInputStream;
34-
import java.io.ByteArrayInputStream;
35-
import java.io.ByteArrayOutputStream;
36-
import java.io.EOFException;
37-
import java.io.IOException;
38-
import java.io.InputStream;
39-
import java.io.OutputStream;
4038

4139

4240

@@ -524,7 +522,7 @@ public synchronized void writeTo(OutputStream os)
524522

525523
String boundary = "--" +
526524
(new ContentType(contentType)).getParameter("boundary");
527-
LineOutputStream los = Session.STREAM_PROVIDER.outputLineStream(os, false);
525+
LineOutputStream los = streamProvider.outputLineStream(os, false);
528526
// if there's a preamble, write it out
529527
if (preamble != null) {
530528
byte[] pb = MimeUtility.getBytes(preamble);
@@ -605,7 +603,7 @@ protected synchronized void parse() throws MessagingException {
605603

606604
try {
607605
// Skip and save the preamble
608-
LineInputStream lin = Session.STREAM_PROVIDER.inputLineStream(in, false);
606+
LineInputStream lin = streamProvider.inputLineStream(in, false);
609607
StringBuilder preamblesb = null;
610608
String line;
611609
while ((line = lin.readLine()) != null) {

0 commit comments

Comments
 (0)