Fixed bug growing the size of the FastStatementList when the capacity is exceeded.

pull/30/head
Brett Wooldridge 11 years ago
parent 072d52178f
commit b566002c0e

@ -16,7 +16,9 @@
package com.zaxxer.hikari.util;
import java.lang.reflect.Array;
import java.sql.Statement;
import java.util.Arrays;
/**
@ -63,11 +65,11 @@ public final class FastStatementList
{
// overflow-conscious code
int oldCapacity = elementData.length;
int newCapacity = oldCapacity + (oldCapacity >> 1);
int newCapacity = oldCapacity << 2;
Statement[] newElementData = new Statement[newCapacity];
System.arraycopy(element, 0, newElementData, 0, oldCapacity);
System.arraycopy(elementData, 0, newElementData, 0, oldCapacity);
newElementData[size++] = element;
elementData = newElementData;
elementData = (Statement[]) newElementData;
}
}

@ -0,0 +1,19 @@
package com.zaxxer.hikari;
import org.junit.Test;
import com.zaxxer.hikari.performance.StubStatement;
import com.zaxxer.hikari.util.FastStatementList;
public class TestFastStatementList
{
@Test
public void testOverflow()
{
FastStatementList list = new FastStatementList();
for (int i = 0; i < 100; i++)
{
list.add(new StubStatement());
}
}
}
Loading…
Cancel
Save