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

VERIFIED FIXED

Status

Core Graveyard
Java-Implemented Plugins
P3
normal
VERIFIED FIXED
18 years ago
6 years ago

People

(Reporter: Vladimir Strigun, Assigned: Igor Kushnirskiy)

Tracking

Trunk
x86
Solaris

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

18 years ago
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
(Assignee)

Comment 1

18 years ago
Fixed
Fix checked into JAVADEV_PR3_20001002 brunch.

(Please update classes and jni directories)
Status: NEW → RESOLVED
Last Resolved: 18 years ago
Resolution: --- → FIXED
(Reporter)

Comment 2

18 years ago
Problem isn't reproduce with latest fix
Status: RESOLVED → VERIFIED
Component: Java-Implemented Plugins → Java-Implemented Plugins
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.