Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not tolerant to null object input #14

Open
janhoy opened this issue Jul 18, 2017 · 6 comments
Open

Not tolerant to null object input #14

janhoy opened this issue Jul 18, 2017 · 6 comments

Comments

@janhoy
Copy link

janhoy commented Jul 18, 2017

Wrote a small program to fill a table from objects. Strings in the objects can be null, but then asciitable crashes:

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 73, Size: 73
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
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.AT_Renderer.render(AT_Renderer.java:128)
at de.vandermeer.asciitable.AsciiTable.render(AsciiTable.java:191)

I currently work around this in my code with

at.addRow(Arrays.stream(row).map(v -> v==null?"":v).collect(Collectors.toList()));
@lorenzo93
Copy link

I started today working with this library and this was my first error. Not good!

Any way to correct this?

@tholu
Copy link

tholu commented Dec 5, 2017

Same problem here, please fix this!

todvora pushed a commit to todvora/asciitable that referenced this issue Dec 5, 2017
@andy176631
Copy link

I think it happened when the value at last column is null, otherwise the cell with null value will merged into its next right cell.

@tholu
Copy link

tholu commented Dec 11, 2017

@andy176631 That was indeed the case. The pull request should fix this behaviour.

andy176631 pushed a commit to andy176631/asciitable that referenced this issue Dec 13, 2017
andy176631 pushed a commit to andy176631/ascii-utf-themes that referenced this issue Dec 13, 2017
andy176631 pushed a commit to andy176631/ascii-utf-themes that referenced this issue Dec 13, 2017
@PavelTurk
Copy link

PavelTurk commented Mar 7, 2024

@vdmeer Can you say if this project is dead? I don't ask you to do something, please, just answer, it won't take much time.

@PavelTurk
Copy link

This is not a bug. Null is used as HTML colspan. If you have null in one row, then at least in one row you must have a non null value. Compare:

        //this example works
        AsciiTable table = new AsciiTable();
        table.addRule();
        table.addRow("A", null, "B");
        table.addRule();
        table.addRow(1, 2, 3);
        table.addRule();
        System.out.println(table.render());

        //this example doesn't work
        AsciiTable table = new AsciiTable();
        table.addRule();
        table.addRow("A", null, "B");
        table.addRule();
        table.addRow(1, null, 3); // <--  null
        table.addRule();
        System.out.println(table.render());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants