dandycheung / microemu

Automatically exported from code.google.com/p/microemu
0 stars 0 forks source link

Close recordstore cause data lost when memoryRecordStore is chosen #62

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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.

Original issue reported on code.google.com by michal.k...@gtempaccount.com on 23 Aug 2010 at 2:01

GoogleCodeExporter commented 8 years ago
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

Original comment by j...@toro-asia.com on 8 Feb 2011 at 2:00

Attachments: