Bug 53811 - exception when using -Dfile.encoding=UTF-8
exception when using -Dfile.encoding=UTF-8
Status: RESOLVED FIXED
Product: Ant
Classification: Unclassified
Component: Core
1.8.4
All All
: P2 major (vote)
: 1.9.0
Assigned To: Ant Notifications List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-09-01 07:16 UTC by Abu Abdullah
Modified: 2013-03-12 15:56 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Abu Abdullah 2012-09-01 07:16:04 UTC
Hi,
adding -Dfile.encoding=UTF-8 causes the below exception when adding entry to the tra file.
java.io.IOException: request to write '198' bytes exceeds size in header of '111' bytes for entry '././@LongLink'
    at org.apache.tools.tar.TarOutputStream.write(TarOutputStream.java:280)
    at org.apache.tools.tar.TarOutputStream.write(TarOutputStream.java:261)
    at org.apache.tools.tar.TarOutputStream.putNextEntry(TarOutputStream.java:185)
Comment 1 Abu Abdullah 2012-09-01 07:46:02 UTC
piece of code:

final TarOutputStream tarFile = new TarOutputStream(new FileOutputStream(pathName));
tarFile.setLongFileMode(TarOutputStream.LONGFILE_GNU);

....

TarEntry tarEntry = new TarEntry(path);
tarEntry.setSize(new File(pre_path+path).length());
tarFile.putNextEntry(tarEntry);
in = new FileInputStream(convertPath(choosedAudioPath)+path);
while((len = in.read(buf)) > 0)
 tarFile.write(buf, 0, len);

tarFile.closeEntry();
in.close();
Comment 2 Abu Abdullah 2012-09-01 07:48:27 UTC
(In reply to comment #1)
> piece of code:
> 
> final TarOutputStream tarFile = new TarOutputStream(new
> FileOutputStream(pathName));
> tarFile.setLongFileMode(TarOutputStream.LONGFILE_GNU);
> 
> ....
> 
> TarEntry tarEntry = new TarEntry(path);
> tarEntry.setSize(new File(pre_path+path).length());
> tarFile.putNextEntry(tarEntry);
> in = new FileInputStream(convertPath(choosedAudioPath)+path);
> while((len = in.read(buf)) > 0)
>  tarFile.write(buf, 0, len);
> 
> tarFile.closeEntry();
> in.close();

sorry, small mistake. it is:
in = new FileInputStream(pre_path+path);
instead of:
in = new FileInputStream(convertPath(choosedAudioPath)+path);
Comment 3 Abu Abdullah 2012-09-02 07:27:24 UTC
it stops with a non-ASCII names (Arabic file name) while setting -Dfile.encoding=UTF-8. does it support adding UTF8 names?
Comment 4 Abu Abdullah 2012-09-02 08:15:53 UTC
the same bug has been solved in:
http://jira.codehaus.org/browse/PLXCOMP-195

please check the patch applied there and consider apply the same to resolve this.

When a TAR file is being written, and:
1. One or more filenames are so long that they require GNU mode
2. The platform encoding is UTF-8
3. Any character in a long filename results in a multibyte UTF-8 sequence

then an exception is thrown with this text:
"Problem creating TAR: request to write 'xxx' bytes exceeds size in header of 'xxx' bytes"
Comment 5 Abu Abdullah 2013-03-11 05:18:43 UTC
This issue is been solved in 1.9 with the new TarOutputStream(FileOutputStream, "UTF8") constructor and setLongFileMode(TarOutputStream.LONGFILE_GNU);