|
1 | 1 | /* |
2 | 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 | 3 | * |
4 | | - * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved. |
| 4 | + * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved. |
5 | 5 | * |
6 | 6 | * The contents of this file are subject to the terms of either the GNU |
7 | 7 | * General Public License Version 2 only ("GPL") or the Common Development |
@@ -95,6 +95,7 @@ public class POP3Store extends Store { |
95 | 95 | volatile boolean useFileCache = false; |
96 | 96 | volatile File fileCacheDir = null; |
97 | 97 | volatile boolean keepMessageContent = false; |
| 98 | + volatile boolean finalizeCleanClose = false; |
98 | 99 |
|
99 | 100 | public POP3Store(Session session, URLName url) { |
100 | 101 | this(session, url, "pop3", false); |
@@ -136,6 +137,9 @@ public POP3Store(Session session, URLName url, |
136 | 137 | // mail.pop3.starttls.required requires use of STLS command |
137 | 138 | requireStartTLS = getBoolProp("starttls.required"); |
138 | 139 |
|
| 140 | + // mail.pop3.finalizecleanclose requires clean close when finalizing |
| 141 | + finalizeCleanClose = getBoolProp("finalizecleanclose"); |
| 142 | + |
139 | 143 | String s = session.getProperty("mail." + name + ".message.class"); |
140 | 144 | if (s != null) { |
141 | 145 | logger.log(Level.CONFIG, "message class: {0}", s); |
@@ -341,9 +345,17 @@ synchronized void closePort(POP3Folder owner) { |
341 | 345 | } |
342 | 346 |
|
343 | 347 | public synchronized void close() throws MessagingException { |
| 348 | + close(false); |
| 349 | + } |
| 350 | + |
| 351 | + synchronized void close(boolean force) throws MessagingException { |
344 | 352 | try { |
345 | | - if (port != null) |
346 | | - port.quit(); |
| 353 | + if (port != null) { |
| 354 | + if (force) |
| 355 | + port.close(); |
| 356 | + else |
| 357 | + port.quit(); |
| 358 | + } |
347 | 359 | } catch (IOException ioex) { |
348 | 360 | } finally { |
349 | 361 | port = null; |
@@ -410,7 +422,7 @@ public synchronized boolean isSSL() { |
410 | 422 | protected void finalize() throws Throwable { |
411 | 423 | try { |
412 | 424 | if (port != null) // don't force a connection attempt |
413 | | - close(); |
| 425 | + close(!finalizeCleanClose); |
414 | 426 | } finally { |
415 | 427 | super.finalize(); |
416 | 428 | } |
|
0 commit comments