Closed beForged closed 4 years ago
Could you please get a thread dump of the hanging JVM?
I did a thread dump and found out that it probably was a naive toString() implementation on my side that ended up causing this hang to occur. I would argue that the reliance on toString() should probably be mentioned somewhere, since this was quite a difficult bug to track down (and I misinterpreted it at first)
Well, what else would assertEquals()
call to create a String representation of the arguments in case of failure? I don't think documenting that it calls toString()
would be helpful. Thus, I'm closing this issue. If you feel strongly that this needs to be addressed, please feel free to comment or raise a new, more focussed, issue.
Ran across this issue when doing property based testing mostly, but if the toString() of the objects compared are too large and they fail, assertEquals will attempt to return the strings as a message and will hang. I haven't found anywhere where this is documented, and was quite difficult to actually diagnose since I assumed that the test was failing due to code timing out, not JUnit timing out, so suggest either doing some sort of default response if the message string is too large, having a cutoff for length where the message is truncated, or somehow making it a little clearer why the test is hanging.