コード例 #1
0
 public JilterStatus eom(JilterEOMActions eomActions, Properties properties) {
   logger.debug("jilter eom()");
   try {
     bos.close(); // close stream
   } catch (IOException io) {
     logger.error("jilter failed to close io stream during eom", io);
   }
   byte[] messageBytes = bos.toByteArray();
   bos = new ByteArrayOutputStream();
   ByteArrayInputStream bis = new ByteArrayInputStream(messageBytes);
   try {
     logger.debug("jilter store callback execute");
     Config.getStopBlockFactory()
         .detectBlock("milter server", Thread.currentThread(), this, IDLE_TIMEOUT);
     callback.store(bis, host);
     logger.debug("jilter store callback finished");
   } catch (ArchiveException e) {
     logger.error("failed to store the message via milter", e);
     if (e.getRecoveryDirective() == ArchiveException.RecoveryDirective.REJECT) {
       logger.debug("jilter reject");
       return JilterStatus.SMFIS_REJECT;
     } else if (e.getRecoveryDirective() == ArchiveException.RecoveryDirective.RETRYLATER) {
       logger.debug("jilter temp fail");
       return JilterStatus.SMFIS_TEMPFAIL;
     }
   } catch (Throwable oome) {
     logger.error("failed to store message:" + oome.getMessage(), oome);
     return JilterStatus.SMFIS_REJECT;
   } finally {
     Config.getStopBlockFactory().endDetectBlock(Thread.currentThread());
   }
   return JilterStatus.SMFIS_CONTINUE;
 }
コード例 #2
0
  public void handleBlock(Thread thread) {

    try {
      if (socket != null) {
        logger.debug("close socket()");
        socket.close();
      }
    } catch (Exception e) {
      // ignored
    }
    synchronized (this) {
      if (thread != null) {
        logger.debug("interrupt thread()");
        thread.interrupt();
      }
    }
  }
コード例 #3
0
  public static synchronized List<SearchResultBean> getSearchResultBeans(
      List<Search.Result> results, Locale locale) {
    List<SearchResultBean> searchResultBeans = new LinkedList<SearchResultBean>();
    try {
      for (Search.Result result : results) {
        searchResultBeans.add(new SearchResultBean(result, locale));
      }
      while (searchResultBeans.size() < Config.getConfig().getSearch().getMaxSearchResults()) {
        searchResultBeans.add(new SearchResultBean());
      }
    } catch (java.util.ConcurrentModificationException ce) {
      // bit of a hack to say the least

      try {
        Thread.sleep(50);
      } catch (Exception e) {
      }
      return getSearchResultBeans(results, locale);
    }
    return searchResultBeans;
  }