Skip to content
This repository was archived by the owner on Aug 26, 2021. It is now read-only.
This repository was archived by the owner on Aug 26, 2021. It is now read-only.

Object Graph circular dependency check is not thread safe #459

@dalewking

Description

@dalewking

Was experiencing some occasional, random array index out of bounds exceptions from circular dependency check in graph validation and looking at the code it occurs to me that the code for circular dependency checking is not thread safe. It sets a visiting flag on the binding to mark that it is currently visiting it. But if another thread happens to be validating the same graph this can lead to problems. If a binding is visited on another thread the current thread will see the binding as visited. When it tries to compose a nice message of the cycle it starts at the index of the binding in its path, but the current path has not actually visited it so does not have that binding in its path thus the Array index out of bounds exception.

In our case the multiple threads was due to the fact that we use Dagger to also inject some services and it was always the injection for a service that failed. If they happened to be started at the same time as an injection for the UI we get the exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions