|
From: <de...@us...> - 2003-10-01 08:57:40
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker
In directory sc8-pr-cvs1:/tmp/cvs-serv22758/modules/scanner/src/com/babeldoc/scanner/worker
Modified Files:
MailboxScanner.java
Log Message:
Resources are not keept opened while not scanning anymore.
This is done tring to fix bug 815709
Index: MailboxScanner.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/MailboxScanner.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** MailboxScanner.java 30 Sep 2003 13:47:54 -0000 1.25
--- MailboxScanner.java 1 Oct 2003 08:57:36 -0000 1.26
***************
*** 85,89 ****
import com.babeldoc.core.I18n;
- import com.babeldoc.core.LogService;
import com.babeldoc.core.option.ConfigOption;
import com.babeldoc.core.option.IConfigOptionType;
--- 85,88 ----
***************
*** 119,125 ****
/** Instance variables */
- Folder folder;
- Session session;
- Store store;
private String folder_; // INBOX
private String getFrom = BODY; //getChild from body
--- 118,121 ----
***************
*** 146,157 ****
public void doScan() throws ScannerException {
//Folder folder = null;
try {
! if (!store.isConnected()) {
! getLog().logDebug("Connection closed. Reconnecting");
! store.connect(host, username, password);
! }
folder = store.getFolder(folder_);
folder.open(Folder.READ_WRITE);
!
Message[] messages = folder.getMessages();
--- 142,156 ----
public void doScan() throws ScannerException {
//Folder folder = null;
+ Folder folder = null;
+ Store store = null;
+ Session session = null;
try {
! Properties props = new Properties();
! session = Session.getDefaultInstance(props, null);
! store = session.getStore(protocol);
! store.connect(host, username, password);
folder = store.getFolder(folder_);
folder.open(Folder.READ_WRITE);
!
Message[] messages = folder.getMessages();
***************
*** 160,185 ****
deleteMessage(messages[i]);
}
-
- folder.close(true);
} catch (Exception x) {
try {
if (folder.isOpen()) {
folder.close(true);
}
} catch (Exception e) {
! //LogService.getInstance().logError("Error occured, closing folder", e);
! }
!
! x.printStackTrace();
! throw new ScannerException(
! I18n.get("scanner.MailboxScanner.error.scanning"),
! x);
! } finally {
! try {
! //folder.close(true);
! } catch (Exception e) {
! // LogService.getInstance().logError("[doScan]: closing folder", e);
! }
! }
}
--- 159,176 ----
deleteMessage(messages[i]);
}
} catch (Exception x) {
+ throw new ScannerException(
+ I18n.get("scanner.MailboxScanner.error.scanning"),
+ x);
+ } finally {
try {
if (folder.isOpen()) {
folder.close(true);
}
+ store.close();
} catch (Exception e) {
! getLog().logError("Error closing store and folder", e);
! }
! }
}
***************
*** 210,224 ****
}
}
-
- try {
- Properties props = new Properties();
- session = Session.getInstance(props, null);
- store = session.getStore(protocol);
- store.connect(host, username, password);
- } catch (Exception x) {
- throw new ScannerConfigurationException(
- I18n.get("scanner.MailboxScanner.error.initialize"),
- x);
- }
}
--- 201,204 ----
***************
*** 227,247 ****
*/
public void relinquishResources() {
! try {
! if (folder.isOpen()) {
! folder.close(true);
! }
! } catch (Exception x) {
! LogService.getInstance().logError(
! I18n.get("scanner.MailboxScanner.error.closingFolder"),
! x);
! }
!
! try {
! store.close();
! } catch (Exception x) {
! LogService.getInstance().logError(
! I18n.get("scanner.MailboxScanner.error.closingStore"),
! x);
! }
}
--- 207,211 ----
*/
public void relinquishResources() {
! //do nothing by now...
}
|