263: " key=" + key + " value=" + value + " size=" + size + " maxSize=" + maxSize +
264: " Please check that your keys are immutable, and that you have used synchronization properly." +
265: " If so, then please report this to commons-dev@jakarta.apache.org as a bug.");
266: }
267: reuseMapping(reuse, hashIndex, hashCode, key, value);
268: } else {
269: super.addMapping(hashIndex, hashCode, key, value);
270: }
271: } else {
272: super.addMapping(hashIndex, hashCode, key, value);
273: }
274: }
275:
276: /**
277: * Reuses an entry by removing it and moving it to a new place in the map.
278: *
279: * This method uses {@link #removeEntry}, {@link #reuseEntry} and {@link #addEntry}.
280: *
281: * @param entry the entry to reuse
282: * @param hashIndex the index into the data array to store at
283: * @param hashCode the hash code of the key to add
284: * @param key the key to add
285: * @param value the value to add
286: */
287: protected void reuseMapping(LinkEntry entry, int hashIndex, int hashCode, Object key, Object value) {
288: // find the entry before the entry specified in the hash table
289: // remember that the parameters (except the first) refer to the new entry,
290: // not the old one
291: try {
292: int removeIndex = hashIndex(entry.hashCode, data.length);
293: HashEntry[] tmp = data; // may protect against some sync issues
295: HashEntry previous = null;
296: while (loop != entry && loop != null) {
297: previous = loop;
298: loop = loop.next;
299: }
300: if (loop == null) {
301: throw new IllegalStateException(
302: "Entry.next=null, data[removeIndex]=" + data[removeIndex] + " previous=" + previous +
303: " key=" + key + " value=" + value + " size=" + size + " maxSize=" + maxSize +
304: " Please check that your keys are immutable, and that you have used synchronization properly." +
305: " If so, then please report this to commons-dev@jakarta.apache.org as a bug.");
306: }
307:
308: // reuse the entry
309: modCount++;
310: removeEntry(entry, removeIndex, previous);
311: reuseEntry(entry, hashIndex, hashCode, key, value);
312: addEntry(entry, hashIndex);
313: } catch (NullPointerException ex) {
314: throw new IllegalStateException(
315: "NPE, entry=" + entry + " entryIsHeader=" + (entry==header) +
316: " key=" + key + " value=" + value + " size=" + size + " maxSize=" + maxSize +
317: " Please check that your keys are immutable, and that you have used synchronization properly." +
318: " If so, then please report this to commons-dev@jakarta.apache.org as a bug.");
319: }
320: }
321:
322: /**
323: * Subclass method to control removal of the least recently used entry from the map.
324: *
325: