Closed Bug 56113 Opened 24 years ago Closed 24 years ago

method read() of PlugletInputStream class always return last byte of stream after end of stream reached

Categories

(Core Graveyard :: Java-Implemented Plugins, defect, P3)

x86
Solaris
defect

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: sva, Assigned: blackconnect)

Details

Overview Description: 
Due to JDK specification for java.io.InputStream method read() return "the next
byte of data, or -1 if the end of the stream is reached". But it return code of
last symbol in stream, and never return -1.

1) Use following implementation for your
   PlugletStreamListener.onDataAvailable method in
/mozilla/java/plugins/test/test.java:

public void onDataAvailable(PlugletStreamInfo plugletInfo, InputStream
input,int  length) {
        try{          
            int i = 0;
            int b = input.read();
            System.out.println("1. b= "+b);
            int tmp = length-1;
            while(b!=-1) {
	      System.out.println("Try to read " + i + " byte of " + tmp);
              b = input.read();
              i++;
              System.out.print("i= "+i+" input.read()= "+b);
            }

        } catch(Exception e) {
            ;
        }
}

2. Type gmake in /mozilla/java/plugins/test/

3. Start mozilla with test pluglet.

Actual result:
endless cycle is obtained. I have following output:
i= 866025 input.read()= 10
Try to read 866025 byte of 8191
i= 866026 input.read()= 10
Try to read 866026 byte of 8191
i= 866027 input.read()= 10
Try to read 866027 byte of 8191
i= 866028 input.read()= 10
Try to read 866028 byte of 8191
i= 866029 input.read()= 10
Try to read 866029 byte of 8191
i= 866030 input.read()= 10
Try to read 866030 byte of 8191

Expected result: 
method read() should return -1 and cycle finished

Source & OS:
/mozilla/java/plugins/ source from 10.11.2000 & OS: Intel Solaris 2.7
Fixed
Fix checked into JAVADEV_PR3_20001002 brunch.

(Please update classes and jni directories)
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Problem isn't reproduce with latest fix
Status: RESOLVED → VERIFIED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.