Message:
The following issue has been closed.
Resolver: Dennis Sosnoski
Date: Fri, 30 Apr 2004 9:53 PM
Verified fixed.
---------------------------------------------------------------------
View the issue:
http://jira.codehaus.org/secure/ViewIssue.jspa?key=JIBX-12
Here is an overview of the issue:
---------------------------------------------------------------------
Key: JIBX-12
Summary: ArrayIndexOutOfBoundsException when marshalling a large element
Type: Bug
Status: Closed
Priority: Blocker
Resolution: FIXED
Original Estimate: Unknown
Time Spent: Unknown
Remaining: Unknown
Project: JiBX
Components:
core
Fix Fors:
1.0-beta3b
Versions:
1.0-beta3a
Assignee: Dennis Sosnoski
Reporter: Gareth Farrington
Created: Fri, 16 Apr 2004 4:23 PM
Updated: Fri, 30 Apr 2004 9:53 PM
Environment: JDK 1.4.2_04
WinXP Pro
Description:
An exception is thrown when marshalling an element that contains more than 4k of data.
If the element contains less than 4k of data the marshalling compleates normally.
Some good sample output with 850 bytes of data is included at the end. I havn't tested
unmarshalling larg elements yet.
>>>>>>>>>>>>>> EXCEPTION >>>>>>>>>>>>>>>>>
java.lang.ArrayIndexOutOfBoundsException: 4096
at
org.jibx.runtime.impl.UTF8StreamWriter.writeTextContent(UTF8StreamWriter.java:277)
at
org.jibx.runtime.impl.MarshallingContext.element(MarshallingContext.java:638)
at
ky.mindshare.net.group.services.ftp.FileTransferDescriptor.JiBX_File_Transfer_Protocol_marshal_1_0(FileTransferDescriptor.java)
at
ky.mindshare.net.group.services.ftp.JiBX_File_Transfer_ProtocolFileTransferDescriptor_access.marshal()
at
ky.mindshare.net.group.services.ftp.FileTransferDescriptor.marshal(FileTransferDescriptor.java)
at
org.jibx.runtime.impl.MarshallingContext.marshalRoot(MarshallingContext.java:907)
at
org.jibx.runtime.impl.MarshallingContext.marshalDocument(MarshallingContext.java:955)
>>>>>>>>>>>>>> SOURCE >>>>>>>>>>>>>>>>>
/**
* @author Gareth Farrignton
* Created on Apr 13, 2004
*/
package ky.mindshare.net.group.services.ftp;
import java.io.*;
import org.jibx.runtime.*;
public class FileTransferDescriptor {
public String name; // something to identify the file, could be a
name or an entire path
public int length; // In bytes
public int segmentSize; // size of one segment
private String segmentHashes; // SHA1 hashes of every segment strung together
private String infoHash; // 20 byte SHA1 hash of the name, context and
segmentHashes fields
// concatanated together, in that order. 'Should'
uniquly identify this file. */
// JiBX XML stuff:
private static IBindingFactory bindingFactory;
private static IUnmarshallingContext fromXML;
private IMarshallingContext toXML;
static {
try {
bindingFactory =
BindingDirectory.getFactory(FileTransferDescriptor.class);
fromXML = bindingFactory.createUnmarshallingContext();
} catch (JiBXException e) {
throw new RuntimeException(e);
}
}
private FileTransferDescriptor() {
}
protected FileTransferDescriptor(FtpFile file) {
this.name = new String(file.name);
length = file.length;
segmentSize = file.segmentSize;
setHashes(file.segmentHashes);
setInfoHash(file.infoHash);
}
public void setHashes(byte[] hashes) {
this.segmentHashes = new sun.misc.BASE64Encoder().encodeBuffer(hashes);
System.out.println("Segment hases size: " + segmentHashes.length() + "
bytes");
}
public byte[] getSegmentHashes() {
try {
return new
sun.misc.BASE64Decoder().decodeBuffer(segmentHashes);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void setInfoHash(byte[] infoHash) {
this.infoHash = new sun.misc.BASE64Encoder().encodeBuffer(infoHash);
}
public byte[] getInfoHash() {
try {
return new sun.misc.BASE64Decoder().decodeBuffer(infoHash);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
* Create a FileTransferDescriptor from a source of bytes
* @param bytes bytes of XML to convert into an object
*/
public static FileTransferDescriptor loadTransferDescriptor(byte[] bytes) {
ByteArrayInputStream baos = new ByteArrayInputStream(bytes);
try {
return (FileTransferDescriptor)fromXML.unmarshalDocument(baos,
"UTF-8");
} catch (JiBXException e) {
throw new RuntimeException(e);
}
}
/**
* convert this object into bytes
* @return bytes of XML
*/
public byte[] saveTransferDescriptor() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
toXML = bindingFactory.createMarshallingContext();
toXML.setIndent(-1);
toXML.marshalDocument(this, "UTF-8", null, baos);
return baos.toByteArray();
} catch (JiBXException e) {
throw new RuntimeException(e);
}
}
}
>>>>>>>>>>>>>> BINDING >>>>>>>>>>>>>>>>>
<binding>
<mapping name="file-info"
class="ky.mindshare.net.group.services.ftp.FileTransferDescriptor">
<value name="name" field="name"/>
<value name="length" field="length"/>
<value name="segment-size" field="segmentSize"/>
<value name="hashes" field="segmentHashes"/>
<value name="info-hash" field="infoHash"/>
</mapping>
</binding>
>>>>>>>>>>>>>> SAMPLE OUTPUT >>>>>>>>>>>>>>>>>
<?xml version="1.0" encoding="UTF-8"?>
<file-info>
<name>thunderbird-win32.zip</name>
<length>7941400</length>
<segment-size>262144</segment-size>
<hashes>UiVZ2x7TJcHLB4qN1+FdLY+wNawb0HKM8WDPtbUiQeqD7ItOpxvFX9f97zs4fU7N9G1VRXbhqjoE
8SKD4oQfVGDvvbmTUiNuMIc3ib7OPlnWUek1wJsVzGAC9YwJC7Yauu5Cg/MQeGjAx7soxBuLF3wB
XCba2khgjh1z26+NMjULmnLFfa/ryQTIsm4iGgR0WIwvi5WDJCDNrhF3U9fw78x0G24kEG0p/dzD
PweaBfvyZrY7AQpEYawQbil2vWuTpSBDKseJRNkT7AoMGVu3uw+ZwNCJUwZHq0ussos21RKnl3wn
KXpsdH8LSsXq1kWhnYccnVtMIp2MF7PGh71BdP9FD/4HyXjhVhi5oNp7zVvMb3r9zB92doKq+vXo
YIXeIqPRUaqrQafnYdbt9bGrbcHn9RE961aUlYGUjO2lTYdvJ/oZR0jXhYwHNLwpUHWRIQJkvrks
2hQ8hQ4AfnQisC5MqnWvT9mIbNN/yXFNeX9klPeQMugCFvEr2nQQ+Mp89/+FPMxBOx44IJoywu3G
aFHEjo5oNKPNwF1pV9ssmjnJ9WmazSARJ+JMsCm1EYCp4iEdCjG6hKMuVemxw4Klne4tO37yFZ7e
NL2AfScNGTULHVR8yQta6VMEQe3D84SLW0UqT2/Ghpc9PysgWhFVLxLWNS2941CExukV5j03z0Nj
HYKXIXYhn1oT/SHNp37WABdWel3fphA6CiKgczChhfn+xgTkvj43OlaPfwOyEUEp5bw9Cr+n0yEX
imUORk9UdUGX5vtv4LUP+ZaZ0mOFFqoDhTEFbs8uVQ+bnHPUnWa9dUMn+ttCzTy7Cfc=
</hashes>
<info-hash>oR6X2xZ5I3uoqobiWzBHq7NmT7Y=
</info-hash></file-info>
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
jibx-devs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-devs