From 8e23da89931c1bf52425f7cb9900f32bccb6b4e1 Mon Sep 17 00:00:00 2001 From: jmehrens Date: Tue, 5 Mar 2024 16:00:37 -0600 Subject: [PATCH] Remove this-escape compiler warnings #141 Signed-off-by: jmehrens jason_mehrens@hotmail.com --- .../angus/mail/util/MailConnectException.java | 12 ++++--- .../mail/util/SocketConnectException.java | 15 ++++---- .../java/example/client/ComponentFrame.java | 4 ++- .../main/java/example/client/FolderModel.java | 13 ++++--- .../java/example/client/FolderTreeNode.java | 4 +-- .../java/example/client/FolderViewer.java | 4 ++- .../java/example/client/MessageViewer.java | 4 ++- .../java/example/client/MultipartViewer.java | 8 +++-- .../example/client/SimpleAuthenticator.java | 9 ++--- .../java/example/client/SimpleClient.java | 14 ++++---- .../java/example/client/StoreTreeNode.java | 4 +-- .../main/java/example/client/TextViewer.java | 4 ++- .../main/java/example/outlook/MSMessage.java | 4 ++- .../outlook/MSMultipartDataSource.java | 10 +++--- .../java/example/app/JakartaMailServlet.java | 7 ++-- .../main/java/demo/ListAttachmentsTag.java | 3 +- .../src/main/java/demo/ListMessagesTag.java | 3 +- .../taglib/src/main/java/demo/MessageTag.java | 3 +- demos/taglib/src/main/java/demo/SendTag.java | 3 +- .../src/main/java/demo/AttachmentServlet.java | 5 +-- .../src/main/java/demo/FilterServlet.java | 4 ++- doc/src/main/resources/docs/CHANGES.txt | 6 ++++ .../angus/mail/dsn/MultipartReport.java | 15 ++++++-- .../angus/mail/gimap/GmailMessage.java | 4 +-- .../mail/gimap/protocol/GmailProtocol.java | 5 ++- .../org/eclipse/angus/mail/iap/Protocol.java | 3 +- .../org/eclipse/angus/mail/iap/Response.java | 7 ++-- .../org/eclipse/angus/mail/imap/Rights.java | 5 +-- .../angus/mail/imap/protocol/FLAGS.java | 3 +- .../mail/imap/protocol/FetchResponse.java | 7 ++-- .../mail/imap/protocol/IMAPProtocol.java | 3 +- .../mail/imap/protocol/IMAPResponse.java | 4 ++- .../angus/mail/mbox/DefaultMailbox.java | 11 +++--- .../eclipse/angus/mail/mbox/MboxFolder.java | 35 +++++++++++++++---- .../eclipse/angus/mail/mbox/MboxMessage.java | 6 +++- .../angus/mail/remote/RemoteStore.java | 7 +++- providers/pop3/src/main/java/module-info.java | 3 +- 37 files changed, 177 insertions(+), 84 deletions(-) diff --git a/core/src/main/java/org/eclipse/angus/mail/util/MailConnectException.java b/core/src/main/java/org/eclipse/angus/mail/util/MailConnectException.java index 22054496..dad0c802 100644 --- a/core/src/main/java/org/eclipse/angus/mail/util/MailConnectException.java +++ b/core/src/main/java/org/eclipse/angus/mail/util/MailConnectException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -30,9 +30,9 @@ */ public class MailConnectException extends MessagingException { - private String host; - private int port; - private int cto; + private final String host; + private final int port; + private final int cto; private static final long serialVersionUID = -3818807731125317729L; @@ -40,7 +40,9 @@ public class MailConnectException extends MessagingException { * Constructs a MailConnectException. * * @param cex the SocketConnectException with the details + * @throws NullPointerException if given exception is {@code null}. */ + @SuppressWarnings("this-escape") public MailConnectException(SocketConnectException cex) { super( "Couldn't connect to host, port: " + @@ -51,7 +53,7 @@ public MailConnectException(SocketConnectException cex) { this.host = cex.getHost(); this.port = cex.getPort(); this.cto = cex.getConnectionTimeout(); - setNextException(cex.getException()); + super.setNextException(cex.getException()); } /** diff --git a/core/src/main/java/org/eclipse/angus/mail/util/SocketConnectException.java b/core/src/main/java/org/eclipse/angus/mail/util/SocketConnectException.java index 76ca7d8b..fe6a2899 100644 --- a/core/src/main/java/org/eclipse/angus/mail/util/SocketConnectException.java +++ b/core/src/main/java/org/eclipse/angus/mail/util/SocketConnectException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -32,15 +32,15 @@ public class SocketConnectException extends IOException { /** * The socket host name. */ - private String host; + private final String host; /** * The socket port. */ - private int port; + private final int port; /** * The connection timeout. */ - private int cto; + private final int cto; /** * The generated serial id. */ @@ -57,8 +57,7 @@ public class SocketConnectException extends IOException { */ public SocketConnectException(String msg, Exception cause, String host, int port, int cto) { - super(msg); - initCause(cause); + super(msg, cause); this.host = host; this.port = port; this.cto = cto; @@ -71,8 +70,8 @@ public SocketConnectException(String msg, Exception cause, */ public Exception getException() { // the "cause" is always an Exception; see constructor above - Throwable t = getCause(); - assert t == null || t instanceof Exception; + Throwable t = super.getCause(); + assert t == null || t instanceof Exception : t; return (Exception) t; } diff --git a/demos/client/src/main/java/example/client/ComponentFrame.java b/demos/client/src/main/java/example/client/ComponentFrame.java index d8df64d9..a27cb4e9 100644 --- a/demos/client/src/main/java/example/client/ComponentFrame.java +++ b/demos/client/src/main/java/example/client/ComponentFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -20,6 +20,7 @@ * @author Christopher Cotton */ public class ComponentFrame extends JFrame { + private static final long serialVersionUID = -1L; /** * creates the frame @@ -36,6 +37,7 @@ public ComponentFrame(Component what) { * @param what the component to display * @param name the name of the Frame */ + @SuppressWarnings("this-escape") public ComponentFrame(Component what, String name) { super(name); diff --git a/demos/client/src/main/java/example/client/FolderModel.java b/demos/client/src/main/java/example/client/FolderModel.java index c86c9608..7be05952 100644 --- a/demos/client/src/main/java/example/client/FolderModel.java +++ b/demos/client/src/main/java/example/client/FolderModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -25,12 +25,12 @@ * @author Bill Shannon */ public class FolderModel extends AbstractTableModel { - + private static final long serialVersionUID = -1L; Folder folder; Message[] messages; String[] columnNames = {"Date", "From", "Subject"}; - Class[] columnTypes = {String.class, String.class, String.class}; + Class[] columnTypes = {String.class, String.class, String.class}; public void setFolder(Folder what) throws MessagingException { if (what != null) { @@ -62,19 +62,23 @@ public Message getMessage(int which) { // Implementation of the TableModel methods //--------------------- + @Override public String getColumnName(int column) { return columnNames[column]; } - public Class getColumnClass(int column) { + @Override + public Class getColumnClass(int column) { return columnTypes[column]; } + @Override public int getColumnCount() { return columnNames.length; } + @Override public int getRowCount() { if (messages == null) return 0; @@ -82,6 +86,7 @@ public int getRowCount() { return messages.length; } + @Override public Object getValueAt(int aRow, int aColumn) { switch (aColumn) { case 0: // date diff --git a/demos/client/src/main/java/example/client/FolderTreeNode.java b/demos/client/src/main/java/example/client/FolderTreeNode.java index 74017c5c..069b915f 100644 --- a/demos/client/src/main/java/example/client/FolderTreeNode.java +++ b/demos/client/src/main/java/example/client/FolderTreeNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -21,7 +21,7 @@ * @author Christopher Cotton */ public class FolderTreeNode extends DefaultMutableTreeNode { - + private static final long serialVersionUID = -1L; protected Folder folder = null; protected boolean hasLoaded = false; diff --git a/demos/client/src/main/java/example/client/FolderViewer.java b/demos/client/src/main/java/example/client/FolderViewer.java index 121cbcb3..87afce77 100644 --- a/demos/client/src/main/java/example/client/FolderViewer.java +++ b/demos/client/src/main/java/example/client/FolderViewer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -24,6 +24,7 @@ * @author Bill Shannon */ public class FolderViewer extends JPanel { + private static final long serialVersionUID = -1L; FolderModel model = new FolderModel(); JScrollPane scrollpane; @@ -33,6 +34,7 @@ public FolderViewer() { this(null); } + @SuppressWarnings("this-escape") public FolderViewer(Folder what) { super(new GridLayout(1, 1)); diff --git a/demos/client/src/main/java/example/client/MessageViewer.java b/demos/client/src/main/java/example/client/MessageViewer.java index 97388dd7..f53a7eb5 100644 --- a/demos/client/src/main/java/example/client/MessageViewer.java +++ b/demos/client/src/main/java/example/client/MessageViewer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -32,6 +32,7 @@ * @author Bill Shannon */ public class MessageViewer extends JPanel implements CommandObject { + private static final long serialVersionUID = -1L; Message displayed = null; DataHandler dataHandler = null; @@ -43,6 +44,7 @@ public MessageViewer() { this(null); } + @SuppressWarnings("this-escape") public MessageViewer(Message what) { // set our layout super(new GridBagLayout()); diff --git a/demos/client/src/main/java/example/client/MultipartViewer.java b/demos/client/src/main/java/example/client/MultipartViewer.java index 69bfb66e..4158cda2 100644 --- a/demos/client/src/main/java/example/client/MultipartViewer.java +++ b/demos/client/src/main/java/example/client/MultipartViewer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -29,7 +29,7 @@ * @author Christopher Cotton */ public class MultipartViewer extends JPanel implements CommandObject { - + private static final long serialVersionUID = -1L; protected DataHandler dh = null; protected String verb = null; @@ -38,6 +38,7 @@ public MultipartViewer() { } + @Override public void setCommandContext(String verb, DataHandler dh) throws IOException { this.verb = verb; this.dh = dh; @@ -157,11 +158,12 @@ public AttachmentViewer(BodyPart part) { bp = part; } + @Override public void actionPerformed(ActionEvent e) { ComponentFrame f = new ComponentFrame( getComponent(bp), "Attachment"); f.pack(); - f.show(); + f.setVisible(true); } } diff --git a/demos/client/src/main/java/example/client/SimpleAuthenticator.java b/demos/client/src/main/java/example/client/SimpleAuthenticator.java index f58bfe01..20bf4f04 100644 --- a/demos/client/src/main/java/example/client/SimpleAuthenticator.java +++ b/demos/client/src/main/java/example/client/SimpleAuthenticator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -116,10 +116,11 @@ protected PasswordAuthentication getPasswordAuthentication() { int result = JOptionPane.showConfirmDialog(frame, d, "Login", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); - if (result == JOptionPane.OK_OPTION) + if (result == JOptionPane.OK_OPTION) { + char[] pw = password.getPassword(); return new PasswordAuthentication(username.getText(), - password.getText()); - else + pw == null ? (String) null : new String(pw)); + } else return null; } diff --git a/demos/client/src/main/java/example/client/SimpleClient.java b/demos/client/src/main/java/example/client/SimpleClient.java index 70dc3d78..bf38910b 100644 --- a/demos/client/src/main/java/example/client/SimpleClient.java +++ b/demos/client/src/main/java/example/client/SimpleClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -41,7 +41,7 @@ public class SimpleClient { - static Vector url = new Vector(); + static Vector url = new Vector<>(); static FolderViewer fv; static MessageViewer mv; @@ -60,7 +60,7 @@ public static void main(String[] argv) { } } - if (usage || url.size() == 0) { + if (usage || url.isEmpty()) { System.out.println("Usage: client.SimpleClient -L url"); System.out.println(" where url is protocol://username:password@hostname/"); System.exit(1); @@ -81,6 +81,7 @@ public static void main(String[] argv) { JFrame frame = new JFrame("Simple Jakarta Mail Client"); frame.addWindowListener(new WindowAdapter() { + @Override public void windowClosing(WindowEvent e) { System.exit(0); } @@ -96,8 +97,8 @@ public void windowClosing(WindowEvent e) { DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root"); // create a node for each store we have - for (Enumeration e = url.elements(); e.hasMoreElements(); ) { - String urlstring = (String) e.nextElement(); + for (Enumeration e = url.elements(); e.hasMoreElements(); ) { + String urlstring = e.nextElement(); URLName urln = new URLName(urlstring); Store store = session.getStore(urln); @@ -130,7 +131,7 @@ public void windowClosing(WindowEvent e) { frame.getContentPane().add(jsp2); frame.pack(); - frame.show(); + frame.setVisible(true); } catch (Exception ex) { System.out.println("SimpletClient caught exception"); @@ -143,6 +144,7 @@ public void windowClosing(WindowEvent e) { class TreePress implements TreeSelectionListener { + @Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getNewLeadSelectionPath(); if (path != null) { diff --git a/demos/client/src/main/java/example/client/StoreTreeNode.java b/demos/client/src/main/java/example/client/StoreTreeNode.java index 912b5ac9..de379879 100644 --- a/demos/client/src/main/java/example/client/StoreTreeNode.java +++ b/demos/client/src/main/java/example/client/StoreTreeNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -23,7 +23,7 @@ * @author Christopher Cotton */ public class StoreTreeNode extends DefaultMutableTreeNode { - + private static final long serialVersionUID = -1L; protected Store store = null; protected Folder folder = null; protected String display = null; diff --git a/demos/client/src/main/java/example/client/TextViewer.java b/demos/client/src/main/java/example/client/TextViewer.java index 354c2a96..342b7a62 100644 --- a/demos/client/src/main/java/example/client/TextViewer.java +++ b/demos/client/src/main/java/example/client/TextViewer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -26,6 +26,7 @@ */ public class TextViewer extends JPanel implements CommandObject { + private static final long serialVersionUID = -1L; private JTextArea text_area = null; private DataHandler dh = null; private String verb = null; @@ -33,6 +34,7 @@ public class TextViewer extends JPanel implements CommandObject { /** * Constructor */ + @SuppressWarnings("this-escape") public TextViewer() { super(new GridLayout(1, 1)); diff --git a/demos/outlook/src/main/java/example/outlook/MSMessage.java b/demos/outlook/src/main/java/example/outlook/MSMessage.java index 71a25753..a09d2a2a 100644 --- a/demos/outlook/src/main/java/example/outlook/MSMessage.java +++ b/demos/outlook/src/main/java/example/outlook/MSMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -47,6 +47,7 @@ public class MSMessage extends MimeMessage { * IOException occurs when accessing the given * MimeMessage object */ + @SuppressWarnings("this-escape") public MSMessage(Session session, MimeMessage msg) throws MessagingException { super(session); @@ -77,6 +78,7 @@ ByteArrayInputStream toByteArrayInputStream() { /** * Constructor to create a outlook.MSMessage from the given InputStream. */ + @SuppressWarnings("this-escape") public MSMessage(Session session, InputStream is) throws MessagingException { super(session); // setup headerstore etc diff --git a/demos/outlook/src/main/java/example/outlook/MSMultipartDataSource.java b/demos/outlook/src/main/java/example/outlook/MSMultipartDataSource.java index 97c6c443..2f9fd6b3 100644 --- a/demos/outlook/src/main/java/example/outlook/MSMultipartDataSource.java +++ b/demos/outlook/src/main/java/example/outlook/MSMultipartDataSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -28,14 +28,12 @@ */ public class MSMultipartDataSource extends MimePartDataSource implements MultipartDataSource { - //private List parts; - private List parts; + private List parts; public MSMultipartDataSource(MimePart part, byte[] content) throws MessagingException { super(part); - //parts = new ArrayList(); - parts = new ArrayList(); + parts = new ArrayList<>(); /* * Parse the text of the message to find the attachments. @@ -81,10 +79,12 @@ public MSMultipartDataSource(MimePart part, byte[] content) } } + @Override public int getCount() { return parts.size(); } + @Override public BodyPart getBodyPart(int index) throws MessagingException { return (BodyPart) parts.get(index); } diff --git a/demos/servlet/src/main/java/example/app/JakartaMailServlet.java b/demos/servlet/src/main/java/example/app/JakartaMailServlet.java index 5a656af2..0451244d 100644 --- a/demos/servlet/src/main/java/example/app/JakartaMailServlet.java +++ b/demos/servlet/src/main/java/example/app/JakartaMailServlet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -59,6 +59,7 @@ * @author Max Spivak */ public class JakartaMailServlet extends HttpServlet implements SingleThreadModel { + private static final long serialVersionUID = -1L; String protocol = "imap"; String mbox = "INBOX"; @@ -95,7 +96,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse res) // create MailUserData mud = new MailUserData(url); - ssn.putValue("jakartamailservlet", mud); + ssn.setAttribute("jakartamailservlet", mud); try { Properties props = System.getProperties(); @@ -614,7 +615,7 @@ private MailUserData getMUD(HttpSession ses) throws IOException { if (ses == null) { return null; } else { - if ((mud = (MailUserData) ses.getValue("jakartamailservlet")) == null) { + if ((mud = (MailUserData) ses.getAttribute("jakartamailservlet")) == null) { return null; } } diff --git a/demos/taglib/src/main/java/demo/ListAttachmentsTag.java b/demos/taglib/src/main/java/demo/ListAttachmentsTag.java index 1fe32a80..e860d713 100644 --- a/demos/taglib/src/main/java/demo/ListAttachmentsTag.java +++ b/demos/taglib/src/main/java/demo/ListAttachmentsTag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -24,6 +24,7 @@ * within the body of the tag. */ public class ListAttachmentsTag extends BodyTagSupport { + private static final long serialVersionUID = -1L; private String messageinfo; private int partNum = 1; private int numParts = 0; diff --git a/demos/taglib/src/main/java/demo/ListMessagesTag.java b/demos/taglib/src/main/java/demo/ListMessagesTag.java index 535c7aab..917360d7 100644 --- a/demos/taglib/src/main/java/demo/ListMessagesTag.java +++ b/demos/taglib/src/main/java/demo/ListMessagesTag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -28,6 +28,7 @@ * within the body of the tag. */ public class ListMessagesTag extends BodyTagSupport { + private static final long serialVersionUID = -1L; private String folder; private String session; private int msgNum = 0; diff --git a/demos/taglib/src/main/java/demo/MessageTag.java b/demos/taglib/src/main/java/demo/MessageTag.java index 0f85fc04..bcea4519 100644 --- a/demos/taglib/src/main/java/demo/MessageTag.java +++ b/demos/taglib/src/main/java/demo/MessageTag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -20,6 +20,7 @@ * Custom tag for retrieving a message. */ public class MessageTag extends TagSupport { + private static final long serialVersionUID = -1L; private String folder; private String session; private int num = 1; diff --git a/demos/taglib/src/main/java/demo/SendTag.java b/demos/taglib/src/main/java/demo/SendTag.java index ef3f8b53..ac888652 100644 --- a/demos/taglib/src/main/java/demo/SendTag.java +++ b/demos/taglib/src/main/java/demo/SendTag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -25,6 +25,7 @@ * Custom tag for sending messages. */ public class SendTag extends BodyTagSupport { + private static final long serialVersionUID = -1L; private String body; private String cc; private String host; diff --git a/demos/webapp/src/main/java/demo/AttachmentServlet.java b/demos/webapp/src/main/java/demo/AttachmentServlet.java index 29614c99..98334b12 100644 --- a/demos/webapp/src/main/java/demo/AttachmentServlet.java +++ b/demos/webapp/src/main/java/demo/AttachmentServlet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -32,10 +32,11 @@ * content handling capabilities. */ public class AttachmentServlet extends HttpServlet { - + private static final long serialVersionUID = -1L; /** * This method handles the GET requests from the client. */ + @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { diff --git a/demos/webapp/src/main/java/demo/FilterServlet.java b/demos/webapp/src/main/java/demo/FilterServlet.java index 666929c0..b82757a8 100644 --- a/demos/webapp/src/main/java/demo/FilterServlet.java +++ b/demos/webapp/src/main/java/demo/FilterServlet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -23,11 +23,13 @@ * forwarding the request to the selected URL. */ public class FilterServlet extends HttpServlet { + private static final long serialVersionUID = -1L; /** * This method handles the "POST" submission from two forms: the * login form and the message compose form. */ + @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { diff --git a/doc/src/main/resources/docs/CHANGES.txt b/doc/src/main/resources/docs/CHANGES.txt index fcb29bf7..009c2471 100644 --- a/doc/src/main/resources/docs/CHANGES.txt +++ b/doc/src/main/resources/docs/CHANGES.txt @@ -7,6 +7,12 @@ for the Eclipse EE4J Angus Mail project: https://github.com/eclipse-ee4j/angus-mail/issues/ + CHANGES IN THE 2.1.0 RELEASE + ---------------------------- +The following bugs have been fixed in the 2.1.0 release. + +141: Remove this-escape compiler warnings + CHANGES IN THE 2.0.3 RELEASE ---------------------------- The following bugs have been fixed in the 2.0.3 release. diff --git a/dsn/src/main/java/org/eclipse/angus/mail/dsn/MultipartReport.java b/dsn/src/main/java/org/eclipse/angus/mail/dsn/MultipartReport.java index c74a2f9a..eabedba0 100644 --- a/dsn/src/main/java/org/eclipse/angus/mail/dsn/MultipartReport.java +++ b/dsn/src/main/java/org/eclipse/angus/mail/dsn/MultipartReport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -61,6 +61,7 @@ public class MultipartReport extends MimeMultipart { * * @exception MessagingException for failures */ + @SuppressWarnings("this-escape") public MultipartReport() throws MessagingException { super("report"); // always at least two body parts @@ -80,6 +81,7 @@ public MultipartReport() throws MessagingException { * @param report the Report object * @exception MessagingException for failures */ + @SuppressWarnings("this-escape") public MultipartReport(String text, Report report) throws MessagingException { super("report"); @@ -106,6 +108,7 @@ public MultipartReport(String text, Report report) * @param msg the message this report is about * @exception MessagingException for failures */ + @SuppressWarnings("this-escape") public MultipartReport(String text, Report report, MimeMessage msg) throws MessagingException { this(text, report); @@ -126,6 +129,7 @@ public MultipartReport(String text, Report report, MimeMessage msg) * @param hdr the headers of the message this report is about * @exception MessagingException for failures */ + @SuppressWarnings("this-escape") public MultipartReport(String text, Report report, InternetHeaders hdr) throws MessagingException { this(text, report); @@ -143,6 +147,7 @@ public MultipartReport(String text, Report report, InternetHeaders hdr) * @param ds DataSource, can be a MultipartDataSource * @exception MessagingException for failures */ + @SuppressWarnings("this-escape") public MultipartReport(DataSource ds) throws MessagingException { super(ds); parse(); @@ -298,6 +303,7 @@ public synchronized DeliveryStatus getDeliveryStatus() * @exception MessagingException for failures * @deprecated use setReport instead */ + @Deprecated public synchronized void setDeliveryStatus(DeliveryStatus status) throws MessagingException { MimeBodyPart mbp = new MimeBodyPart(); @@ -358,7 +364,7 @@ public synchronized void setReturnedMessage(MimeMessage msg) private synchronized void setBodyPart(BodyPart part, int index) throws MessagingException { if (parts == null) // XXX - can never happen? - parts = new Vector(); + parts = new Vector<>(); if (index < parts.size()) super.removeBodyPart(index); @@ -374,6 +380,7 @@ private synchronized void setBodyPart(BodyPart part, int index) * @param subtype Subtype * @exception MessagingException always; can't change subtype */ + @Override public synchronized void setSubType(String subtype) throws MessagingException { throw new MessagingException("Can't change subtype of MultipartReport"); @@ -386,6 +393,7 @@ public synchronized void setSubType(String subtype) * @param part The part to remove * @exception MessagingException always */ + @Override public boolean removeBodyPart(BodyPart part) throws MessagingException { throw new MessagingException( "Can't remove body parts from multipart/report"); @@ -398,6 +406,7 @@ public boolean removeBodyPart(BodyPart part) throws MessagingException { * @param index Index of the part to remove * @exception MessagingException always */ + @Override public void removeBodyPart(int index) throws MessagingException { throw new MessagingException( "Can't remove body parts from multipart/report"); @@ -410,6 +419,7 @@ public void removeBodyPart(int index) throws MessagingException { * @param part The Part to be appended * @throws MessagingException always */ + @Override public synchronized void addBodyPart(BodyPart part) throws MessagingException { // Once constructor is done, don't allow this anymore. @@ -428,6 +438,7 @@ public synchronized void addBodyPart(BodyPart part) * @param index Location where to insert the part * @throws MessagingException always */ + @Override public synchronized void addBodyPart(BodyPart part, int index) throws MessagingException { throw new MessagingException( diff --git a/providers/gimap/src/main/java/org/eclipse/angus/mail/gimap/GmailMessage.java b/providers/gimap/src/main/java/org/eclipse/angus/mail/gimap/GmailMessage.java index f521e3f4..709302d1 100644 --- a/providers/gimap/src/main/java/org/eclipse/angus/mail/gimap/GmailMessage.java +++ b/providers/gimap/src/main/java/org/eclipse/angus/mail/gimap/GmailMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -90,7 +90,7 @@ public long getThrId() throws MessagingException { public String[] getLabels() throws MessagingException { String[] labels = (String[]) getItem(GmailProtocol.LABELS_ITEM); if (labels != null) - return (String[]) (labels.clone()); + return labels.clone(); else return new String[0]; } diff --git a/providers/gimap/src/main/java/org/eclipse/angus/mail/gimap/protocol/GmailProtocol.java b/providers/gimap/src/main/java/org/eclipse/angus/mail/gimap/protocol/GmailProtocol.java index 6cc265ee..ca157e5b 100644 --- a/providers/gimap/src/main/java/org/eclipse/angus/mail/gimap/protocol/GmailProtocol.java +++ b/providers/gimap/src/main/java/org/eclipse/angus/mail/gimap/protocol/GmailProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -82,6 +82,7 @@ public Object parseItem(FetchResponse r) { * @throws ProtocolException for protocol failures * @exception IOException for I/O errors */ + @SuppressWarnings("this-escape") public GmailProtocol(String name, String host, int port, Properties props, boolean isSSL, MailLogger logger) throws IOException, ProtocolException { @@ -100,6 +101,7 @@ public GmailProtocol(String name, String host, int port, * Return the additional fetch items supported by the Gmail protocol. * Combines our fetch items with those supported by the superclass. */ + @Override public FetchItem[] getFetchItems() { if (fetchItems != null) return fetchItems; @@ -187,6 +189,7 @@ private Argument createLabelList(String[] labels) { /** * Return a GmailSearchSequence. */ + @Override protected SearchSequence getSearchSequence() { if (searchSequence == null) searchSequence = new GmailSearchSequence(this); diff --git a/providers/imap/src/main/java/org/eclipse/angus/mail/iap/Protocol.java b/providers/imap/src/main/java/org/eclipse/angus/mail/iap/Protocol.java index f6d9e1ce..b712b550 100644 --- a/providers/imap/src/main/java/org/eclipse/angus/mail/iap/Protocol.java +++ b/providers/imap/src/main/java/org/eclipse/angus/mail/iap/Protocol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -101,6 +101,7 @@ public class Protocol { * @exception IOException for I/O errors * @exception ProtocolException for protocol failures */ + @SuppressWarnings("this-escape") public Protocol(String host, int port, Properties props, String prefix, boolean isSSL, MailLogger logger) diff --git a/providers/imap/src/main/java/org/eclipse/angus/mail/iap/Response.java b/providers/imap/src/main/java/org/eclipse/angus/mail/iap/Response.java index 2ce32e82..ea56cd67 100644 --- a/providers/imap/src/main/java/org/eclipse/angus/mail/iap/Response.java +++ b/providers/imap/src/main/java/org/eclipse/angus/mail/iap/Response.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -90,6 +90,7 @@ public Response(String s) { * @param supportsUtf8 allow UTF-8 in response? * @since JavaMail 1.6.0 */ + @SuppressWarnings("this-escape") public Response(String s, boolean supportsUtf8) { if (supportsUtf8) buffer = s.getBytes(StandardCharsets.UTF_8); @@ -107,6 +108,7 @@ public Response(String s, boolean supportsUtf8) { * @exception IOException for I/O errors * @exception ProtocolException for protocol failures */ + @SuppressWarnings("this-escape") public Response(Protocol p) throws IOException, ProtocolException { // read one response into 'buffer' ByteArray ba = p.getResponseBuffer(); @@ -195,7 +197,6 @@ else if (s.equalsIgnoreCase("BYE")) index = mark; // reset pindex = index; - return; } public void skipSpaces() { @@ -489,7 +490,7 @@ private Object parseString(boolean parseAtoms, boolean returnString) { while (buffer[index] != '}') index++; - int count = 0; + int count; try { count = ASCIIUtility.parseInt(buffer, start, index); } catch (NumberFormatException nex) { diff --git a/providers/imap/src/main/java/org/eclipse/angus/mail/imap/Rights.java b/providers/imap/src/main/java/org/eclipse/angus/mail/imap/Rights.java index 6fc0448c..bb6a8d34 100644 --- a/providers/imap/src/main/java/org/eclipse/angus/mail/imap/Rights.java +++ b/providers/imap/src/main/java/org/eclipse/angus/mail/imap/Rights.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -59,7 +59,7 @@ public class Rights implements Cloneable { * of standard rights objects are predefined here. */ public static final class Right { - private static Right[] cache = new Right[128]; + private static final Right[] cache = new Right[128]; // XXX - initialization order? /** @@ -163,6 +163,7 @@ public Rights(Rights rights) { * * @param rights the rights for initialization */ + @SuppressWarnings("this-escape") public Rights(String rights) { for (int i = 0; i < rights.length(); i++) add(Right.getInstance(rights.charAt(i))); diff --git a/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/FLAGS.java b/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/FLAGS.java index eef524d9..6f6a9596 100644 --- a/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/FLAGS.java +++ b/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/FLAGS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -39,6 +39,7 @@ public class FLAGS extends Flags implements Item { * @throws ParsingException for parsing failures * @param r the IMAPResponse */ + @SuppressWarnings("this-escape") public FLAGS(IMAPResponse r) throws ParsingException { msgno = r.getNumber(); diff --git a/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/FetchResponse.java b/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/FetchResponse.java index 20f40888..a005bf28 100644 --- a/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/FetchResponse.java +++ b/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/FetchResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -51,6 +51,7 @@ public class FetchResponse extends IMAPResponse { private Map extensionItems; private final FetchItem[] fitems; + @SuppressWarnings("this-escape") public FetchResponse(Protocol p) throws IOException, ProtocolException { super(p); @@ -72,6 +73,7 @@ public FetchResponse(IMAPResponse r) * @exception ProtocolException for protocol failures * @since JavaMail 1.4.6 */ + @SuppressWarnings("this-escape") public FetchResponse(IMAPResponse r, FetchItem[] fitems) throws IOException, ProtocolException { super(r); @@ -184,7 +186,6 @@ private void parse() throws ParsingException { "error in FETCH parsing, missing '(' at index " + index); List v = new ArrayList<>(); - Item i = null; skipSpaces(); do { @@ -192,7 +193,7 @@ private void parse() throws ParsingException { throw new ParsingException( "error in FETCH parsing, ran off end of buffer, size " + size); - i = parseItem(); + Item i = parseItem(); if (i != null) v.add(i); else if (!parseExtensionItem()) diff --git a/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/IMAPProtocol.java b/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/IMAPProtocol.java index d2a55996..8d9e312b 100644 --- a/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/IMAPProtocol.java +++ b/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/IMAPProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -126,6 +126,7 @@ public class IMAPProtocol extends Protocol { * @param logger the MailLogger to use for debug output * @exception IOException for I/O errors */ + @SuppressWarnings("this-escape") public IMAPProtocol(String name, String host, int port, Properties props, boolean isSSL, MailLogger logger) throws IOException, ProtocolException { diff --git a/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/IMAPResponse.java b/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/IMAPResponse.java index 916d626f..576196dc 100644 --- a/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/IMAPResponse.java +++ b/providers/imap/src/main/java/org/eclipse/angus/mail/imap/protocol/IMAPResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -36,6 +36,7 @@ public class IMAPResponse extends Response { private String key; private int number; + @SuppressWarnings("this-escape") public IMAPResponse(Protocol c) throws IOException, ProtocolException { super(c); init(); @@ -86,6 +87,7 @@ public IMAPResponse(String r) throws IOException, ProtocolException { * @exception ProtocolException for protocol failures * @since JavaMail 1.6.0 */ + @SuppressWarnings("this-escape") public IMAPResponse(String r, boolean utf8) throws IOException, ProtocolException { super(r, utf8); diff --git a/providers/mbox/src/main/java/org/eclipse/angus/mail/mbox/DefaultMailbox.java b/providers/mbox/src/main/java/org/eclipse/angus/mail/mbox/DefaultMailbox.java index fd2022c4..27ed9285 100644 --- a/providers/mbox/src/main/java/org/eclipse/angus/mail/mbox/DefaultMailbox.java +++ b/providers/mbox/src/main/java/org/eclipse/angus/mail/mbox/DefaultMailbox.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -32,10 +32,12 @@ public DefaultMailbox() { home = System.getProperty("user.home"); } + @Override public MailFile getMailFile(String user, String folder) { return new DefaultMailFile(filename(user, folder)); } + @Override public String filename(String user, String folder) { try { char c = folder.charAt(0); @@ -72,18 +74,17 @@ class DefaultMailFile extends File implements MailFile { super(name); } + @Override public boolean lock(String mode) { try { file = new RandomAccessFile(this, mode); return true; } catch (FileNotFoundException fe) { return false; - } catch (IOException ie) { - file = null; - return false; } } + @Override public void unlock() { if (file != null) { try { @@ -95,9 +96,11 @@ public void unlock() { } } + @Override public void touchlock() { } + @Override public FileDescriptor getFD() { if (file == null) return null; diff --git a/providers/mbox/src/main/java/org/eclipse/angus/mail/mbox/MboxFolder.java b/providers/mbox/src/main/java/org/eclipse/angus/mail/mbox/MboxFolder.java index 5e070864..dd787d91 100644 --- a/providers/mbox/src/main/java/org/eclipse/angus/mail/mbox/MboxFolder.java +++ b/providers/mbox/src/main/java/org/eclipse/angus/mail/mbox/MboxFolder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -58,14 +58,14 @@ public class MboxFolder extends Folder { - private String name; // null => the default folder + private final String name; // null => the default folder private boolean is_inbox = false; private int total; // total number of messages in mailbox private volatile boolean opened = false; private List messages; private TempFile temp; - private MboxStore mstore; - private MailFile folder; + private final MboxStore mstore; + private final MailFile folder; private long file_size; // the size the last time we read or wrote it private long saved_file_size; // size at the last open, close, or expunge private boolean special_imap_message; @@ -108,10 +108,12 @@ public MboxFolder(MboxStore store, String name) { saved_file_size = -1; } + @Override public char getSeparator() { return File.separatorChar; } + @Override public Folder[] list(String pattern) throws MessagingException { if (!folder.isDirectory()) throw new MessagingException("not a directory"); @@ -153,7 +155,7 @@ protected Folder[] list(String ref, String pattern, boolean fromStore) } else { realdir = mstore.mb.filename(mstore.user, refdir); } - List flist = new ArrayList(); + List flist = new ArrayList<>(); listWork(realdir, refdir, pattern, fromStore ? 0 : 1, flist); if (Match.path("INBOX", pattern, '\0')) flist.add("INBOX"); @@ -165,6 +167,7 @@ protected Folder[] list(String ref, String pattern, boolean fromStore) return fl; } + @Override public String getName() { if (name == null) return ""; @@ -174,6 +177,7 @@ else if (is_inbox) return folder.getName(); } + @Override public String getFullName() { if (name == null) return ""; @@ -181,6 +185,7 @@ public String getFullName() { return name; } + @Override public Folder getParent() { if (name == null) return null; @@ -191,10 +196,12 @@ else if (is_inbox) return createFolder(mstore, folder.getParent()); } + @Override public boolean exists() { return folder.exists(); } + @Override public int getType() { if (folder.isDirectory()) return HOLDS_FOLDERS; @@ -202,10 +209,12 @@ public int getType() { return HOLDS_MESSAGES; } + @Override public Flags getPermanentFlags() { return MboxStore.permFlags; } + @Override public synchronized boolean hasNewMessages() { if (folder instanceof UNIXFile) { UNIXFile f = (UNIXFile) folder; @@ -229,6 +238,7 @@ public synchronized boolean hasNewMessages() { return current_size > saved_file_size; } + @Override public synchronized Folder getFolder(String name) throws MessagingException { if (folder.exists() && !folder.isDirectory()) @@ -237,6 +247,7 @@ public synchronized Folder getFolder(String name) (this.name == null ? "~" : this.name) + File.separator + name); } + @Override public synchronized boolean create(int type) throws MessagingException { switch (type) { case HOLDS_FOLDERS: @@ -275,6 +286,7 @@ public synchronized boolean create(int type) throws MessagingException { return true; } + @Override public synchronized boolean delete(boolean recurse) throws MessagingException { checkClosed(); @@ -305,6 +317,7 @@ private boolean delete(File f) { return ret; } + @Override public synchronized boolean renameTo(Folder f) throws MessagingException { checkClosed(); @@ -364,6 +377,7 @@ private void checkWritable() throws IllegalStateException { throw new IllegalStateException("Folder is not Writable"); } + @Override public boolean isOpen() { return opened; } @@ -371,6 +385,8 @@ public boolean isOpen() { /* * Open the folder in the specified mode. */ + @Override + @SuppressWarnings("fallthrough") public synchronized void open(int mode) throws MessagingException { if (opened) throw new IllegalStateException("Folder is already Open"); @@ -401,7 +417,7 @@ public synchronized void open(int mode) throws MessagingException { } if (!folder.lock("r")) throw new MessagingException("Failed to lock folder: " + name); - messages = new ArrayList(); + messages = new ArrayList<>(); total = 0; Message[] msglist = null; try { @@ -419,6 +435,7 @@ public synchronized void open(int mode) throws MessagingException { opened = true; // now really opened } + @Override public synchronized void close(boolean expunge) throws MessagingException { checkOpen(); @@ -655,6 +672,7 @@ protected static String getUnixFrom(MimeMessage msg) { date.substring(0, 20) + date.substring(24); } + @Override public synchronized int getMessageCount() throws MessagingException { if (!opened) return -1; @@ -685,6 +703,7 @@ public synchronized int getMessageCount() throws MessagingException { * Get the specified message. Note that messages are numbered * from 1. */ + @Override public synchronized Message getMessage(int msgno) throws MessagingException { checkReadable(); @@ -716,6 +735,7 @@ private InputStream getMessageStream(int msgno) { return temp.newStream(md.start, md.dataend); } + @Override public synchronized void appendMessages(Message[] msgs) throws MessagingException { if (!folder.lock("rw")) @@ -758,6 +778,7 @@ public synchronized void appendMessages(Message[] msgs) throw new MessagingException("Can't append non-Mime message"); } + @Override public synchronized Message[] expunge() throws MessagingException { checkWritable(); @@ -896,6 +917,7 @@ private MboxMessage loadMessage(InputStream is, int msgno, /* * Only here to make accessible to MboxMessage. */ + @Override protected void notifyMessageChangedListeners(int type, Message m) { super.notifyMessageChangedListeners(type, m); } @@ -905,6 +927,7 @@ protected void notifyMessageChangedListeners(int type, Message m) { * this is an exact duplicate of the Folder.getURL except it doesn't * add a beginning '/' to the URLName. */ + @Override public URLName getURLName() { // XXX - note: this should not be done this way with the // new jakarta.mail apis. diff --git a/providers/mbox/src/main/java/org/eclipse/angus/mail/mbox/MboxMessage.java b/providers/mbox/src/main/java/org/eclipse/angus/mail/mbox/MboxMessage.java index 50078178..e24d63b9 100644 --- a/providers/mbox/src/main/java/org/eclipse/angus/mail/mbox/MboxMessage.java +++ b/providers/mbox/src/main/java/org/eclipse/angus/mail/mbox/MboxMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -59,9 +59,11 @@ public class MboxMessage extends MimeMessage { Date rcvDate; int lineCount = -1; private static OutputStream nullOutputStream = new OutputStream() { + @Override public void write(int b) { } + @Override public void write(byte[] b, int off, int len) { } }; @@ -69,6 +71,7 @@ public void write(byte[] b, int off, int len) { /** * Construct an MboxMessage from the InputStream. */ + @SuppressWarnings("this-escape") public MboxMessage(Session session, InputStream is) throws MessagingException, IOException { super(session); @@ -92,6 +95,7 @@ public MboxMessage(Session session, InputStream is) * Construct an MboxMessage using the given InternetHeaders object * and content from an InputStream. */ + @SuppressWarnings("this-escape") public MboxMessage(MboxFolder folder, InternetHeaders hdrs, InputStream is, int msgno, String unix_from, boolean writable) throws MessagingException { diff --git a/providers/mbox/src/main/java/org/eclipse/angus/mail/remote/RemoteStore.java b/providers/mbox/src/main/java/org/eclipse/angus/mail/remote/RemoteStore.java index 80cf3b00..81378e7f 100644 --- a/providers/mbox/src/main/java/org/eclipse/angus/mail/remote/RemoteStore.java +++ b/providers/mbox/src/main/java/org/eclipse/angus/mail/remote/RemoteStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -38,6 +38,7 @@ public abstract class RemoteStore extends MboxStore { protected int port; protected long lastUpdate = 0; + @SuppressWarnings("this-escape") public RemoteStore(Session session, URLName url) { super(session, url); remoteStore = getRemoteStore(session, url); @@ -53,6 +54,7 @@ public RemoteStore(Session session, URLName url) { /** * Connect to the store. */ + @Override public void connect(String host, int port, String user, String password) throws MessagingException { this.host = host; @@ -105,12 +107,14 @@ protected void updateInbox() throws MessagingException { } } + @Override public Folder getDefaultFolder() throws MessagingException { checkConnected(); return new RemoteDefaultFolder(this, null); } + @Override public Folder getFolder(String name) throws MessagingException { checkConnected(); @@ -120,6 +124,7 @@ public Folder getFolder(String name) throws MessagingException { return super.getFolder(name); } + @Override public Folder getFolder(URLName url) throws MessagingException { checkConnected(); return getFolder(url.getFile()); diff --git a/providers/pop3/src/main/java/module-info.java b/providers/pop3/src/main/java/module-info.java index 59faf844..fbce0120 100644 --- a/providers/pop3/src/main/java/module-info.java +++ b/providers/pop3/src/main/java/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -14,6 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ +@SuppressWarnings("module") module org.eclipse.angus.mail.pop3 { requires transitive jakarta.mail;