RowData { public void createRow(final RowDef rowDef, final Object[] values, boolean growBuffer) { if (growBuffer && !(bufferStart == 0 && bufferEnd == bytes.length)) { throw new CannotGrowBufferException(); } RuntimeException exception = null; do { try { exception = null; createRow(rowDef, values); } catch (ArrayIndexOutOfBoundsException e) { exception = e; } catch (EncodingException e) { if (e.getCause() instanceof ArrayIndexOutOfBoundsException) { exception = e; } else { throw e; } } if (exception != null && growBuffer) { int newSize = bytes.length == 0 ? CREATE_ROW_INITIAL_SIZE : bytes.length * 2; reset(new byte[newSize]); } } while (growBuffer && exception != null); if (exception != null) { throw exception; } } RowData();  RowData(final byte[] bytes);  RowData(final byte[] bytes, final int offset, final int length); void reset(final int offset, final int length); void reset(final byte[] bytes); void reset(final byte[] bytes, final int offset, final int length); boolean prepareRow(final int offset); void validateRow(final int offset); int getBufferStart(); int getBufferLength(); int getBufferEnd(); int getRowStart(); int getRowStartData(); int getRowEnd(); int getRowSize(); int getInnerStart(); int getInnerSize(); int getFieldCount(); int getRowDefId(); byte[] getBytes(); int getColumnMapByte(final int offset); boolean isNull(final int fieldIndex); long getIntegerValue(final int offset, final int width); long getUnsignedIntegerValue(final int offset, final int width); String getStringValue(final int offset, final int width, final FieldDef fieldDef); RowData copy(); void createRow(final RowDef rowDef, final Object[] values, boolean growBuffer); void createRow(final RowDef rowDef, final Object[] values); void updateNonNullLong(FieldDef fieldDef, long rowId); @Override String toString(); String toString(AkibanInformationSchema ais); String toString(final RowDef rowDef); String toStringWithoutRowDef(String missingRowDefExplanation); final static int O_LENGTH_A; final static int O_SIGNATURE_A; final static int O_FIELD_COUNT; final static int O_ROW_DEF_ID; final static int O_NULL_MAP; final static int O_SIGNATURE_B; final static int O_LENGTH_B; final static int MINIMUM_RECORD_LENGTH; final static int MAXIMUM_RECORD_LENGTH; final static char SIGNATURE_A; final static char SIGNATURE_B; final static int ENVELOPE_SIZE; final static int LEFT_ENVELOPE_SIZE; final static int RIGHT_ENVELOPE_SIZE; final static int CREATE_ROW_INITIAL_SIZE; }
@Test public void reallocateOnBind() throws ClassNotFoundException { AkibanInformationSchema ais = AISBBasedBuilder.create(typesTranslator) .table("myschema", "mytable") .colInt("id", false) .colInt("int_0", true) .colInt("int_1", true) .colInt("int_2", true) .colInt("int_3", true) .colInt("int_4", true) .colString("bigstring", 500) .colString("smallstring", 2) .ais(); List<?> values = Arrays.asList( 1L, null, null, null, null, null, Strings.repeat("a", 476), "hi" ); Object[] valuesArray = values.toArray(new Object[values.size()]); RowData rowData = new RowData(new byte[500]); new SchemaFactory().buildRowDefs(ais); RowDef rowDef = ais.getTable("myschema", "mytable").rowDef(); assertNotNull("RowDef", rowDef); try { rowData.createRow(rowDef, valuesArray, false); fail("expected ArrayIndexOutOfBoundsException"); } catch (ArrayIndexOutOfBoundsException e) { boolean foundInBind = false; for (StackTraceElement frame : e.getStackTrace()) { Class<?> frameClass = Class.forName(frame.getClassName()); if (RowDataTarget.class.isAssignableFrom(frameClass) && "bind".equals(frame.getMethodName())) { foundInBind = true; break; } } assertTrue("stack trace didn't include RowDataTarget.bind", foundInBind); } }