Uploaded image for project: 'ManifoldCF'
  1. ManifoldCF
  2. CONNECTORS-713

Alfresco connector needs to deal with IOExceptions better

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: ManifoldCF 1.2
    • Fix Version/s: ManifoldCF 1.3
    • Component/s: Alfresco connector
    • Labels:
      None

      Description

      The Alfresco Connector deals with IOExceptions by just tossing a wrapping ManifoldCFException. This is a problem for several reasons. First, IOExceptions are usually transient, and should mostly be converted into ServiceInterruptions instead. Second, IOExceptions may represent thread interrupts, in which case the software should instead throw new ManifoldCFException(<msg>, ManifoldCFException.INTERRUPTED).

      A good model is to have a method called "void handleIOException(IOException) throws ServiceInterruption, ManifoldCFException" called from everywhere that IOExceptions are caught. Usually they get implemented something like this, although you can also throw ServiceInterruptions with different characteristics dependent on the kind of IOException being caught:

        private static void handleIOException(IOException e)
          throws ManifoldCFException, ServiceInterruption {
          if (!(e instanceof java.net.SocketTimeoutException) && (e instanceof InterruptedIOException)) {
            throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
              ManifoldCFException.INTERRUPTED);
          }
          long currentTime = System.currentTimeMillis();
          throw new ServiceInterruption("IO exception: "+e.getMessage(), e, currentTime + 300000L,
            currentTime + 3 * 60 * 60000L,-1,false);
        }
      

      The exception returned is the following:

      FATAL 2013-06-11 16:40:03,441 (Worker thread '12') - Error tossed: Unable to get content as inputStream.
      org.alfresco.webservice.util.WebServiceException: Unable to get content as inputStream.
          at org.alfresco.webservice.util.ContentUtils.getContentAsInputStream(ContentUtils.java:139)
          at org.apache.manifoldcf.crawler.connectors.alfresco.ContentReader.getBinary(ContentReader.java:73)
          at org.apache.manifoldcf.crawler.connectors.alfresco.AlfrescoRepositoryConnector.processDocuments(AlfrescoRepositoryConnector.java:824)
          at org.apache.manifoldcf.crawler.connectors.BaseRepositoryConnector.processDocuments(BaseRepositoryConnector.java:423)
          at org.apache.manifoldcf.crawler.system.WorkerThread.run(WorkerThread.java:559)
      Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:9090/alfresco/download/direct/workspace/SpacesStore/1e4f7fe4-d58a-4d69-b26f-3349546af7ca/testdata2.txt?ticket=TICKET_33ac1ec81c5b0ca9d024f0489df115286d0ac030
          at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1625)
          at org.alfresco.webservice.util.ContentUtils.getContentAsInputStream(ContentUtils.java:135)
          ... 4 more
      

        Attachments

          Activity

            People

            • Assignee:
              piergiorgiolucidi@gmail.com Piergiorgio Lucidi
              Reporter:
              kwright@metacarta.com Karl Wright
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: