<?xml version="1.0" encoding="UTF-8"?>
<!--

    DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

    Copyright (c) 2010-2017 Oracle and/or its affiliates. All rights reserved.

    The contents of this file are subject to the terms of either the GNU
    General Public License Version 2 only ("GPL") or the Common Development
    and Distribution License("CDDL") (collectively, the "License").  You
    may not use this file except in compliance with the License.  You can
    obtain a copy of the License at
    https://oss.oracle.com/licenses/CDDL+GPL-1.1
    or LICENSE.txt.  See the License for the specific
    language governing permissions and limitations under the License.

    When distributing the software, include this License Header Notice in each
    file and include the License file at LICENSE.txt.

    GPL Classpath Exception:
    Oracle designates this particular file as subject to the "Classpath"
    exception as provided by Oracle in the GPL Version 2 section of the License
    file that accompanied this code.

    Modifications:
    If applicable, add the following below the License Header, with the fields
    enclosed by brackets [] replaced by your own identifying information:
    "Portions Copyright [year] [name of copyright owner]"

    Contributor(s):
    If you wish your version of this file to be governed by only the CDDL or
    only the GPL Version 2, indicate your decision by adding "[Contributor]
    elects to include this software in this distribution under the [CDDL or GPL
    Version 2] license."  If you don't indicate a single choice of license, a
    recipient has the option to distribute your version of this file under
    either the CDDL, the GPL Version 2 or to extend the choice of license to
    its licensees as provided above.  However, if you add GPL Version 2 code
    and therefore, elected the GPL Version 2 license, then the option applies
    only if the new code is made subject to such option by the copyright
    holder.

-->

<!-- FindBugs exclude list for JavaMail -->

