Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OutOfBoundsException Error

 
Karen Baog
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My test server program receives packets from the Client.
Im my server program the data received is assigned to:


When my client is set to continually send a message, eventually (only after a few seconds) the server throws an ArrayIndexOutOfBoundsException Error.

I assume the data[] doesn't get cleared and is filled very quickly.
I would have thought that, because the data array is declared and initialized inside the for loop, the garbage collector would take care of it.

Karen
[ July 13, 2005: Message edited by: Karen Baog ]
 
Karen Baog
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I need to expand on this a bit more.

Hre is an expanded code. I'll use values instead of variable names, where possible for clarity. I have opted not to show the exception clauses as it will only clog up the code.


Pleeeease, help!
[ July 13, 2005: Message edited by: Karen Baog ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please post the exact error message? It will include the line of code that is throwing the exception. This will greatly help us be able to determine what the problem might be.

Layne
 
Karen Baog
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Digging deeper into this, I see that the StringBuffer gets filled up.
But I can't find any method of clearing it.
The .delete(int, int) don't work.

Any suggestions?
 
Karen Baog
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried several methods to try to clear up the StringBuffer as suggested here, but still can't get it to work. The StringBuffer just keeps growing.

StringBuffer

I do hope that someone here would look a this.
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I think you're correct.
Is newMsg.length() greater than data.length ??
In other words, can you always assign newMsg.charAt(i) to data[i] ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic