ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 31251] - manifest task improperly truncates long lines for classpath attribute.
Date Wed, 15 Sep 2004 23:19:46 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31251>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31251

manifest task improperly truncates long lines for classpath attribute.

joel.regen@activant.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|DUPLICATE                   |



------- Additional Comments From joel.regen@activant.com  2004-09-15 23:19 -------
WHAT! This is broken! I looked at the source in Manifest.java, the writeValue 
method of the Attribute class:
Give me a break! This produces BROKEN class path attributes in any manifest.
!!!!!!!!!!!

Here's my proposed fix:
        private void writeValue(PrintWriter writer, String value)
             throws IOException {
            String line = name + ": " + value;
            String pathComponent = null;
            boolean done = false;

            // If this is a class-path, be smarter about breaking up 
            // value string - break only at whitespace. In fact,
            // just put each classpath component on a separate line.
            // It's simpler.
            if ("Class-Path".equals(name)) {
                StringTokenizer st = new StringTokenizer(value);
                writer.print(name + ": ");
                while (st.hasMoreElements()) {
                    String elem = st.nextToken();
                    writer.print(elem + EOL + " ");
                }
            }
            else{
                while (line.getBytes().length > MAX_LINE_LENGTH) {
                    // try to find a MAX_LINE_LENGTH byte section
                    int breakIndex = MAX_SECTION_LENGTH;
                    String section = line.substring(0, breakIndex);
                    while (section.getBytes().length > MAX_SECTION_LENGTH
                         && breakIndex > 0) {
                        breakIndex--;
                        section = line.substring(0, breakIndex);
                    }
                    if (breakIndex == 0) {
                        throw new IOException("Unable to write manifest line "
                            + name + ": " + value);
                    }
                    writer.print(section + EOL);
                    line = " " + line.substring(breakIndex);
                }
                writer.print(line + EOL);
            }
        }
    }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message