powsybl / powsybl-afs

AFS modules for powsybl
Mozilla Public License 2.0
3 stars 1 forks source link

Enforce chunk size in cassandra data output stream #56

Closed pl-buiquang closed 3 years ago

pl-buiquang commented 3 years ago

Signed-off-by: Paul Bui-Quang paul.buiquang@rte-france.com

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...) bug fix

What is the current behavior? (You can also link to an open issue here) Also (not fixed in this PR), the chunk size is not enforced if the write buffer length used with this outputstream is greater than the chunk size. For instance:

String nodeId = "someId";
String dataNodeName = "somedataname";
byte[] data = new byte[N]; // where N is greater than chunk size
Arrays.fill(data, (byte)0);
try(BinaryDataOutputStream os = new BinaryDataOutputStream(nodeId, dataNodeName))  {
  os.write(data); // will call os.write(data, 0, data.length)
}

will result in one only chunk written to database instead of the proper chunk count expected. Usually the OutputStream is wrapped in an other one that buffers the data way under the size of the configured chunk size, but this is no guarantee.

What is the new behavior (if this is a feature change)? The data is splitted accordingly.

sonarcloud[bot] commented 3 years ago

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

warning The version of Java (1.8.0_272) you have used to run this analysis is deprecated and we will stop accepting it accepting it soon.Please update to at least Java 11. Read more here