United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-7148584 : Jar tools fails to generate manifest correctly when boundary condition hit

Details
Type:
Bug
Submit Date:
2012-02-24
Status:
Closed
Updated Date:
2014-11-19
Project Name:
JDK
Resolved Date:
2012-04-20
Component:
tools
OS:
generic
Sub-Component:
jar
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u24
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Backport:
Backport:

Sub Tasks

Description
SHORT SUMMARY:Jar tools fails to generate manifest file correctly when 
boundary condition hit in Manifest.FastInputStream class
INDICATORS: jar tool fails to add attributes to Manifest file
COUNTER INDICATORS:
TRIGGERS: A manifest file is supplied of unique size so that a 
Manifest.FastInputStream.fill() call is made just before EOF of Manifest file 
is reached.
KNOWN WORKAROUND: Add an extra empty line to Manifest file supplied to jar 
command
PRESENT SINCE: FCS 
HOW TO VERIFY: See bug DB descrition
NOTES FOR SE:
REGRESSION: No.

                                    

Comments
EVALUATION

when EOF is encountered (and fill() read call returns -1), we should invalidate the buffer (buf) so that any peek calls doesn't read back data in the buffer from the previous fill() call.
                                     
2012-02-24
SUGGESTED FIX

proposed change to fill() method in Manifest.FastInputStream : (6.0 codebase) 

@@ -422,7 +420,10 @@ public class Manifest implements Cloneab
            int n = in.read(buf, 0, buf.length);
            if (n > 0) {
                count = n;
-           }
+           } else {
+                //EOF reached
+                buf[0] = (byte)'\n';
+            }
        }
                                     
2012-02-24



Hardware and Software, Engineered to Work Together