private void connect() throws ServiceException { if (!connection.isClosed()) return; try { connection.connect(); try { connection.login(dataSource.getDecryptedPassword()); } catch (CommandFailedException e) { throw new LoginException(e.getError()); } } catch (Exception e) { connection.close(); throw ServiceException.FAILURE("Unable to connect to POP3 server: " + dataSource, e); } }