mirror of
https://github.com/apache/commons-csv.git
synced 2025-02-14 14:06:12 +00:00
[CSV-311] OutOfMemory for very long rows despite using column value of
type Reader
This commit is contained in:
parent
699b858c4c
commit
fca97cd9ce
@ -50,6 +50,7 @@
|
||||
<action type="fix" dev="ggregory" due-to="step-security-bot">[StepSecurity] CI: Harden GitHub Actions #329, #330.</action>
|
||||
<action type="fix" issue="CSV-147" dev="ggregory" due-to="Steven Peterson, Benedikt Ritter, Gary Gregory, Joerg Schaible, Buddhi De Silva, Elliotte Rusty Harold">Better error message during faulty CSV record read #347.</action>
|
||||
<action type="fix" issue="CSV-310" dev="ggregory" due-to="Buddhi De Silva">Misleading error message when QuoteMode set to None #352.</action>
|
||||
<action type="fix" issue="CSV-311" dev="ggregory" due-to="Christian Feuersaenger, Gary Gregory">OutOfMemory for very long rows despite using column value of type Reader.</action>
|
||||
<!-- UPDATE -->
|
||||
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-io:commons-io: from 2.11.0 to 2.15.1.</action>
|
||||
<action type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">Bump commons-parent from 57 to 67.</action>
|
||||
|
@ -2325,28 +2325,13 @@ public final class CSVFormat implements Serializable {
|
||||
final char quote = getQuoteCharacter().charValue();
|
||||
// (1) Append opening quote
|
||||
append(quote, appendable);
|
||||
// (2) Append Reader content
|
||||
final StringBuilder builder = new StringBuilder(IOUtils.DEFAULT_BUFFER_SIZE);
|
||||
// (2) Append Reader contents, doubling quotes
|
||||
int c;
|
||||
int pos = 0;
|
||||
while (EOF != (c = reader.read())) {
|
||||
builder.append((char) c);
|
||||
append((char) c, appendable);
|
||||
if (c == quote) {
|
||||
// Append current segment
|
||||
if (pos > 0) {
|
||||
append(builder.toString(), appendable);
|
||||
// Recycle builder
|
||||
builder.setLength(0);
|
||||
pos = -1;
|
||||
}
|
||||
// Append nested quote
|
||||
append(quote, appendable);
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
// Append last segment
|
||||
if (pos > 0) {
|
||||
append(builder.substring(0, pos), appendable);
|
||||
}
|
||||
// (3) Append closing quote
|
||||
append(quote, appendable);
|
||||
|
Loading…
x
Reference in New Issue
Block a user