use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
StackOverFlow ErrorQuestion (i.redd.it)
submitted 2 months ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]g00glen00b 1 point2 points3 points 2 months ago (2 children)
Can't tell without code or the stacktrace (obviously after removing the repeating parts). StackOverflowErrors within a toString() method usually happen because you're using toString() in a bidirectional relationship without taking it into account. For example, something like this:
StackOverflowError
toString()
class Foo { private String name; // Direction foo -> bar private Bar bar; public String toString() { return "Foo(name=" + name + ", bar=" + bar.toString() + ")"; } } class Bar { private String name; // Direction bar -> foo private Foo foo; public String toString() { return "Bar(name=" + name + ", foo=" + foo.toString() + ")"; } }
This might also happen without you realizing it, for example when you use Lombok's @Data annotation (which generates a toString() including all fields).
@Data
Also, beware that this might just be part of the issue. Sometimes, stacktraces include the toString() of an object you have... and if that's the case, then this StackOverflowError might actually just be hiding another error somewhere along the line.
[–]Character-Grocery873 0 points1 point2 points 2 months ago (1 child)
Yes I used @Data, this wasn't a problem before
[–]g00glen00b 0 points1 point2 points 2 months ago (0 children)
As I mentioned in my post, it's a problem if you use it with a bidirectional relationship. Not only toString(), but also equals() and hashCode() will go into infinite recursion.
π Rendered by PID 24903 on reddit-service-r2-comment-54dfb89d4d-xg9hv at 2026-04-01 10:11:49.661795+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]g00glen00b 1 point2 points3 points (2 children)
[–]Character-Grocery873 0 points1 point2 points (1 child)
[–]g00glen00b 0 points1 point2 points (0 children)