1 Reply Latest reply: Jun 21, 2011 12:55 PM by 796440 RSS

    IndexOutOfBoundsException occurs only on certain date and time

    870411
      I've put together a piece of code that is used to talk to a credit board/coin validator hooked to my PC via a serial port (comm 1).

      My problem is that I receive a really strange error (IndexOutOfBoundsException) that occurs only between 17th and 20th of June. If i forward the system clock to a time and date earlier or later than this date range everything works as expected?

      The error outputted is: java.lang.IndexOutOfBoundsException: Index: 6144, Size: 0

      Any help on this would be real plus?....

      Adam
        • 1. Re: IndexOutOfBoundsException occurs only on certain date and time
          796440
          867408 wrote:
          The error outputted is: java.lang.IndexOutOfBoundsException: Index: 6144, Size: 0
          The error message is telling you exactly what's wrong: You're trying to access the 6,145th element of an array or Collection (at index 6144), but that array or Collection has 0 elements.

          If you haven't done something silly like
          catch (Exception e) {
            System.out.println(e); // should be e.printStackTrace();
          }
          then you'll get a stacktrace, which will show you exactly which line of code caused the error, and what was calling that method, and so on up the stack.

          As for why the error occurs under those particular circumstances, what's causing it, and how to fix it, that's impossible to say, since we know nothing of this system, its code, or other systems it interacts with. I can only suggest that you add copious logging statements so that you can see exactly what data you're getting and exactly what you're doing with it.