vdmeer/asciitable

IndexOutOfBoundsException

laeubi opened this issue · 2 comments

Today I got an IOOB Exception, the code should either check for such condition and give meaningful error message if it is an user error or do not fail.

java.lang.IndexOutOfBoundsException: Index 135 out of bounds for length 135
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
	at java.base/java.util.Objects.checkIndex(Objects.java:359)
	at java.base/java.util.ArrayList.get(ArrayList.java:427)
	at de.vandermeer.asciithemes.TA_GridHelpers.adjustBorder(TA_GridHelpers.java:194)
	at de.vandermeer.asciithemes.TA_Grid.addGrid(TA_Grid.java:306)
	at de.vandermeer.asciitable.AT_Renderer.renderAsCollection(AT_Renderer.java:282)
	at de.vandermeer.asciitable.AsciiTable.renderAsCollection(AsciiTable.java:207)
	at de.vandermeer.skb.interfaces.render.RendersToClusterWidth.renderAsIterator(RendersToClusterWidth.java:52)

This seem to happen when the last value of a cell is null, it would be good that:

  1. When adding a row and the last value is null an IllegalArgumentException is thrown
    -- or --
  2. the code just handles the null like an empty String

I have one more addition to the problem. It seems that it also occurs when some cell of the last row of the table has a value of null. Even if that is not the last cell.