assertj / assertj/assertj

OOM during StringBuilder in AssertionErrorMessagesAggregrator#aggregrateErrorMessages

未關閉
#1,908 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Java
星號
2.8k
分支
788
平均合併
14 小時 57 分鐘
30 天內合併 PR
36

描述

Summary

Building the string for an assertAll can lead to an OOM, it would be better to return a truncated message if the error count is larger than some configurable number - or at least add a defensive check and/or catch OOM to produce a more useful outcome than

Java heap space
java.lang.OutOfMemoryError: 
	at java.util.Arrays.copyOf(Arrays.java:3332)
	at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448)
	at java.lang.StringBuilder.append(StringBuilder.java:136)
	at org.assertj.core.error.AssertionErrorMessagesAggregrator.aggregrateErrorMessages(AssertionErrorMessagesAggregrator.java:25)
	at org.assertj.core.api.SoftAssertionError.<init>(SoftAssertionError.java:36)
	at org.assertj.core.error.AssertionErrorCreator.multipleSoftAssertionsError(AssertionErrorCreator.java:75)
	at org.assertj.core.api.SoftAssertions.assertAll(SoftAssertions.java:166)
	at com.redacted.testThing(Redacted.java:129)

This should be easy to repro.

Thanks for considering - I can submit a PR if that would help here.

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 AssertionErrorMessagesAggregrator.java:25 開始,追蹤 SoftAssertionError 和 SoftAssertions.assertAll 如何建構彙總訊息。使用足夠多的錯誤重現 assertAll 以觸發失敗,然後針對過大的訊息定義並驗證一種有界或其他防禦性的結果。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
java
領域
testing
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。