I have got a recurring sonar issue to "Remove this use of constructor "String(byte[])". One of the example is of the code below:
byte[] d = c.doFinal(e);
return new String(d);
I do not know why this is popping up. Any help is welcome. Thanks.
I have got a recurring sonar issue to "Remove this use of constructor "String(byte[])". One of the example is of the code below:
byte[] d = c.doFinal(e);
return new String(d);
I do not know why this is popping up. Any help is welcome. Thanks.
Sonar says:
Using classes and methods that rely on the default system encoding can result in code that works fine in its "home" environment. But that code may break for customers who use different encodings in ways that are extremely difficult to diagnose and nearly, if not completely, impossible to reproduce when it's time to fix them.
you should use the String(byte bytes[], Charset charset) constructor instead
you can read more about it here: https://gazelle.ihe.net/sonar/coding_rules#rule_key=squid%3AS1943