diff --git a/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java index a7e07136fbc9..1de0393acde6 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java @@ -398,30 +398,7 @@ public class MapReduceIndex implements UpdatableIndexemptyMap(); if (DebugAssertions.EXTRA_SANITY_CHECKS) { - - for(Map.Entry e: data.entrySet()) { - final Value value = e.getValue(); - if (!(Comparing.equal(value, value) && (value == null || value.hashCode() == value.hashCode()))) { - LOG.error("Index %s violates equals / hashCode contract for Value parameter", myIndexId.toString()); - } - - if (myValueExternalizer != null) { - try { - final BufferExposingByteArrayOutputStream out = new BufferExposingByteArrayOutputStream(); - DataOutputStream outputStream = new DataOutputStream(out); - myValueExternalizer.save(outputStream, value); - outputStream.close(); - final Value deserializedValue = - myValueExternalizer.read(new DataInputStream(new UnsyncByteArrayInputStream(out.getInternalBuffer(), 0, out.size()))); - - if (!(Comparing.equal(value, deserializedValue) && (value == null || value.hashCode() == deserializedValue.hashCode()))) { - LOG.error("Index %s violates equals / hashCode contract for Value parameter", myIndexId.toString()); - } - } catch (IOException ex) { - LOG.error(ex); - } - } - } + checkValuesHaveProperEqualsAndHashCode(data); } } @@ -576,6 +553,32 @@ public class MapReduceIndex implements UpdatableIndex data) { + for(Map.Entry e: data.entrySet()) { + final Value value = e.getValue(); + if (!(Comparing.equal(value, value) && (value == null || value.hashCode() == value.hashCode()))) { + LOG.error("Index " + myIndexId.toString() + " violates equals / hashCode contract for Value parameter"); + } + + if (myValueExternalizer != null) { + try { + final BufferExposingByteArrayOutputStream out = new BufferExposingByteArrayOutputStream(); + DataOutputStream outputStream = new DataOutputStream(out); + myValueExternalizer.save(outputStream, value); + outputStream.close(); + final Value deserializedValue = + myValueExternalizer.read(new DataInputStream(new UnsyncByteArrayInputStream(out.getInternalBuffer(), 0, out.size()))); + + if (!(Comparing.equal(value, deserializedValue) && (value == null || value.hashCode() == deserializedValue.hashCode()))) { + LOG.error("Index " + myIndexId.toString() + " violates equals / hashCode contract for Value parameter"); + } + } catch (IOException ex) { + LOG.error(ex); + } + } + } + } + private StringBuilder buildDiff(Map data, Map contentData) { StringBuilder moreInfo = new StringBuilder(); if (contentData.size() != data.size()) {