Skip to content

Commit 05a92f8

Browse files
fix(util): use using statement for JAction in Reset_AllowsReuse test (#611)
Fixes CodeQL alert cs/dispose-not-called-on-throw. If Execute(), Reset(), or Do() threw an exception, Dispose() would not be called. Using a using declaration ensures the JAction is disposed even if an exception occurs. Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9ecdfb8 commit 05a92f8

File tree

1 file changed

+1
-3
lines changed
  • UnityProject/Packages/com.jasonxudeveloper.jengine.util/Tests/Editor

1 file changed

+1
-3
lines changed

UnityProject/Packages/com.jasonxudeveloper.jengine.util/Tests/Editor/JActionTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ public void Reset_AllowsReuse()
473473
{
474474
int counter = 0;
475475

476-
var action = JAction.Create()
476+
using var action = JAction.Create()
477477
.Do(() => counter++);
478478

479479
action.Execute();
@@ -484,8 +484,6 @@ public void Reset_AllowsReuse()
484484
.Execute();
485485

486486
Assert.AreEqual(11, counter);
487-
488-
action.Dispose();
489487
}
490488

491489
#endregion

0 commit comments

Comments
 (0)