[
https://issues.apache.org/jira/browse/JENA-1920?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Matt Hoffman updated JENA-1920:
-------------------------------
Description:
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}
was:
I observed that when the 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}
> 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)