Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RMTESToUTF8 does not work (Java SDK) #289

Closed
mzl-financial-com opened this issue Oct 14, 2024 · 2 comments
Closed

RMTESToUTF8 does not work (Java SDK) #289

mzl-financial-com opened this issue Oct 14, 2024 · 2 comments

Comments

@mzl-financial-com
Copy link

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:

	@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++;
			}

which copies from input to output buffer.
(https://github.com/Refinitiv/Real-Time-SDK/blob/master/Cpp-C/Eta/Impl/Codec/rsslRmtes.c)

@ViktorYelizarov
Copy link
Contributor

@mzl-financial-com Thank you for bringing this issue to our attention! We created an internal Jira to investigate it.

@vlevendel
Copy link
Contributor

Fixed with version Real-Time-SDK-2.2.3.L1. Please reopen if there are additional concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants