Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConcurrentModificationException from SequentialSpace class #21

Open
Uabanur opened this issue Jan 14, 2018 · 1 comment
Open

ConcurrentModificationException from SequentialSpace class #21

Uabanur opened this issue Jan 14, 2018 · 1 comment

Comments

@Uabanur
Copy link

Uabanur commented Jan 14, 2018

When performing queryAll on a SequentialSpace in a SpaceRepository, ConcurrentModificationExceptions are occasionally thrown. The code where this is observed most often is:

    public String[] getUsers()
    {
        List<Object[]> users = this.queryAll(new FormalField(String.class));
        String[] users_string = new String[users.size()];
        for (int i = 0; i < users.size(); i++)
        {
            users_string[i] = (String) users.get(i)[0];
        }

        return users_string;
    }

Here the ConcurrentModificationException is thrown from the line with queryAll(...). Looking in the SequentialSpace class, we see that the methods findTuple(...)and findAllTuples(...)are not synchronised in the java monitor.

This may be a deliberate choice to make it possible to query concurrently for several threads, but the concurrent exceptions are thrown since the found elements are returned, instead of a copy of their data.

@michele-loreti
Copy link
Member

Both the methods findTuple(...) and findAllTuple(...) are only used in methods that are synchronized. For this reason the exception cannot originates from them. Note that ConcurrentModificationExceptions is generated when the content of an Iterable is changed while it is subject of an iteration (foreach statement). Please, can you share the stack trace you get?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants