You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Erik Antelman <ea...@gmail.com> on 2011/09/23 21:22:08 UTC

Understanding ConcurrentModificationException()

Okay, so I have a GenericRuleReasoner instance with a hybrid configuration.
I do some SPARQLCONSTRUCT on that InfModel and then add the results back
into the InfModel.
Everything looks like it works fine.

Then I wanted to iterate over the model and compute something new assertions
myself. Being a newbie I used
 StmtIterator sceneIter = sourceModel.listStatements(select);

-- 
for(;;); /* eantelman@gmail.com */

Re: Understanding ConcurrentModificationException()

Posted by Andy Seaborne <an...@apache.org>.
On 26/09/11 14:14, Erik Antelman wrote:
> Sorry for not updating. Ignazio was right, there was in fact a place where I
> was updating the model within the scope of the iterator.
> Silly me.
>
> Thank you for the response and concern though.

No problem, it being something that's quite easy to do - if we had fully 
immutable state and functional programming languages ... then we'd have 
a whole category of other issues but no CME.

	Andy

>
> On Sun, Sep 25, 2011 at 3:14 PM, Andy Seaborne<an...@apache.org>  wrote:
>
>> Erik,
>>
>> Could you provide a complete, minimal example as a test case, please?
>>
>>         Thanks
>>         Andy
>>
>>
>> On 23/09/11 21:15, Erik Antelman wrote:
>>
>>> No I am collecting any statements during the iterator into a temp model
>>> (or
>>> actually in some cases into a string that I read into a temp model and
>>> then
>>> .add to the InfModel.
>>> The CME occurs during simply iterating.
>>>
>>> I went ahead and re-wrote the code with the
>>> com.hp.hpl.jena.util.iterator.**ExtendedIterator<Triple>   from the
>>> Graph.find
>>> method.
>>>
>>> It does seem to work, but is a bit more detailed (since it's dealing with
>>> Triples instead of Statements.
>>>
>>> What's the design thinking behind this restriction?
>>>
>>> On Fri, Sep 23, 2011 at 3:38 PM, Ignazio Palmisano<
>>> ipalmisano.mailings@gmail.com>   wrote:
>>>
>>>   On 23 September 2011 20:22, Erik Antelman<ea...@gmail.com>   wrote:
>>>>
>>>>> Okay, so I have a GenericRuleReasoner instance with a hybrid
>>>>>
>>>> configuration.
>>>>
>>>>> I do some SPARQLCONSTRUCT on that InfModel and then add the results back
>>>>> into the InfModel.
>>>>> Everything looks like it works fine.
>>>>>
>>>>> Then I wanted to iterate over the model and compute something new
>>>>>
>>>> assertions
>>>>
>>>>> myself. Being a newbie I used
>>>>>
>>>>
>>>> That's likely the issue. Are you adding new statements while
>>>> iterating? That's likely modifying the structures you're iterating
>>>> over, which is a lileky cause for CME.
>>>> HTH,
>>>> I.
>>>>
>>>>    StmtIterator sceneIter = sourceModel.listStatements(**select);
>>>>>
>>>>> --
>>>>> for(;;); /* eantelman@gmail.com */
>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>
>
>


Re: Understanding ConcurrentModificationException()

Posted by Erik Antelman <ea...@gmail.com>.
Sorry for not updating. Ignazio was right, there was in fact a place where I
was updating the model within the scope of the iterator.
Silly me.

Thank you for the response and concern though.

On Sun, Sep 25, 2011 at 3:14 PM, Andy Seaborne <an...@apache.org> wrote:

> Erik,
>
> Could you provide a complete, minimal example as a test case, please?
>
>        Thanks
>        Andy
>
>
> On 23/09/11 21:15, Erik Antelman wrote:
>
>> No I am collecting any statements during the iterator into a temp model
>> (or
>> actually in some cases into a string that I read into a temp model and
>> then
>> .add to the InfModel.
>> The CME occurs during simply iterating.
>>
>> I went ahead and re-wrote the code with the
>> com.hp.hpl.jena.util.iterator.**ExtendedIterator<Triple>  from the
>> Graph.find
>> method.
>>
>> It does seem to work, but is a bit more detailed (since it's dealing with
>> Triples instead of Statements.
>>
>> What's the design thinking behind this restriction?
>>
>> On Fri, Sep 23, 2011 at 3:38 PM, Ignazio Palmisano<
>> ipalmisano.mailings@gmail.com>  wrote:
>>
>>  On 23 September 2011 20:22, Erik Antelman<ea...@gmail.com>  wrote:
>>>
>>>> Okay, so I have a GenericRuleReasoner instance with a hybrid
>>>>
>>> configuration.
>>>
>>>> I do some SPARQLCONSTRUCT on that InfModel and then add the results back
>>>> into the InfModel.
>>>> Everything looks like it works fine.
>>>>
>>>> Then I wanted to iterate over the model and compute something new
>>>>
>>> assertions
>>>
>>>> myself. Being a newbie I used
>>>>
>>>
>>> That's likely the issue. Are you adding new statements while
>>> iterating? That's likely modifying the structures you're iterating
>>> over, which is a lileky cause for CME.
>>> HTH,
>>> I.
>>>
>>>   StmtIterator sceneIter = sourceModel.listStatements(**select);
>>>>
>>>> --
>>>> for(;;); /* eantelman@gmail.com */
>>>>
>>>>
>>>
>>
>>
>>
>


-- 
for(;;); /* eantelman@gmail.com */

Re: Understanding ConcurrentModificationException()

Posted by Andy Seaborne <an...@apache.org>.
Erik,

Could you provide a complete, minimal example as a test case, please?

	Thanks
	Andy

On 23/09/11 21:15, Erik Antelman wrote:
> No I am collecting any statements during the iterator into a temp model (or
> actually in some cases into a string that I read into a temp model and then
> .add to the InfModel.
> The CME occurs during simply iterating.
>
> I went ahead and re-wrote the code with the
> com.hp.hpl.jena.util.iterator.ExtendedIterator<Triple>  from the Graph.find
> method.
>
> It does seem to work, but is a bit more detailed (since it's dealing with
> Triples instead of Statements.
>
> What's the design thinking behind this restriction?
>
> On Fri, Sep 23, 2011 at 3:38 PM, Ignazio Palmisano<
> ipalmisano.mailings@gmail.com>  wrote:
>
>> On 23 September 2011 20:22, Erik Antelman<ea...@gmail.com>  wrote:
>>> Okay, so I have a GenericRuleReasoner instance with a hybrid
>> configuration.
>>> I do some SPARQLCONSTRUCT on that InfModel and then add the results back
>>> into the InfModel.
>>> Everything looks like it works fine.
>>>
>>> Then I wanted to iterate over the model and compute something new
>> assertions
>>> myself. Being a newbie I used
>>
>> That's likely the issue. Are you adding new statements while
>> iterating? That's likely modifying the structures you're iterating
>> over, which is a lileky cause for CME.
>> HTH,
>> I.
>>
>>>   StmtIterator sceneIter = sourceModel.listStatements(select);
>>>
>>> --
>>> for(;;); /* eantelman@gmail.com */
>>>
>>
>
>
>


Re: Understanding ConcurrentModificationException()

Posted by Erik Antelman <ea...@gmail.com>.
No I am collecting any statements during the iterator into a temp model (or
actually in some cases into a string that I read into a temp model and then
.add to the InfModel.
The CME occurs during simply iterating.

I went ahead and re-wrote the code with the
com.hp.hpl.jena.util.iterator.ExtendedIterator<Triple> from the Graph.find
method.

It does seem to work, but is a bit more detailed (since it's dealing with
Triples instead of Statements.

What's the design thinking behind this restriction?

On Fri, Sep 23, 2011 at 3:38 PM, Ignazio Palmisano <
ipalmisano.mailings@gmail.com> wrote:

> On 23 September 2011 20:22, Erik Antelman <ea...@gmail.com> wrote:
> > Okay, so I have a GenericRuleReasoner instance with a hybrid
> configuration.
> > I do some SPARQLCONSTRUCT on that InfModel and then add the results back
> > into the InfModel.
> > Everything looks like it works fine.
> >
> > Then I wanted to iterate over the model and compute something new
> assertions
> > myself. Being a newbie I used
>
> That's likely the issue. Are you adding new statements while
> iterating? That's likely modifying the structures you're iterating
> over, which is a lileky cause for CME.
> HTH,
> I.
>
> >  StmtIterator sceneIter = sourceModel.listStatements(select);
> >
> > --
> > for(;;); /* eantelman@gmail.com */
> >
>



-- 
for(;;); /* eantelman@gmail.com */

Re: Understanding ConcurrentModificationException()

Posted by Ignazio Palmisano <ip...@gmail.com>.
On 23 September 2011 20:22, Erik Antelman <ea...@gmail.com> wrote:
> Okay, so I have a GenericRuleReasoner instance with a hybrid configuration.
> I do some SPARQLCONSTRUCT on that InfModel and then add the results back
> into the InfModel.
> Everything looks like it works fine.
>
> Then I wanted to iterate over the model and compute something new assertions
> myself. Being a newbie I used

That's likely the issue. Are you adding new statements while
iterating? That's likely modifying the structures you're iterating
over, which is a lileky cause for CME.
HTH,
I.

>  StmtIterator sceneIter = sourceModel.listStatements(select);
>
> --
> for(;;); /* eantelman@gmail.com */
>