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

Null value at the last column cause exception #19

Open
andy176631 opened this issue Dec 15, 2017 · 0 comments
Open

Null value at the last column cause exception #19

andy176631 opened this issue Dec 15, 2017 · 0 comments

Comments

@andy176631
Copy link

When I try the code:

final AsciiTable at = new AsciiTable();   
at.addRule();		
at.addRow("c_1_1", "c_1_2", "c_1_3");	
at.addRule();		
at.addRow("c_2_1", null, "c_2_3");		
at.addRule();
at.setTextAlignment(TextAlignment.CENTER);	
System.out.println(at.render());

The column spans as expected:

┌──────────────────────────┬─────────────────────────┬─────────────────────────┐
│          c_1_1           │          c_1_2          │          c_1_3          │
├──────────────────────────┼─────────────────────────┴─────────────────────────┤
│          c_2_1           │                       c_2_3                       │
└──────────────────────────┴───────────────────────────────────────────────────┘

But when the null value is at the last column:

final AsciiTable at = new AsciiTable();   
at.addRule();		
at.addRow("c_1_1", "c_1_2", "c_1_3");	
at.addRule();		
at1.addRow("c_2_1", "c_2_2", null);		
at.addRule();
at.setTextAlignment(TextAlignment.CENTER);	
System.out.println(at.render());

It cause exception as bellow:

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 55, Size: 55
	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.AT_Renderer.render(AT_Renderer.java:112)
	at de.vandermeer.asciitable.AsciiTable.render(AsciiTable.java:185)
	at test.Test.main(Test.java:56)

I think this's one corner case that not been discovered

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

No branches or pull requests

1 participant