The documentation for the CharMatcher.countIn method does not state the expected behaviour if the input sequence is null. The user may expect the method to return 0 for such a case but the implementation throws NullPointerException (which could also be considered as a valid output). This ambiguity should be explicitly clarified in the documentation or else handled well in the code.
"Guava's utilities are designed to fail fast in the presence of null rather than allow nulls to be used, so long as there is a null-friendly workaround available" (wiki/UsingAndAvoidingNullExplained)
I would say that NPE is expected by default.
As for workaround, you can use Strings.nullToEmpty to normalize your string before passing it to CharMatcher.countIn.
Most helpful comment
I would say that NPE is expected by default.
As for workaround, you can use
Strings.nullToEmptyto normalize your string before passing it toCharMatcher.countIn.