/** * Reports the compatibility of a reader/writer schema pair. * * <p> Memoizes the compatibility results. </p> * * @param reader Reader schema to test. * @param writer Writer schema to test. * @return the compatibility of the reader/writer schema pair. */ public SchemaCompatibilityType getCompatibility( final Schema reader, final Schema writer ) { LOG.debug("Checking compatibility of reader {} with writer {}", reader, writer); final ReaderWriter pair = new ReaderWriter(reader, writer); final SchemaCompatibilityType existing = mMemoizeMap.get(pair); if (existing != null) { if (existing == SchemaCompatibilityType.RECURSION_IN_PROGRESS) { // Break the recursion here. // schemas are compatible unless proven incompatible: return SchemaCompatibilityType.COMPATIBLE; } return existing; } // Mark this reader/writer pair as "in progress": mMemoizeMap.put(pair, SchemaCompatibilityType.RECURSION_IN_PROGRESS); final SchemaCompatibilityType calculated = calculateCompatibility(reader, writer); mMemoizeMap.put(pair, calculated); return calculated; }