pmd: fix #1134 UseStringBufferLength false positives

This change fixes the false positives triggered by UseStringBufferLength from [bug #1134](https://sourceforge.net/p/pmd/bugs/1134/).