Question about detect if RMTES_STRING failed to encode

HI, for data type "OMMTypes.RMTES_STRING", I use below code to get the string to display it:
OMMDataBuffer buffer = (OMMDataBuffer)entryData
String dataDisplay = new String(buffer.getBytes, new RmtesCharsetProvider().charsetForName("RMTES"))
Most of the time it work but I can also get
java.nio.charset.CoderMalfunctionError: java.lang.IndexOutOfBoundsException
at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:587) ~[?:?]
at java.lang.String.decodeWithDecoder(String.java:1210) ~[?:?]
at java.lang.String.<init>(String.java:665) ~[?:?]
at java.lang.String.<init>(String.java:1387) ~[?:?]
Caused by: java.lang.IndexOutOfBoundsException
at java.nio.Buffer.checkIndex(Buffer.java:743) ~[?:?]
at java.nio.HeapByteBuffer.get(HeapByteBuffer.java:169) ~[?:?]
at com.reuters.rmtes.RmtesCharsetDecoder.parseLangCode(Unknown Source) ~[feed-assembly-2.6.13.jar:2.6.13]
at com.reuters.rmtes.RmtesCharsetDecoder.parseEscSeq(Unknown Source) ~[feed-assembly-2.6.13.jar:2.6.13]
at com.reuters.rmtes.RmtesCharsetDecoder.decodeLoop(Unknown Source) ~[feed-assembly-2.6.13.jar:2.6.13]
at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:585) ~[?:?]
Just wonder how can I prevent that Exception with some kind of detection?
Answers
-
Hello @Carfield Yim
Can you give me more detail about the issue?
- I am assuming you are using the RFA Java API, what is the version of the RFA Java API that encounters the problem?
- What is the RIC that encounter the issue?
- What kind of data that an application tries to decode? Is it Market Price or News (MRN) data?
- Can you replicate the issue with the RFA Java News Viewer application (rfaj8.2.5.L2.all.rrg package\Examples\com\reuters\rfa\example\omm\idn\newsviewer)
- Can you try the RFA Java version 8.2.5.L2?
- Is it data from exchange or your own publication?
0 -
Thanks a lot
- We are using 8.2.3.L1.all version
- We are using TREP with another data provider call ACTIV, and one symbol we got this problem was "TXG."
- It is market price
- Would you remind me the download page? Look like that is not in public maven repository, btw, look like my version is already new enough?
0 -
Can you print the raw bytes hex data when the exception occurred?
We would like to check the data in the buffer.
0 -
Thanks a lot, how do you want the data to print out? If I just do "log.info (buffer.getBytes)" the I believe the output is like "[b@182decdb" , is that what you want?
0 -
That string is also useful but I would like to see the raw data.
You can try the one mentioned on the StackOverflow.
0 -
HI, sure I see the value "44511B" most of the time, and few "51201B"
0 -
Do you mean the hex values are "0x44 0x51 0x1B" and "0x51 0x20 0x1B"?
Did the library fail to decode these values?
0 -
Thanks, I believe it is, I copy below method to encode the byte
private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
public static String bytesToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];
for (int j = 0; j < bytes.length; j++) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = HEX_ARRAY[v >>> 4];
hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
}
return new String(hexChars);
}0 -
I tested with the following code.
public static void main(String[] args) {
// TODO Auto-generated method stub
byte[] bytes1 = HexFormat.of().parseHex("44511B");
byte[] bytes2 = HexFormat.of().parseHex("51201B");
String dataDisplay = new String(bytes2, new RmtesCharsetProvider().charsetForName("RMTES"));
}I also got the exception.
Exception in thread "main" java.nio.charset.CoderMalfunctionError: java.lang.IndexOutOfBoundsException
at java.base/java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:588)
at java.base/java.lang.String.decodeWithDecoder(String.java:1247)
at java.base/java.lang.String.<init>(String.java:681)
at java.base/java.lang.String.<init>(String.java:1425)
at main.main(main.java:12)
Caused by: java.lang.IndexOutOfBoundsException
at java.base/java.nio.Buffer$1.apply(Buffer.java:757)
at java.base/java.nio.Buffer$1.apply(Buffer.java:754)
at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.nio.Buffer.checkIndex(Buffer.java:768)
at java.base/java.nio.HeapByteBuffer.get(HeapByteBuffer.java:176)
at com.reuters.rmtes.RmtesCharsetDecoder.parseLangCode(Unknown Source)
at com.reuters.rmtes.RmtesCharsetDecoder.parseEscSeq(Unknown Source)
at com.reuters.rmtes.RmtesCharsetDecoder.decodeLoop(Unknown Source)
at java.base/java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:586)
... 4 moreYou may need to contact the ACTIV data provider to verify those values.
0 -
I see, yes understand it probably the data provider issue but at API level it would be great to have API like "isparsable()" for API user to detect if it is parsable or not
0 -
It could be an enhancement request that should be submitted to the API support team via Contact Premium Support.
However, the application can catch the error.
try {
String dataDisplay = new String(bytes2, new RmtesCharsetProvider().charsetForName("RMTES"));
}catch (java.nio.charset.CoderMalfunctionError ex) {
System.out.println("Exception:");
System.out.println(ex.getMessage());
}0 -
yeah, that is what I am doing now, I was just think there is a way to detect this rather than try-catch, it ok, sound like we don't have that feature, I guess let me stick with what I am doing now
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 685 Datastream
- 1.4K DSS
- 615 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 252 ETA
- 556 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 650 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 193 TREP Infrastructure
- 228 TRKD
- 917 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