renatoh commented on code in PR #3163:
URL: https://github.com/apache/solr/pull/3163#discussion_r1946046611
##########
solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java:
##########
@@ -863,6 +868,26 @@ protected Map<Object, Object> readMap(DataInputInputStream
dis, int sz) throws I
return m;
}
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ protected Map<?, Object>
readMapAsSimpleOrderedMapForStringKeys(DataInputInputStream dis, int sz)
+ throws IOException {
+ Map m = null;
+ for (int i = 0; i < sz; i++) {
+ Object key = readVal(dis);
+
+ if (m == null) {
+ if (key instanceof String) {
+ m = new SimpleOrderedMap<>(sz);
+ } else {
+ m = newMap(sz);
+ }
+ }
+ Object val = readVal(dis);
+ m.put(key, val);
+ }
+ return m;
+ }
+
Review Comment:
Just casting the key to a String, or having an assert on it, will fail three
unit test of TestJavaBinCodec. E.g. the .bin used in the tests -
org.apache.solr.common.util.TestJavaBinCodec#SOLRJ_JAVABIN_BACKCOMPAT_BIN -
holds a Map with Integer as key. So you are saying that this is not
representing a realistic case and had to be changed?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]