incubator-droids-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thorsten Scherler (JIRA)" <>
Subject [jira] Closed: (DROIDS-68) HandlerFactory fails with multithreaded implementation
Date Mon, 21 Dec 2009 14:14:18 GMT


Thorsten Scherler closed DROIDS-68.

    Resolution: Fixed

Committed revision 892828.

thanks Javier

> HandlerFactory fails with multithreaded implementation
> ------------------------------------------------------
>                 Key: DROIDS-68
>                 URL:
>             Project: Droids
>          Issue Type: Bug
>          Components: core
>         Environment: Ubuntu 9.04 i386
> Java Runtime 1.6_16
>            Reporter: Javier Puerto
>            Priority: Critical
>         Attachments: droids_concurrency.patch, droidsTest_concurrency.patch
> Hi, I'm working with Droids and made some URL crawlers to save a lot of web pages in
disk. In JUnit test, I run a little http server and crawl 20 pages, the most times everything
works ok but in rare cases I get an error. I found the problem in the HandlerFactory implementation,
in the example the call to handlers is like this:
> protected void handle(ContentEntity entity, Link link)
>     throws DroidsException, IOException
> {
>   droid.getHandlerFactory().handle(link.getURI(), entity);
> }
> If two or more workers is trying to handle at same time, the HandlerFactory will handle
with the same instance. The solution could be saving memory or improving performance.
> The first solution could be implemented adding a "synchronized" to HandlerFactory.handle
like this.
> public synchronized boolean handle(URI uri, ContentEntity entity)
>     throws DroidsException, IOException {
>   for (Handler handler : getMap().values()) {
>     handler.handle(uri, entity);
>   }
>   return true;
> }
> This solution works but it is a workaround.
> The real solution was discussed in the dev list and it was make the Droid and the GenericFactory
abstractions clonable and invoking the clone method in the Worker's constructor.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message