You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ra...@apache.org on 2021/09/17 06:05:26 UTC
[olingo-odata4] branch master updated: [OLINGO-1547]Avoid
BufferOverFlowException in BatchLineReader
This is an automated email from the ASF dual-hosted git repository.
ramyav pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/olingo-odata4.git
The following commit(s) were added to refs/heads/master by this push:
new e429cb2 [OLINGO-1547]Avoid BufferOverFlowException in BatchLineReader
e429cb2 is described below
commit e429cb24ad2415679e6c3da415cb426ff690d8c9
Author: ramya vasanth <ra...@sap.com>
AuthorDate: Fri Sep 17 11:35:14 2021 +0530
[OLINGO-1547]Avoid BufferOverFlowException in BatchLineReader
---
.../core/deserializer/batch/BatchLineReader.java | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReader.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReader.java
index be1b0e6..16eeb3f 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReader.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReader.java
@@ -145,12 +145,7 @@ public class BatchLineReader {
if (!foundLineEnd) {
byte currentChar = buffer[offset++];
- if (!innerBuffer.hasRemaining()) {
- innerBuffer.flip();
- ByteBuffer tmp = ByteBuffer.allocate(innerBuffer.limit() * 2);
- tmp.put(innerBuffer);
- innerBuffer = tmp;
- }
+ innerBuffer = grantBuffer(innerBuffer);
innerBuffer.put(currentChar);
if (currentChar == LF) {
@@ -166,6 +161,7 @@ public class BatchLineReader {
// Check if there is at least one character
if (limit != EOF && buffer[offset] == LF) {
+ innerBuffer = grantBuffer(innerBuffer);
innerBuffer.put(LF);
offset++;
}
@@ -183,6 +179,16 @@ public class BatchLineReader {
}
}
+ private ByteBuffer grantBuffer(ByteBuffer buffer) {
+ if(!buffer.hasRemaining()) {
+ buffer.flip();
+ ByteBuffer tmp = ByteBuffer.allocate(buffer.limit() *2);
+ tmp.put(buffer);
+ buffer = tmp;
+ }
+ return buffer;
+ }
+
private int fillBuffer() throws IOException {
limit = reader.read(buffer, 0, buffer.length);
offset = 0;