Issue 62: Close recordstore cause data lost when memoryRecordStore is chosen
Status:  New
Owner: ----
Reported by michal.k...@gtempaccount.com, Aug 23, 2010
Recently I updated microemu to 3.0 Snapshot. We use it as an applet on our site. 

1. I found such problem: during initialization of our app record store is opened an closed in some sequence.
 
2. I am using MemoryRecordStoreManager.

3. The application was hanging up during initialization, but when I started microeumu standalone whit FileRecordstore option everything was fine.

4. I ve found that app is hanging up beacuse of infinite loop in method: rebuild() in RecordEnumerationImpl. In while loop method getNumRecords returns non zero value but records Hashtable in RecordStoreImpl is empty  so loop never ends.

5. I ve found that it is beacuse of method closeRecordStore in RecordStoreImpl. Where records Hashtable is cleared.But size and lastRecordId field is not updated. I think is it is fine in case of FileRecordStore cause this data can be obtained from file. But in case of MemoryRecordstore this data is lost cause there is no RecordStore file from where data can be obtained.

6. I have comented this line and everything works fine for me. But I think that FileRecordstore won`t work.


Feb 7, 2011
#1 j...@toro-asia.com
Hi all!

I have got the same problem, and I resolve it doing a quick and dirty fix like this:

To the microemu-midp/src/main/java/org/microemu/RecordStoreManager.java interface I added this:
boolean cleanRecordsOnCloseRecordStore();
And to the microemu-midp/src/main/java/org/microemu/util/RecordStoreImpl.java class, in the method closeRecordStore(), I changed that "records.clear" by:
if (recordStoreManager.cleanRecordsOnCloseRecordStore()) {
	records.clear();
}
The implementation of the MemoryRecordStoreManager, that method returns "true", and for the others "false".

I attach some of the files.

I hope if can also work for you.

Best regards,

Jose
RecordStoreImpl.java
12.6 KB   View   Download
RecordStoreManager.java
2.4 KB   View   Download
MemoryRecordStoreManager.java
3.8 KB   View   Download
FileRecordStoreManager.java
10.5 KB   View   Download