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

StackOverflowError with self-relations using Java collections #1

Open
pereirazc opened this issue Feb 4, 2017 · 0 comments
Open

StackOverflowError with self-relations using Java collections #1

pereirazc opened this issue Feb 4, 2017 · 0 comments

Comments

@pereirazc
Copy link
Contributor

The Drools runtime throws StackOverflowError when a self-relation scenario (bellow) happens
image
The self-relation friends causes a loop when the engine calls toStringfor the List class because in a situation of Friendship between A and B, A is inside of B's friends and vice-versa.

declare Person
    id: int
    name: String
    friends: List
end

declare Friendship extends Situation
    friendA: Person @part(label = "a")
    friendB: Person @part(label = "b")
end

rule Friendship
@role(situation)
@type(Friendship)
 when
    a: Person()
    b: Person(this != a)
 then
    SituationHelper.situationDetected(drools);
 end

The problem is AbstractCollection's toString method, a quick solution would be to offer our own List class reimplementing toString.

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

No branches or pull requests

1 participant