PMonitor icon indicating copy to clipboard operation
PMonitor copied to clipboard

Fixed Linux PIDs casting & added posibility to "disable" check from config.

Open aipirvu opened this issue 3 years ago • 0 comments

  • Changed the AbstractProcessMonitor so that it can properly handle situations where PMonitorNbOfProcesses key in appSettings is set to 0 or missing completly. This would be useful when it is desired to disable the check without redeploying the application that uses this library. I encountered a situation where it would have been helpful to disable the check in order to partial restore application functionality until I would figure out the issue causing the library to fail. Leading to the next change:
  • Changed the parsing of Linux PIDs from Int16 to Int32. This was causing a series of problems with large PIDs:
    • Could not be converted from String to short as the value is too large to be accommodated in this data type and exceptions was being thrown: image
    • This in turn leads to the exception being swallowed allowing the execution to continue creating the LinuxProcessStatusFile but without the Pid and FileName being set at all. Furthermore, the check is done on the LinuxProcessStatusFile being instantiated but its properties are never verified. image
    • Finally, the execution's only path (as I can tell) leads to the last line of code in GetProcessName method which attempts to trim the LinuxProcessStatusFile.FileName property just to end up in throwing a NullReferenceException: image
  • Changed to return null when the LinuxProcessStatusFile cannot be sucessfully build instead of an object but with invalid values.

aipirvu avatar Jan 14 '22 15:01 aipirvu