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

Zero-check PDH counter and instance lists, add English index lookup #988

Merged
merged 2 commits into from
Jul 21, 2018

Conversation

dbwiddis
Copy link
Contributor

The util methods I submitted in #973 do not handle zero-length results (e.g., no counters or instances) well, throwing an IllegalArgumentException when attempting to instantiate Memory. I've added checks to return sane values.

Also I've added a Util method that looks up the counter index from the English name using the registry, to permit easier localization of counter strings.

@dbwiddis dbwiddis force-pushed the pdhutil branch 5 times, most recently from 3bbfe7e to 53e5993 Compare July 14, 2018 17:14
// Can't allocate 0 memory
if (pcchCounterListLength.getValue().intValue() < 1 || pcchInstanceListLength.getValue().intValue() < 1) {
return counters;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible, that only one of the lists has content? I would special case the 0-elements case and replace the memory with a null pointer. From my experience that is the expected usage of the API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. If it's 0 you can null it and it works; but if it's nonzero you can't null it. I decided to go the route of just setting the "other" value to 0 and not asking for data I won't use.

@dbwiddis dbwiddis force-pushed the pdhutil branch 2 times, most recently from d318e62 to f937b4c Compare July 19, 2018 04:24
@matthiasblaesing matthiasblaesing merged commit 57a9dd0 into java-native-access:master Jul 21, 2018
@dbwiddis dbwiddis deleted the pdhutil branch July 21, 2018 16:34
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

Successfully merging this pull request may close these issues.

2 participants