Exception when using Serial monitor

Hi All,

I have compiled the Arduino IDE from the source code I pulled today.
Everything compiled fine and works as far as compiling and uploading codes.
All the menus and windows are opening up just fine.
The only issue I'm getting is when I try using the Serial Monitor window and I receive serial data.
It accepts a few bytes and then raises an exception:

Exception in thread "EventThread COM29" java.lang.NullPointerException
at processing.app.Serial.serialEvent(Serial.java:176)
at jssc.SerialPort$EventThread.run(SerialPort.java:1096)

The line in question is this:
https://github.com/arduino/Arduino/blob/ide-1.5.x/app/src/processing/app/Serial.java#L176

        byte[] buf = port.readBytes();
        if (buf.length > 0) {

The function readBytes is here:
https://github.com/arduino/Arduino/blob/ide-1.5.x/app/src/processing/app/Serial.java#L248

  public synchronized byte[] readBytes() {
    if (bufferIndex == bufferLast) return null;

    int length = bufferLast - bufferIndex;
    byte outgoing[] = new byte[length];
    System.arraycopy(buffer, bufferIndex, outgoing, 0, length);

    bufferIndex = 0;  // rewind
    bufferLast = 0;
    return outgoing;
  }

So, there is a possibility the function would return null if this statement is true:

    if (bufferIndex == bufferLast) return null;

I think this is what is causing my exception.
Would this be a bug or something in my compilation that went bad?

Thanks,
RI

I have compiled the Arduino IDE from the source code I pulled today.

From a release branch? A development branch?

What are you trying to accomplish?

I used the branch ide-1.5.x that I pulled today.
I have made a few changes to Sketch.java, but it is unrelated to the issue.
My latest pull was a while ago on 1.5.3 version and the serial monitor was working fine.
I did notice there was a change from RXTX to jSSC that was reverted back, but there was no comments and I didn't quite understand why it was introduced and then reverted back.
Maybe it has something to do with this problem I'm getting.
You can see the history of the file here:

I suggest asking on the Developers List which branch / tag / revision was used for the 1.5.5 delivery.

I had the same problem on my Due using the 1.5.6 IDE, where Serial Monitor would read a few lines then crash with a NullPointerException. I'm using Windows 7 64 bit, and had the same problem happen with my Arduino Micro. The test code I used was:

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println("Test");
  delay(1);
}

The problem is most likely the IDE. After I switched to an older version (1.5.1r2), the problem went away. You can download Arduino 1.5.1r2 at https://github.com/downloads/arduino/Arduino/arduino-1.5.1r2-windows.zip