tflobbe commented on a change in pull request #1335: SOLR-14316 Remove unchecked type conversion warning in JavaBinCodec's readMapEntry's equals() method URL: https://github.com/apache/lucene-solr/pull/1335#discussion_r391150799
########## File path: solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java ########## @@ -287,6 +289,45 @@ public void testAllTypes() throws IOException { ); } + @Test + public void testReadMapEntry() throws IOException { + Map.Entry<Object, Object> extryFromTextDoc1 = getMapFromJavaBinCodec(SOLRJ_DOCS_1); + Map.Entry<Object, Object> extryFromTextDoc1_clone = getMapFromJavaBinCodec(SOLRJ_DOCS_1); + + Map.Entry<Object, Object> extryFromTextDoc2 = getMapFromJavaBinCodec(SOLRJ_DOCS_2); + Map.Entry<Object, Object> extryFromTextDoc2_clone = getMapFromJavaBinCodec(SOLRJ_DOCS_2); + + // exactly same document read twice should have same content + assert (extryFromTextDoc1.equals(extryFromTextDoc1_clone)); + // doc1 and doc2 are 2 text files with different content on line 1 + assert (!extryFromTextDoc2.equals(extryFromTextDoc1)); + // exactly same document read twice should have same content + assert (extryFromTextDoc2.equals(extryFromTextDoc2_clone)); + + // now lets look at binary files + Map.Entry<Object, Object> entryFromBinFileA = getMapFromJavaBinCodec(SOLRJ_JAVABIN_BACKCOMPAT_BIN); + Map.Entry<Object, Object> entryFromBinFileA_clone = getMapFromJavaBinCodec(SOLRJ_JAVABIN_BACKCOMPAT_BIN); + + // as the equals assertion is based on the hashcode, even the same exact bin file + // will produce different Objects and hence different hashcodes Review comment: this is interesting. what's the type of the objects in the map for this case? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org