File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
server/src/main/java/org/elasticsearch/common/io/stream Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change
1
+ pr : 90632
2
+ summary : Fix `RecyclerBytesStreamOutput` allocating unlimited heap for some capacities
3
+ area : Network
4
+ type : bug
5
+ issues : []
Original file line number Diff line number Diff line change @@ -225,10 +225,12 @@ private void ensureCapacity(int bytesNeeded) {
225
225
}
226
226
227
227
private void ensureCapacityFromPosition (long newPosition ) {
228
+ // Integer.MAX_VALUE is not a multiple of the page size so we can only allocate the largest multiple of the pagesize that is less
229
+ // than Integer.MAX_VALUE
230
+ if (newPosition > Integer .MAX_VALUE - (Integer .MAX_VALUE % pageSize )) {
231
+ throw new IllegalArgumentException (getClass ().getSimpleName () + " cannot hold more than 2GB of data" );
232
+ }
228
233
while (newPosition > currentCapacity ) {
229
- if (newPosition > Integer .MAX_VALUE ) {
230
- throw new IllegalArgumentException (getClass ().getSimpleName () + " cannot hold more than 2GB of data" );
231
- }
232
234
Recycler .V <BytesRef > newPage = recycler .obtain ();
233
235
assert pageSize == newPage .v ().length ;
234
236
pages .add (newPage );
You can’t perform that action at this time.
0 commit comments