Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in ProcessInfo.stringFormat #39

Open
romikk opened this issue Mar 11, 2016 · 2 comments
Open

NullPointerException in ProcessInfo.stringFormat #39

romikk opened this issue Mar 11, 2016 · 2 comments

Comments

@romikk
Copy link

romikk commented Mar 11, 2016

Got below exception when running on Linux:

$ uname -a
Linux lonsl1100576 2.6.32-573.12.1.el6.x86_64 #1 SMP Mon Nov 23 12:55:32 EST 2015 x86_64 x86_64 x86_64 GNU/Linux
$ /apps/java/64/jdk1.8.0_45/bin/java -cp "lib/javasysmon-0.3.5.jar" com.jezhumble.javasysmon.JavaSysMon
..skipped output...
Exception in thread "main" java.lang.NullPointerException
        at com.jezhumble.javasysmon.ProcessInfo.stringFormat(ProcessInfo.java:184)
        at com.jezhumble.javasysmon.ProcessInfo.stringFormat(ProcessInfo.java:179)
        at com.jezhumble.javasysmon.ProcessInfo.toString(ProcessInfo.java:160)
        at com.jezhumble.javasysmon.JavaSysMon.main(JavaSysMon.java:98)
@rich-coe
Copy link

One of the process entries in your system is causing the issue.
The 3 strings passed to ProcessInfo from LinuxProcessInfoParser are command, name, and owner.
If command was null, it would have had an exception in LinuxProcessInfoParser.
I suspect it is either name or owner. Owner cannot be blank.
In /proc/PID/status of the bad process, the 'Name:' field is blank.

One could argue that javasysmon shouldn't fail on blank 'name' but one could also argue processes shouldn't have blank process names either.

To fix javasysmon, getFirstMatch() in LinuxProcessInfoParser should return "" if matcher.group(1) is null.

@romikk
Copy link
Author

romikk commented Mar 12, 2016

I don't think that asking people to change their processes on the server because one of the libraries can't survive an empty name is a valid response here.
It is simply not always possible in production environment shared my multiple teams.
To me the fix looks trivial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants