The problem can be reproduced in the following unit test:
@Test
public void testRMTESToUTF8() {
final byte[] test = new byte[] { (byte)0x1B, (byte)'%', (byte)'0', 'C', 'P', 'I' };
final Buffer buffer = CodecFactory.createBuffer();
buffer.data(ByteBuffer.wrap(test));
final RmtesDecoder rmtesDecoder = CodecFactory.createRmtesDecoder();
final RmtesCacheBuffer rmtesCacheBuffer = CodecFactory.createRmtesCacheBuffer(0, ByteBuffer.allocate(64), 64);
final RmtesBuffer rmtesBuffer = CodecFactory.createRmtesBuffer(0, ByteBuffer.allocate(64), 64);
int ret;
ret = rmtesDecoder.RMTESApplyToCache(buffer, rmtesCacheBuffer);
Assert.assertEquals(CodecReturnCodes.SUCCESS, ret);
ret = rmtesDecoder.RMTESToUTF8(rmtesBuffer, rmtesCacheBuffer);
Assert.assertEquals(CodecReturnCodes.SUCCESS, ret);
final int decodedLength = rmtesBuffer.length();
rmtesBuffer.byteData().limit(decodedLength);
final byte[] target = new byte[decodedLength];
rmtesBuffer.byteData().get(target, 0, decodedLength);
Assert.assertEquals("CPI", new String(target));
}
The error seems to be in the following lines:
else
/* Just copy the data, since it's already encoded in UTF8 */
{
if (outIterCount + 1 > rmtesBuffer.allocatedLength())
return CodecReturnCodes.BUFFER_TOO_SMALL;
rmtesBuffer.byteData().put(outIterCount++, rmtesBuffer.byteData().get(outIterCount));
inIterCount++;
}
which copy from output to output buffer. Unlike the C implementation:
else /* Just copy the data, since it's already encoded in UTF8 */
{
*outIter = *inIter;
outIter++;
inIter++;
}
The function RMTESToUTF8 does not work.
Function can be found in the class
https://github.com/Refinitiv/Real-Time-SDK/blob/master/Java/Eta/Core/src/main/java/com/refinitiv/eta/codec/RmtesDecoderImpl.java
The problem can be reproduced in the following unit test:
The error seems to be in the following lines:
which copy from output to output buffer. Unlike the C implementation:
which copies from input to output buffer. (https://github.com/Refinitiv/Real-Time-SDK/blob/master/Cpp-C/Eta/Impl/Codec/rsslRmtes.c)