<FindBugsFilter>
    <!--
	FindBugs *really* wants us to use zero length arrays instead
	of null.  Unfortunately, there's a bunch of places we can't
	do this for various reasons:
	  - The API specifies null and we can't make an incompatible change.
	  - We use null to indicate no header and an empty array to indicate
	    the header exists but has no entries.
	  - We use null to indicate NIL in the protocol and an empty array
	    to indicate an empty list "()" in the protocol.
	This error occurs often enough that we just ignore it everywhere.
    -->
    <Match>
	<Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
    </Match>
    <!--
	There are a bunch of places where FindBugs complains about
	exposing internal representations.  We exclude cases where
	this only happens in internal classes that are never visible
	through the public JavaMail API, or cases where the user
	passes in an object (usually an array) and can only hurt
	themselves by modifying the array while a method is in progress,
	or where the implementation is passing the data back to the user
	(e.g., in an Exception) and never uses it again.
    -->
    <Match>
	<Or>
	    <Class name="javax.mail.SendFailedException"/>
	    <Class name="javax.mail.event.MessageCountEvent"/>
	    <Class name="javax.mail.event.TransportEvent"/>
	    <Class name="com.sun.mail.iap.ByteArray"/>
	    <Class name="com.sun.mail.imap.MessageVanishedEvent"/>
	    <Class name="com.sun.mail.imap.protocol.FetchResponse"/>
	</Or>
	<Or>
	    <Bug pattern="EI_EXPOSE_REP"/>
	    <Bug pattern="EI_EXPOSE_REP2"/>
	</Or>
    </Match>
    <Match>
	<Class name="com.sun.mail.smtp.SMTPTransport"/>
	<Method name="sendMessage"/>
	<!-- passed in Address array -->
	<Bug pattern="EI_EXPOSE_REP2"/>
    </Match>
    <Match>
	<Class name="javax.mail.internet.MimeBodyPart"/>
	<Method name="&lt;init&gt;"/> <!-- match constructor -->
	<!-- passed in byte array -->
	<Bug pattern="EI_EXPOSE_REP2"/>
    </Match>
    <Match>
	<Class name="javax.mail.util.ByteArrayDataSource"/>
	<Method name="&lt;init&gt;"/> <!-- match constructor -->
	<!-- passed in byte array -->
	<Bug pattern="EI_EXPOSE_REP2"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.util.MailSSLSocketFactory"/>
	<Method name="setTrustManagers"/>
	<!-- passed in TrustManager array -->
	<Bug pattern="EI_EXPOSE_REP2"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.util.MailSSLSocketFactory"/>
	<Method name="getTrustManagers"/>
	<!-- returned TrustManager array -->
	<Bug pattern="EI_EXPOSE_REP"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.imap.protocol.INTERNALDATE"/>
	<Method name="getDate"/>
	<!--
	    Returned Date object; it's only ever stored in
	    IMAPMessage.receivedDate and is always used to
	    construct a new Date object before returning to
	    users.
	-->
	<Bug pattern="EI_EXPOSE_REP"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.imap.CopyUID"/>
	<Method name="&lt;init&gt;"/> <!-- match constructor -->
	<Bug pattern="EI_EXPOSE_REP2"/>
    </Match>

    <!--
	A few places where it complains about wait not being in a loop.
	This purposely doesn't loop so that the application
	calling idle can check whether the idle should continue.
    -->
    <Match>
	<!-- an anonymous inner class of the idle method -->
	<Class name="~com\.sun\.mail\.imap\.IMAPFolder.*"/>
	<Method name="doCommand"/>
	<Bug pattern="WA_NOT_IN_LOOP"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.imap.IMAPStore"/>
	<Method name="idle"/>
	<Bug pattern="WA_NOT_IN_LOOP"/>
    </Match>

    <!--
	A few places where we catch Exception even though it's not
	explicitly thrown.  We need to make sure that if anything
	goes wrong we clean things up.  Perhaps these should be
	converted to a finally block and a boolean "success" flag?
	Most of these are related to reflection or ClassLoader
	operations, which can fail for all sorts of unexpected reasons.
	Some of these could be converted to use multi-catch with JDK 1.7.
    -->
    <Match>
	<Class name="com.sun.mail.imap.IMAPStore"/>
	<Or>
	    <Method name="&lt;init&gt;"/> <!-- match constructor -->
	    <Method name="getProtocol"/>
	    <Method name="getStoreProtocol"/>
	    <Method name="newIMAPFolder"/>
	</Or>
	<Bug pattern="REC_CATCH_EXCEPTION"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.imap.protocol.IMAPProtocol"/>
	<Or>
	    <Method name="authlogin"/>
	    <Method name="authntlm"/>
	    <Method name="authplain"/>
	    <Method name="authoauth2"/>
	    <Method name="sasllogin"/>
	</Or>
	<Bug pattern="REC_CATCH_EXCEPTION"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.imap.protocol.IMAPSaslAuthenticator"/>
	<Method name="authenticate"/>
	<Bug pattern="REC_CATCH_EXCEPTION"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.pop3.POP3Store"/>
	<Method name="&lt;init&gt;"/> <!-- match constructor -->
	<Bug pattern="REC_CATCH_EXCEPTION"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.smtp.SMTPTransport"/>
	<Or>
	    <Method name="isConnected"/>
	    <Method name="sasllogin"/>
	</Or>
	<Bug pattern="REC_CATCH_EXCEPTION"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.pop3.POP3Folder"/>
	<Method name="createMessage"/>
	<Or>
	    <Bug pattern="REC_CATCH_EXCEPTION"/>
	    <Bug pattern="DE_MIGHT_IGNORE"/>
	</Or>
    </Match>
    <Match>
	<Class name="com.sun.mail.util.SocketFetcher"/>
	<Or>
	    <Method name="getSocket"/>
	    <Method name="startTLS"/>
	    <Method name="matchCert"/>
	</Or>
	<Bug pattern="REC_CATCH_EXCEPTION"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.util.MimeUtil"/>
	<Method name="cleanContentType"/>
	<Bug pattern="REC_CATCH_EXCEPTION"/>
    </Match>
    <Match>
	<Class name="javax.mail.Session"/>
	<Or>
	    <Method name="getService"/>
	    <Method name="loadAllResources"/>
	</Or>
	<Bug pattern="REC_CATCH_EXCEPTION"/>
    </Match>
    <Match>
	<Class name="javax.mail.internet.MimeUtility"/>
	<Or>
	    <Method name="&lt;clinit&gt;"/> <!-- match static initializer -->
	    <Method name="getEncoding"/>
	</Or>
	<Bug pattern="REC_CATCH_EXCEPTION"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.imap.IMAPFolder"/>
	<Method name="handleIdle"/>
	<Bug pattern="DE_MIGHT_IGNORE"/>
    </Match>

    <!--
	FindBugs complains about a possible double check of headersLoaded,
	but it seems to be just wrong; I don't see it.
    -->
    <Match>
	<Class name="com.sun.mail.imap.IMAPMessage"/>
	<Method name="loadHeaders"/>
	<Bug pattern="DC_DOUBLECHECK"/>
    </Match>

    <!--
	These IMAP-specific subclasses of standard classes don't override
	equals because all they add are constructors and optimized access
	methods; everything else, including the way to test for equality,
	is the same.
    -->
    <Match>
	<Class name="com.sun.mail.imap.protocol.FLAGS"/>
	<Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.imap.protocol.IMAPAddress"/>
	<!-- defined in ENVELOPE.java -->
	<Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS"/>
    </Match>

    <!--
	FindBugs complains of an unitialized read of the "capabilities"
	field.  Since the superclass might initialize the field (via a
	call into the overridden processGreeting method), any initialization
	done in the IMAPProtocol class will undo any initialization done
	as a side effect of calling the superclass constructor.  Thus, we
	need to depend on the field being initialized to the default value.
    -->
    <Match>
	<Class name="com.sun.mail.imap.protocol.IMAPProtocol"/>
	<Method name="&lt;init&gt;"/> <!-- match constructor -->
	<Bug pattern="UR_UNINIT_READ"/>
    </Match>

    <!--
	This use of string concatenation only occurs when creating a
	string for an error message in an exception.  The simpler code
	is better here; performance is not an issue.
    -->
    <Match>
	<Class name="com.sun.mail.util.BASE64DecoderStream"/>
	<Method name="recentChars"/>
	<Bug pattern="SBSC_USE_STRINGBUFFER_CONCATENATION"/>
    </Match>

    <!--
	Yes, the "next" element in my linked list isn't ever actually
	used, but it feels weird to only have a "prev" element.
    -->
    <Match>
	<Class name="javax.mail.EventQueue$QueueElement"/>
	<Field name="next"/>
	<Bug pattern="URF_UNREAD_FIELD"/>
    </Match>

    <!--
	Stupid Serializable EventObject class causes FindBugs to complain
	about transient fields in subclasses.  I don't know why it's
	complaining about these fields but not others, but since I don't
	really expect anyone to serialize these events I'm just ignoring
	this complaint.  Ditto Exception fields.
    -->
    <Match>
	<Class name="javax.mail.event.TransportEvent"/>
	<Or>
	    <Field name="invalid"/>
	    <Field name="validSent"/>
	    <Field name="validUnsent"/>
	</Or>
	<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
    </Match>
    <Match>
	<Class name="javax.mail.event.FolderEvent"/>
	<Or>
	    <Field name="folder"/>
	    <Field name="newFolder"/>
	</Or>
	<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
    </Match>
    <Match>
	<Class name="javax.mail.event.MessageChangedEvent"/>
	<Field name="msg"/>
	<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
    </Match>
    <Match>
	<Class name="javax.mail.event.MessageCountEvent"/>
	<Field name="msgs"/>
	<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
    </Match>
    <Match>
	<Class name="javax.mail.event.TransportEvent"/>
	<Field name="msg"/>
	<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
    </Match>
    <Match>
	<Class name="javax.mail.SendFailedException"/>
	<Or>
	    <Field name="invalid"/>
	    <Field name="validSent"/>
	    <Field name="validUnsent"/>
	</Or>
	<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
    </Match>

    <!--
	These string comparisons are just optimizations.
    -->
    <Match>
	<Or>
	    <Class name="javax.mail.URLName"/>
	    <Class name="javax.mail.internet.InternetAddress"/>
	</Or>
	<Method name="equals"/>
	<Bug pattern="ES_COMPARING_STRINGS_WITH_EQ"/>
    </Match>

    <!--
	This string comparison using == is to determine whether the
	String object is a different String object.
    -->
    <Match>
	<Class name="javax.mail.internet.MimeUtility"/>
	<Method name="decodeText"/>
	<Bug pattern="ES_COMPARING_STRINGS_WITH_EQ"/>
    </Match>

    <!--
	This string comparison using == is to determine whether the
	String object is the original default String object.
    -->
    <Match>
	<Class name="com.sun.mail.smtp.SMTPTransport"/>
	<Method name="authenticate"/>
	<Bug pattern="ES_COMPARING_STRINGS_WITH_EQ"/>
    </Match>

    <!--
	ByteArrayInputStream.available guarantees to return the full number
	of bytes left in the buffer, and ByteArrayInputStream.read guarantees
	to read all the bytes, so we don't really need to check the return
	value.  Ignore this complaint.
    -->
    <Match>
	<Class name="com.sun.mail.util.ASCIIUtility"/>
	<Method name="getBytes"/>
	<Bug pattern="DLS_DEAD_LOCAL_STORE"/>
    </Match>

    <!--
	We extract the "lang" field of an encoded string but we don't
	currently do anything with it.  Ignore this complaint.
    -->
    <Match>
	<Class name="javax.mail.internet.ParameterList"/>
	<Method name="decodeValue"/>
	<Bug pattern="DLS_DEAD_LOCAL_STORE"/>
    </Match>

    <!--
	The call ParameterList.set(null, "DONE") is a kludge used by the
	IMAP provider to indicate that it's done setting parameters.
	In other cases we *want* a null name to cause a NullPointerException.
    -->
    <Match>
	<Class name="javax.mail.internet.ParameterList"/>
	<Method name="set"/>
	<Bug pattern="NP_NULL_ON_SOME_PATH"/>
    </Match>

    <!--
	We purposely don't close these streams, which are just wrappers
	around the original stream that needs to remain open.
    -->
    <Match>
	<Class name="javax.mail.internet.MimeMultipart"/>
	<Or>
	    <Method name="parse"/>
	    <Method name="parsebm"/>
	</Or>
	<Bug pattern="OS_OPEN_STREAM"/>
    </Match>

    <!--
	When deleting the temp file fails, there's really nothing to be done.
    -->
    <Match>
	<Class name="com.sun.mail.pop3.TempFile"/>
	<Method name="close"/>
	<Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE"/>
    </Match>

    <!--
	In IMAPFolder.close, I believe the protocol field can be set to null
	as a result of a protocol error that invokes a callback that calls
	cleanup, thus I don't believe these null checks are redundant.
    -->
    <Match>
	<Class name="com.sun.mail.imap.IMAPFolder"/>
	<Method name="close"/>
	<Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/>
    </Match>

    <!--
	Can't fix these errors in toString until JavaMail 1.5 because
	it's part of the spec.  Sigh.
    -->
    <Match>
	<Or>
	    <Class name="javax.mail.internet.ContentDisposition"/>
	    <Class name="javax.mail.internet.ContentType"/>
	</Or>
	<Method name="toString"/>
	<Bug pattern="NP_TOSTRING_COULD_RETURN_NULL"/>
    </Match>

    <!--
	IMAPFolder.uidTable is only ever manipulated when the
	messageCacheLock is held, but FindBugs can't figure that out.
    -->
    <Match>
	<Class name="com.sun.mail.imap.IMAPFolder"/>
	<Field name="uidTable"/>
	<Bug pattern="IS2_INCONSISTENT_SYNC"/>
    </Match>

    <!--
	IMAPFolder.doExpungeNotification is only ever manipulated when the
	messageCacheLock is held, but FindBugs can't figure that out.
    -->
    <Match>
	<Class name="com.sun.mail.imap.IMAPFolder"/>
	<Field name="doExpungeNotification"/>
	<Bug pattern="IS2_INCONSISTENT_SYNC"/>
    </Match>

    <!--
	The static mailDateFormat field is only used to access the parse
	method, which is known to be thread safe, so we can ignore this error.
    -->
    <Match>
	<Class name="com.sun.mail.imap.protocol.INTERNALDATE"/>
	<Bug pattern="STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE"/>
    </Match>

    <!--
	These errors are in code imported from the JDK, where it seems
	to be purposely using the platform default encoding.  It's safer
	to just leave this alone and ignore the errors.
    -->
    <Match>
	<Class name="javax.mail.URLName"/>
	<Bug pattern="DM_DEFAULT_ENCODING"/>
    </Match>

    <!--
	We're purposely using the platform default encoding because
	we're trying to discover what the platform default encoding *is*!
    -->
    <Match>
	<Class name="javax.mail.internet.MimeUtility"/>
	<Method name="getDefaultJavaCharset"/>
	<Bug pattern="DM_DEFAULT_ENCODING"/>
    </Match>

    <!--
	We're purposely using the platform default encoding when a
	charset hasn't been specified.
    -->
    <Match>
	<Class name="javax.mail.internet.ParameterList"/>
	<Method name="combineMultisegmentNames"/>
	<Bug pattern="DM_DEFAULT_ENCODING"/>
    </Match>

    <!--
	We're purposely using the platform default encoding because
	we're converting bytes that were written using the platform
	default encoding back to a String.
    -->
    <Match>
	<Class name="com.sun.mail.util.LogOutputStream"/>
	<Method name="logBuf"/>
	<Bug pattern="DM_DEFAULT_ENCODING"/>
    </Match>

    <!--
	MimeBodyPart.headers is set in the constructor.  IMAPBodyPart has
	perhaps paranoid defensive code to set it if it's not set.  That
	code is protected by the object lock, but all of the reads of the
	field are not, thus FindBugs complains.  For now I think it's
	better to leave the defensive code in and ignore this error.
    -->
    <Match>
	<Class name="javax.mail.internet.MimeBodyPart"/>
	<Field name="headers"/>
	<Bug pattern="IS2_INCONSISTENT_SYNC"/>
    </Match>

    <!--
	Refactoring these anonymous inner classes to be static classes
	makes the code less readable.  Too bad there's no way for an
	anonymous inner class to be static.
	XXX - these class names aren't going to be stable as the code changes
    -->
    <Match>
	<Or>
	    <Class name="com.sun.mail.imap.DefaultFolder$1"/>
	    <Class name="com.sun.mail.imap.DefaultFolder$2"/>
	    <Class name="com.sun.mail.imap.IMAPFolder$1"/>
	    <Class name="com.sun.mail.imap.IMAPFolder$4"/>
	    <Class name="com.sun.mail.imap.IMAPFolder$7"/>
	    <Class name="com.sun.mail.imap.IMAPFolder$13"/>
	    <Class name="com.sun.mail.imap.IMAPFolder$20"/>
	    <Class name="com.sun.mail.imap.IdleManager$2"/>
	</Or>
	<Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/>
    </Match>

    <!--
	SpotBugs doesn't recognize the anonymous inner classes above.
	https://github.com/spotbugs/discuss/issues/22
	This regular expression version has the same effect, and
	avoids the potential issue with the class names changing.
    -->
    <Match>
	<Or>
	    <Class name="~com\.sun\.mail\.imap\.DefaultFolder.*"/>
	    <Class name="~com\.sun\.mail\.imap\.IMAPFolder.*"/>
	    <Class name="~com\.sun\.mail\.imap\.IdleManager.*"/>
	</Or>
	<Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/>
    </Match>

    <!--
	Even though only this array reference is volatile, the array is
	used in such a way that it's safe.  The aray elements are created
	and initialized before the array is assigned to this array
	reference, and after being assigned neither the array nor the
	array elements are changed.
    -->
    <Match>
	<Class name="com.sun.mail.imap.IMAPFolder"/>
	<Field name="attributes"/>
	<Bug pattern="VO_VOLATILE_REFERENCE_TO_ARRAY"/>
    </Match>

    <!--
	This code is easier to understand with empty "if" clauses;
	the "match" method is being called for its side effects.
    -->
    <Match>
	<Class name="com.sun.mail.imap.protocol.FetchResponse"/>
	<Method name="parseItem"/>
	<Bug pattern="UCF_USELESS_CONTROL_FLOW"/>
    </Match>

    <!--
	Even though these fields are unread for now, we'll keep them
	since they represent data in the protocol message being parsed.
    -->
    <Match>
	<Or>
	    <Class name="com.sun.mail.imap.protocol.ENVELOPE"/>
	    <Class name="com.sun.mail.imap.protocol.INTERNALDATE"/>
	    <Class name="com.sun.mail.imap.protocol.RFC822SIZE"/>
	</Or>
	<Field name="msgno"/>
	<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.imap.protocol.MailboxInfo"/>
	<Field name="first"/>
	<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
    </Match>
    <!--
	These unread fields are part of the public API.
    -->
    <Match>
	<Class name="javax.mail.Service"/>
	<Field name="debug"/>
	<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
    </Match>
    <Match>
	<Class name="javax.mail.Quota$Resource"/>
	<Field name="usage"/>
	<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
    </Match>

    <!--
	We use a static MailDateFormat instance, which uses a static
	GregorianCalendar instance.  The MailDateFormat.parse method
	uses only local data except for the GregorianCalendar instance,
	which is invoked through a static synchronized method.
    -->
    <Match>
	<Class name="com.sun.mail.imap.protocol.ENVELOPE"/>
	<Bug pattern="STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE"/>
    </Match>

    <!--
	A special String instance is used to indicate that the POP3
	UID is unknown.  The uid field is initialized to this String
	instance, which we then compare with later to see if the uid
	has been set.
    -->
    <Match>
	<Class name="com.sun.mail.pop3.POP3Folder"/>
	<Method name="getUID"/>
	<Bug pattern="ES_COMPARING_STRINGS_WITH_EQ"/>
    </Match>
    <!--
	As above, a special String instance is used to indicate whether
	certain fields have been set.
    -->
    <Match>
	<Class name="com.sun.mail.smtp.SMTPTransport"/>
	<Or>
	    <Method name="getAuthorizationId"/>
	    <Method name="getNTLMDomain"/>
	    <Method name="getSASLRealm"/>
	</Or>
	<Bug pattern="ES_COMPARING_STRINGS_WITH_EQ"/>
    </Match>

    <!--
	I know Exception.toString is never supposed to return null,
	but this extra check is cheap insurance.
    -->
    <Match>
	<Class name="javax.mail.MessagingException"/>
	<Method name="toString"/>
	<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
    </Match>
    <!--
	I know ClassLoader.getResources is never supposed to return null,
	but this extra check is cheap insurance.
    -->
    <Match>
	<Class name="~javax\.mail\.Session\$.*"/>
	<Method name="run"/>
	<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
    </Match>

    <!--
	These names may be confusing, but we're stuck with them.
    -->
    <Match>
	<Class name="javax.mail.PasswordAuthentication"/>
	<Method name="getUserName"/>
	<Bug pattern="NM_CONFUSING"/>
    </Match>

    <!--
	This trivial inner class extends ArrayList, but is never serialized,
	so it doesn't really need a serialVersionUID.
    -->
    <Match>
	<Class name="javax.mail.internet.ParameterList$MultiValue"/>
	<Bug pattern="SE_NO_SERIALVERSIONID"/>
    </Match>

    <!--
	These array references are declared volatile because they're
	treated as copy-on-write.
    -->
    <Match>
	<Class name="com.sun.mail.util.logging.LogManagerProperties"/>
	<Field name="REFLECT_NAMES"/>
	<Bug pattern="VO_VOLATILE_REFERENCE_TO_ARRAY"/>
    </Match>
    <Match>
	<Class name="com.sun.mail.util.logging.MailHandler"/>
	<Field name="attachmentFilters"/>
	<Bug pattern="VO_VOLATILE_REFERENCE_TO_ARRAY"/>
    </Match>

    <!--
	The Authenticator fields are only accessible by subclasses,
	which are only called through the one synchronized public
	method, assuming the subclass doesn't do something crazy and
	expose them itself.
    -->
    <Match>
	<Class name="javax.mail.Authenticator"/>
	<Bug pattern="IS2_INCONSISTENT_SYNC"/>
    </Match>

    <!--
	Ignore failures to close connection.
    -->
    <Match>
	<Class name="com.sun.mail.smtp.SMTPTransport"/>
	<Method name="protocolConnect"/>
	<Bug pattern="DE_MIGHT_IGNORE"/>
    </Match>

    <!--
	This inner class doesn't need "this", but it creates another
	inner class that *does* need "this".
    -->
    <Match>
	<Class name="com.sun.mail.smtp.SMTPTransport$BDATOutputStream"/>
	<Bug pattern="SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS"/>
    </Match>
</FindBugsFilter>
