JakeWharton / DiskLruCache

Java implementation of a Disk-based LRU cache which specifically targets Android compatibility.
http://jakewharton.github.io/DiskLruCache
Apache License 2.0
5.79k stars 1.18k forks source link

Editor edit(String key, long expectedSequenceNumber) should throw ConcurrentModificationException #7

Open wischweh opened 12 years ago

wischweh commented 12 years ago

If called while another editor is in use edit will return null. I had a hard time debugging this. Throwing a ConcurrentModificationException or something similar would be better.

see DiskLruCache Line 512,

DHuckaby commented 12 years ago

Clients call edit() to create or update the values of an entry. An entry may have only one editor at one time; if a value is not available to be edited then edit() will return null.

ref: https://github.com/JakeWharton/DiskLruCache/blob/master/src/main/java/com/jakewharton/DiskLruCache.java#L68

lexs commented 12 years ago

It should definitely not throw a ConcurrentModificationException as that's a RuntimeException. I think it would be valid to throw IOException (as we can't open the file) and then state that it never returns null.

virl commented 9 years ago

It should NOT throw ANYTHING, it should successfully return another Editor and allow concurrent modification of cache.