3 Replies Latest reply on Jul 21, 2014 2:54 PM by 2686807

    BackingMapContext.getReadOnlyEntry throws IllegalStateException if called from within MapIndex.insert


      Evening all,


      I've just been playing with the latest Coherence 12.1.3 and some custom index code.  The code was previously calling the now deprecated 'context.getBackingMap()' call to retrieve the backing map, (the index synthesises an index based on more than just the single entry).  I was looking to move away from the deprecated call, but the obvious alternative 'getReadOnlyEntry' throws an IllegalStateException when called.


      Does anyone know if this is intentional?  It seems strange, as its a 'read-only' call - so the index can't corrupt the value...


      Simplified code below:


      public class ExampleIndex implements MapIndex {

          private final ValueExtractor extractor;

          private final boolean ordered;

          private final Comparator comparator;

          private final BackingMapContext context;

          private final Map<Object, Set<Object>> index;




          public ExampleIndex(ValueExtractor extractor, boolean ordered, Comparator<Object> comparator, BackingMapContext context) {

              this.extractor = extractor;

              this.ordered = ordered;

              this.comparator = comparator;

              this.context = context;

              this.index = ordered ? new TreeMap<Object, Set<Object>>(comparator) : new HashMap<Object,Set<Object>>();






          public void insert(Map.Entry entry) {

          BinaryEntry binaryEntry = (BinaryEntry)entry;

          for (Object key : binaryEntry.getBackingMap().keySet()) {

                  context.getReadOnlyEntry(key);  // <-- Throws IllegalStateException (on first call)