mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-23 14:52:06 +01:00
Fixed closing ObjectOutputStream (SMACK-143).
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2340 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
d471d42fbf
commit
677b389ccc
1 changed files with 13 additions and 3 deletions
|
@ -424,16 +424,26 @@ public abstract class Packet {
|
||||||
// a binary format, which won't work well inside of XML. Therefore, we base-64
|
// a binary format, which won't work well inside of XML. Therefore, we base-64
|
||||||
// encode the binary data before adding it.
|
// encode the binary data before adding it.
|
||||||
else {
|
else {
|
||||||
|
ByteArrayOutputStream byteStream = null;
|
||||||
|
ObjectOutputStream out = null;
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
|
byteStream = new ByteArrayOutputStream();
|
||||||
ObjectOutputStream out = new ObjectOutputStream(byteStream);
|
out = new ObjectOutputStream(byteStream);
|
||||||
out.writeObject(value);
|
out.writeObject(value);
|
||||||
buf.append("java-object\">");
|
buf.append("java-object\">");
|
||||||
String encodedVal = StringUtils.encodeBase64(byteStream.toByteArray());
|
String encodedVal = StringUtils.encodeBase64(byteStream.toByteArray());
|
||||||
buf.append(encodedVal).append("</value>");
|
buf.append(encodedVal).append("</value>");
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (out != null) {
|
||||||
|
try { out.close(); } catch (Exception e) { }
|
||||||
|
}
|
||||||
|
if (byteStream != null) {
|
||||||
|
try { byteStream.close(); } catch (Exception e) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf.append("</property>");
|
buf.append("</property>");
|
||||||
|
|
Loading…
Reference in a new issue