[
https://issues.apache.org/jira/browse/JENA-1920?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17139430#comment-17139430
]
Andy Seaborne edited comment on JENA-1920 at 6/18/20, 10:45 PM:
----------------------------------------------------------------
Hi Andy,
The use of Random is not required, any non-null character would have been
sufficient.
I ran into JENA-1919 at the same time, they don't seem to be directly related,
that is to say one does not appear to cause the other, so I though it was best
to report them separately.
I found both issues while I was investigating some behavior with rdf-delta. For
this issue since the entire buffer is being flushed rather than the passed
length null characters are being sent to rdf-delta-server which in turn errs
while attempting to read a prefix or keyword
[TokenizerText.readPrefixedNameOrKeyword|https://github.com/apache/jena/blob/master/jena-arq/src/main/java/org/apache/jena/riot/tokens/TokenizerText.java]
was (Author: hoffman):
Hi Andy,
The use of Random is not required, any non-null character would have been
sufficient.
I ran into JENA-1919 at the same time, they don't seem to be directly related,
that is to say one does not appear to cause the other, so I though it was best
to report them separately.
I found both issues while I was investigating some behavior with rdf-delta. For
this issue since the entire buffer is being flushed rather than the passed
length null characters are being sent to rdf-delta-server which in turn errs
while attempting to read a prefix or keyword
[(TokenizerText.readPrefixedNameOrKeyword)|[https://github.com/apache/jena/blob/master/jena-arq/src/main/java/org/apache/jena/riot/tokens/TokenizerText.java].]
> BufferingWriter.java will flush the entirety of a char array despite provided
> length.
> -------------------------------------------------------------------------------------
>
> Key: JENA-1920
> URL: https://issues.apache.org/jira/browse/JENA-1920
> Project: Apache Jena
> Issue Type: Bug
> Components: Base
> Affects Versions: Jena 3.15.0
> Reporter: Matt Hoffman
> Priority: Major
>
> I observed that when flushing a largeBlob the entirety of a char array will
> be flushed out despite the length being provided indicating that only part of
> the char array is populated.
> The below unit test illustrates.
>
> {code:java}
> public void write_08 () {
> String alpha =
> "0123456789abcdefghijklmnopqrstuvwzyzABCDEFGHIJKLMNOPQRSTUVWZYZ";
> Random r = new Random();
> create(8192, 4096);
> //initialized at the max
> char[] randomChars = new char[8192];
> //define just enough to make it a 'large blob'
> for(int i = 0; i < 5000; i++){
> randomChars[i] = alpha.charAt(r.nextInt(alpha.length()));
> }
> w.output(randomChars,0, 5000);
> w.close();
> String x = string();
> assertEquals(5000, x.length());
> }
> {code}
> Results in
> {noformat}
> [ERROR] write_08(org.apache.jena.atlas.io.TestBufferingWriter) Time elapsed:
> 0.001 s <<< FAILURE!
> java.lang.AssertionError: expected:<5000> but was:<8192>
> at
> org.apache.jena.atlas.io.TestBufferingWriter.write_08(TestBufferingWriter.java:141){noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)