*
* @param channel
* @throws IOException
*/
private void writeVersionHeader(final Channel channel, final boolean fullVersionList) throws IOException {
CancellableDataOutputStream dos = new CancellableDataOutputStream(channel.writeMessage());
try {
dos.writeBytes(JMX);
byte[] versions = getSupportedVersions(fullVersionList);
dos.writeInt(versions.length);
dos.write(versions);
if (Version.isSnapshot()) {
dos.write(SNAPSHOT);
} else {
dos.write(STABLE);
}
if (fullVersionList) {
String remotingJMXVersion = Version.getVersionString();
byte[] versionBytes = remotingJMXVersion.getBytes("UTF-8");
dos.writeInt(versionBytes.length);
dos.write(versionBytes);
}
} catch (IOException e) {
dos.cancel();
throw e;
} finally {
dos.close();
}
}