Skip to content

Possible to Encounter ConcurrentModificationException in SessionFactoryImpl #1464

@seabamirum

Description

@seabamirum

When running load tests with 40 threads using the Neo4j driver version 5.9.0, I encountered a ConcurrentModificationException in the toDistinctSet() method of SessionFactoryImpl.

Proposed Fix: on line 74 in the toDistinctSet method in SessionFactoryImpl, replace HashSet<>() with Collections.synchronizedSet(new HashSet<>())

Original Stack Trace:	at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1605) ~[na:na]	at java.base/java.util.HashMap$KeyIterator.next(HashMap.java:1628) ~[na:na]	at java.base/java.util.Collections$UnmodifiableCollection$1.next(Collections.java:1054) ~[na:na]	at org.neo4j.driver.internal.SessionFactoryImpl.toDistinctSet(SessionFactoryImpl.java:76) ~[neo4j-java-driver-5.9.0.jar:5.9.0-1250b2d94997ae49e5a623c52f61636505185057]	at org.neo4j.driver.internal.SessionFactoryImpl.newInstance(SessionFactoryImpl.java:64) ~[neo4j-java-driver-5.9.0.jar:5.9.0-1250b2d94997ae49e5a623c52f61636505185057]	at org.neo4j.driver.internal.InternalDriver.newSession(InternalDriver.java:218) ~[neo4j-java-driver-5.9.0.jar:5.9.0-1250b2d94997ae49e5a623c52f61636505185057]	at org.neo4j.driver.internal.InternalDriver.session(InternalDriver.java:108) ~[neo4j-java-driver-5.9.0.jar:5.9.0-1250b2d94997ae49e5a623c52f61636505185057]	at org.neo4j.driver.Driver.session(Driver.java:212) ~[neo4j-java-driver-5.9.0.jar:5.9.0-1250b2d94997ae49e5a623c52f61636505185057]	at org.springframework.data.neo4j.core.DefaultReactiveNeo4jClient.lambda$getQueryRunner$0(DefaultReactiveNeo4jClient.java:94) ~[spring-data-neo4j-7.1.2.jar:7.1.2]	at reactor.core.publisher.MonoSupplier$MonoSupplierSubscription.request(MonoSupplier.java:126) ~[reactor-core-3.5.8.jar:3.5.8] 

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