Skip to content

CachedIntrospectionResults Not Thread Safe [SPR-9584] #14218

Closed

Description

@spring-projects-issues

elliot barlas opened SPR-9584 and commented

My Spring web application invokes org.springframework.beans.BeanUtils.getPropertyDescriptors in a multi-threaded context. After recent code refactoring, I started noticing something strange: the call occasionally returns an incomplete set of property descriptors. The code change must have produced paths that randomly execute getPropertyDescriptors at exactly the same time. I have written a targeted Java app to demonstrate the problem.

Attached is Main.java, a simple Java app that lines up threads and then invokes getPropertyDescriptors in parallel.

The beans are modeled after my application beans.

When I run the app continuously, failures eventually occur:
for i in {1..1000}; do java -cp <jar path> test.Main 50; done
Fail: 8
Fail: 3
Fail: 8
...

I haven't yet taken the time to identify the thread-safety issue.


Affects: 3.1 GA

Attachments:

Issue Links:

Referenced from: commits spring-attic/spring-framework-issues@96899fe, spring-attic/spring-framework-issues@16d97dc

2 votes, 3 watchers

Activity

  1. spring-projects-issues commented on Jul 11, 2012

    @spring-projects-issues
    CollaboratorAuthor

    elliot barlas commented

    One point that I missed: making verifyDescriptors synchronized solves the problem.

  2. spring-projects-issues commented on Oct 23, 2012

    @spring-projects-issues
    CollaboratorAuthor

    elliot barlas commented

    Any reason this hasn't received much attention? This is a critical bug which caused serious problems in my web application.

  3. spring-projects-issues commented on Oct 23, 2012

    @spring-projects-issues
    CollaboratorAuthor

    Chris Beams commented

    Hi Elliot,

    Could you quickly verify that you get the same results against the latest 3.2.0.BUILD-SNAPSHOT artifacts (available from http://repo.springsource.org/snapshot)? There have been a number of changes to CachedIntrospectionResults and it would be good to confirm you're seeing the same behavior.

  4. spring-projects-issues commented on Oct 23, 2012

    @spring-projects-issues
    CollaboratorAuthor

    elliot barlas commented

    Yes, I'll try this now...

  5. spring-projects-issues commented on Oct 23, 2012

    @spring-projects-issues
    CollaboratorAuthor

    elliot barlas commented

    After many attempts, I was not able to reproduce the issue with version 3.2.0.BUILD-SNAPSHOT. I guess it's fixed?

  6. spring-projects-issues commented on Oct 23, 2012

    @spring-projects-issues
    CollaboratorAuthor

    Chris Beams commented

    Hi Elliot, thanks for verifying that. I had a strong suspicion that the changes made in #14357 would have eliminated the problem, and it looks like they did.

    The short story there is that #14357 removes ExtendedBeanInfo from the code path for 99% (perhaps more) of all use cases of CachedIntrospectionResults. This means that there may well be a concurrency issue in ExtendedBeanInfo, but that it has been neutralized for almost all users.

    Note that #14357 is not being backported to the 3.1.x line, which means that this issue could still crop up for users there, but at this time, I'm marking the issue won't fix because (a) no one else has reported it yet, i.e. it's probably an unlikely scenario, (b) it's fixed in 3.2, (c) any fix to ExtendedBeanInfo would probably represent more trouble than it's worth in terms of committer time and effort.

  7. spring-projects-issues commented on Nov 25, 2012

    @spring-projects-issues
    CollaboratorAuthor

    Chris Beams commented

    A general note to watchers of ExtendedBeanInfo-related issues: #14663 is a major refactoring of ExtendedBeanInfo and overall support for non-void returning setter methods.

    If you have submitted a reproduction project with this issue, we have run it through its paces against these new changes, but we would like to ask you to do the same against your actual applications.

    Please consider updating your dev or test builds to work against 3.1.4.BUILD-SNAPSHOT and/or 3.2.0.BUILD-SNAPSHOT to verify, and we would appreciate any feedback, even if it's to let us know that all is well. So that we can consolidate feedback, please add your comments to #14663, and mention the original issue(s) that you were watching.

    Thanks!

    Note also that testing against 3.1.4 is preferable to 3.2.0 because ExtendedBeanInfo is always in the code path in the latter, while in 3.2.0 we've optimized things such that ExtendedBeanInfo is only in play for bean classes that have one or more non-void returning setter methods.

  8. added
    type: bug
    status: declined
    in: core
    and removed
    type: bug
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: corestatus: declined

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions