[ 
https://issues.apache.org/jira/browse/CONNECTORS-713?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Piergiorgio Lucidi updated CONNECTORS-713:
------------------------------------------

    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:

{code}
  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);
  }
{code}

The exception returned is the following:
{code}
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
{code}

  was:
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:

{code}
  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);
  }
{code}


    
> Alfresco connector needs to deal with IOExceptions better
> ---------------------------------------------------------
>
>                 Key: CONNECTORS-713
>                 URL: https://issues.apache.org/jira/browse/CONNECTORS-713
>             Project: ManifoldCF
>          Issue Type: Bug
>          Components: Alfresco connector
>    Affects Versions: ManifoldCF 1.2
>            Reporter: Karl Wright
>            Assignee: Piergiorgio Lucidi
>             Fix For: ManifoldCF 1.3
>
>
> 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:
> {code}
>   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);
>   }
> {code}
> The exception returned is the following:
> {code}
> 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
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to