openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ioannis Alexandrakis (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OPENJPA-2507) Weird EmptyStackException in CriteriaQueryImpl
Date Wed, 28 May 2014 07:04:02 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-2507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14010860#comment-14010860
] 

Ioannis Alexandrakis commented on OPENJPA-2507:
-----------------------------------------------

I have not seen the source of spring-data very closely to see if it caches CriteriaQueryImpl
(even though after your comment I suspect that that is the case, or something of the sort,
like modifying the contexts using get/setContexts), but since this class was never intended
to be accessed by multiple threads, then there is no reason to protect that part of the class
only.

However, Stacks' methods are synchronized and there is only a setter for contexts (these are
the main differences from the other Maps/Lists inside CriteriaQueryImpl), perhaps if there
is an explanation to the problem would be related to those. I am not saying this is worth
the effort, but I am just curious as to why we have a problem with the specific method (Context
ctx()) in two tickets which are probably related.

Just to mention it, since I tested the proposed fix myself, I haven't seen something related
to CriteriaQueryImpl again.

> Weird EmptyStackException in CriteriaQueryImpl
> ----------------------------------------------
>
>                 Key: OPENJPA-2507
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2507
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: criteria
>    Affects Versions: 2.2.0, 2.3.0
>         Environment: openjpa 2.2.0 & 2.3.0, spring-data-jpa up to 1.4.2
>            Reporter: Ioannis Alexandrakis
>            Priority: Minor
>              Labels: criteria_api, openjpa
>
> Using spring-data-jpa with openjpa, I sometimes encounter a strange error (not all the
times, but under heavy load it makes its appearance, sparsely though):
> ....
> Caused by: java.util.EmptyStackException
>         at java.util.Stack.peek(Stack.java:<arbitrary line>)
>         at org.apache.openjpa.persistence.criteria.CriteriaQueryImpl.ctx(CriteriaQueryImpl.java:<arbitrary
line>
> ....
> I do not know which behaviour triggers it, however I think it would be an improvement
to change (I did not know where exactly to file it, because it is both an improvement and
a bug in my opinion), in org.apache.openjpa.persistence.criteria.CriteriaQueryImpl, method:
Context ctx(), this:
> return _contexts == null || _contexts.isEmpty() ? null :  _contexts.peek();
> to something like this:
> try {
> 	return _contexts == null || _contexts.isEmpty() ? null :  _contexts.peek();
> } catch (EmptyStackException e) {
>     return null;
> }
> , in order to prevent a case where multiple threads modify the "_contexts" between the
evaluation of the inline "if".
> I am not able to reproduce it all the time, thus I can't create a useful test, neither
have I created a patch due to the simplicity of the 'fix'. However I believe it is a harmless
fix which could be considered a minor improvement.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message