BUG in CMS => save ContentAdv to SER File.
"Ferruh Zamangoer" <[email protected]>
| Newsgroups | gmane.comp.java.jxta.user,gmane.comp.java.jxta.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
we are using JXTA-CMS for our legal filesharing system. We have recognized
that the method in the CMS class to save a shared content into the
shares.ser file doesn't work anytime. If somebody share some content the
content advertisement is published and can be found by a list request of an
another peer. But when the location of the content is not correctly
serialized in the SER File a another peer which want to download the content
hangs and end in a request-loop.
The bug can be fixed if the ObjectOutputStream is flushed.
// saves content index to file
private void save(File file) throws IOException
{
File tmp = tmpFile(file);
FileOutputStream os = new FileOutputStream(tmp);
try
{
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(shares);
oos.flush();
//this line was added.
oos.close();
}
catch (IOException io)
{
os.close();
tmp.delete();
throw io;
}
file.delete();
if (!tmp.renameTo(file))
{
throw new IOException("Could not rename file: " + tmp);
}
}
Regards
Ferruh
may the source be with you..