]
Dmitrii Tikhomirov reassigned WFLY-9897:
----------------------------------------
Assignee: Dmitrii Tikhomirov (was: Paul Ferraro)
getBytes(); calls should be replaced with
getBytes(StandardCharsets.UTF_8);
----------------------------------------------------------------------------
Key: WFLY-9897
URL:
https://issues.jboss.org/browse/WFLY-9897
Project: WildFly
Issue Type: Bug
Components: Clustering
Affects Versions: 12.0.0.Beta1
Reporter: Michal Vinkler
Assignee: Dmitrii Tikhomirov
There are several calls of method getBytes(); in clustering subsystem. These calls were
identified by Coverity static code analysis as dubious [1]. getBytes() depends on
platform's default charset [2]. This will cause the application behaviour to vary
between platforms.
Better solution would imho be getBytes(StandardCharsets.UTF_8);
Occurrences:
{code}
./jgroups/extension/src/main/java/org/jboss/as/clustering/jgroups/subsystem/DigestAuthTokenBuilder.java:60:
return new BinaryAuthToken(digest.digest(sharedSecret.getBytes()));
./jgroups/extension/src/main/java/org/jboss/as/clustering/jgroups/subsystem/PlainAuthTokenBuilder.java:39:
return new BinaryAuthToken(sharedSecret.getBytes());
./jgroups/extension/src/main/java/org/jboss/as/clustering/jgroups/subsystem/CipherAuthTokenBuilder.java:105:
return new CipherAuthToken(cipher, pair, authValue.getBytes());
./marshalling/jboss/src/test/java/org/wildfly/clustering/marshalling/jboss/SimpleMarshalledValueFactoryTestCase.java:93:
assertNull(mv.getBytes());
./marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/HashableMarshalledValueExternalizer.java:50:
return new HashableMarshalledValue<>(value.getBytes(), hashCode);
./marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/SimpleMarshalledValue.java:67:
byte[] getBytes() throws IOException {
./marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/SimpleMarshalledValue.java:135:
byte[] us = this.getBytes();
./marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/SimpleMarshalledValue.java:136:
byte[] them = value.getBytes();
./marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/SimpleMarshalledValue.java:152:
byte[] bytes = this.getBytes();
./marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/SimpleMarshalledValueExternalizer.java:51:
byte[] bytes = object.getBytes();
{code}
[1]
http://station5.brq.redhat.com:8080/docs/en/findbugs/fb_checker_ref.html#...
[2]
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#getBytes--