mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-11-27 10:00:57 +00:00
updated pr-agent best practices with auto analysis
parent
c7e39401ed
commit
ea4f138cce
|
|
@ -1,3 +1,56 @@
|
|||
<!-- PR --><table><tr><td> <b><a href='https://github.com/gnh1201/welsonjs/pull/330#issuecomment-3342945176'>PR 330</a></b> (2025-09-28)
|
||||
|
||||
</td></tr></table>
|
||||
|
||||
|
||||
|
||||
<!-- suggestion --><details><summary>[possible issue] Fix a file handle leak</summary>
|
||||
|
||||
___
|
||||
|
||||
✅ Fix a file handle leak
|
||||
|
||||
**To prevent a file handle leak, move the FileStream and StreamWriter creation inside the if block so they are only instantiated when a new trace listener is actually added.**
|
||||
|
||||
[WelsonJS.Toolkit/WelsonJS.Launcher/TraceLogger.cs [47-57]](https://github.com/gnh1201/welsonjs/pull/330/files#diff-1c64dc458a9c5d10aefc6236be3d746a16d152b194a86cff3aead853a35b395eR47-R57)
|
||||
|
||||
```diff
|
||||
_logFilePath = Path.Combine(baseDir, $"{ns}.{suffix}.pid{pid}.log");
|
||||
-
|
||||
-var fs = new FileStream(_logFilePath, FileMode.Append, FileAccess.Write, FileShare.Read);
|
||||
-var writer = new StreamWriter(fs) { AutoFlush = true };
|
||||
|
||||
if (!Trace.Listeners.OfType<TextWriterTraceListener>().Any())
|
||||
{
|
||||
+ var fs = new FileStream(_logFilePath, FileMode.Append, FileAccess.Write, FileShare.Read);
|
||||
+ var writer = new StreamWriter(fs) { AutoFlush = true };
|
||||
Trace.Listeners.Add(new TextWriterTraceListener(writer)
|
||||
{
|
||||
Name = "FileTraceListener",
|
||||
TraceOutputOptions = TraceOptions.DateTime
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Suggestion importance[1-10]: 9
|
||||
|
||||
__
|
||||
|
||||
Why: The suggestion correctly identifies a resource leak bug where a `FileStream` handle is not disposed if a trace listener already exists, and the proposed change effectively fixes it.
|
||||
|
||||
___
|
||||
|
||||
</details>
|
||||
|
||||
___
|
||||
|
||||
|
||||
|
||||
<!-- PR --><table><tr><td> <b><a href='https://github.com/gnh1201/welsonjs/pull/323#issuecomment-3222497708'>PR 323</a></b> (2025-08-26)
|
||||
|
||||
</td></tr></table>
|
||||
|
|
@ -124,6 +177,8 @@ ___
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- PR --><table><tr><td> <b><a href='https://github.com/gnh1201/welsonjs/pull/320#issuecomment-3204803405'>PR 320</a></b> (2025-08-20)
|
||||
|
||||
</td></tr></table>
|
||||
|
|
@ -268,6 +323,8 @@ ___
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- PR --><table><tr><td> <b><a href='https://github.com/gnh1201/welsonjs/pull/318#issuecomment-3194328108'>PR 318</a></b> (2025-08-17)
|
||||
|
||||
</td></tr></table>
|
||||
|
|
@ -439,6 +496,8 @@ ___
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- PR --><table><tr><td> <b><a href='https://github.com/gnh1201/welsonjs/pull/309#issuecomment-3172799544'>PR 309</a></b> (2025-08-10)
|
||||
|
||||
</td></tr></table>
|
||||
|
|
@ -487,6 +546,8 @@ ___
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- PR --><table><tr><td> <b><a href='https://github.com/gnh1201/welsonjs/pull/307#issuecomment-3154116053'>PR 307</a></b> (2025-08-05)
|
||||
|
||||
</td></tr></table>
|
||||
|
|
@ -584,6 +645,8 @@ ___
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- PR --><table><tr><td> <b><a href='3055522397'>PR 284</a></b> (2025-07-10)
|
||||
|
||||
</td></tr></table>
|
||||
|
|
@ -660,6 +723,8 @@ ___
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- PR --><table><tr><td> <b><a href='3006712754'>PR 279</a></b> (2025-06-26)
|
||||
|
||||
</td></tr></table>
|
||||
|
|
@ -718,6 +783,8 @@ ___
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- PR --><table><tr><td> <b><a href='2982794401'>PR 276</a></b> (2025-06-18)
|
||||
|
||||
</td></tr></table>
|
||||
|
|
@ -773,6 +840,8 @@ ___
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- PR --><table><tr><td> <b><a href='2953770469'>PR 272</a></b> (2025-06-08)
|
||||
|
||||
</td></tr></table>
|
||||
|
|
@ -837,6 +906,8 @@ ___
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- PR --><table><tr><td> <b><a href='2868572186'>PR 249</a></b> (2025-05-10)
|
||||
|
||||
|
|
@ -911,6 +982,8 @@ ___
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1044,6 +1117,8 @@ ___
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1146,6 +1221,8 @@ ___
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user