java.util.Locale serialization fails #74

Closed
Toilal opened this Issue Apr 26, 2012 · 1 comment

Comments

Projects
None yet
2 participants
Contributor

Toilal commented Apr 26, 2012

This unit test fails, on db.close();

import static org.junit.Assert.*;

import java.io.File;
import java.io.IOException;
import java.util.Locale;
import java.util.concurrent.ConcurrentMap;

import net.kotek.jdbm.DB;
import net.kotek.jdbm.DBMaker;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.junit.Test;

import com.validit.vitam.utils.jdbm.JDBMBuilder;
import com.validit.vitam.utils.jdbm.JDBMBuilderOptions;

public class JDBMTest {

    @Test
    public void test() throws IOException {
        File directory = new File("test.serializer/test");
        FileUtils.deleteDirectory(directory);
        directory.mkdirs();

        DBMaker dbMaker = DBMaker.openFile(directory.getPath() + "/jdbm");
        DB db = dbMaker.make();
        try {
            ConcurrentMap<String, Locale> map = db.createHashMap("map");

            map.put("en", Locale.ENGLISH);
            map.put("fr", Locale.FRENCH);

            db.commit();
        } finally {
            db.close();
        }

        dbMaker = DBMaker.openFile(directory.getPath() + "/jdbm");
        db = dbMaker.make();

        ConcurrentMap<String, Locale> map = db.getHashMap("map");
        assertEquals(map.get("en"), Locale.ENGLISH);
        assertEquals(map.get("fr"), Locale.FRENCH);
    }

}
java.lang.NoSuchFieldError: class java.util.Locale.hashcode
    at net.kotek.jdbm.SerialClassInfo.getFieldValue(SerialClassInfo.java:221)
    at net.kotek.jdbm.SerialClassInfo.writeObject(SerialClassInfo.java:299)
    at net.kotek.jdbm.Serialization.serialize(Serialization.java:377)
    at net.kotek.jdbm.Serialization.serialize(Serialization.java:84)
    at net.kotek.jdbm.HTreeBucket.writeExternal(HTreeBucket.java:297)
    at net.kotek.jdbm.HTree$1.serialize(HTree.java:68)
    at net.kotek.jdbm.DBStore.update2(DBStore.java:331)
    at net.kotek.jdbm.DBStore.update(DBStore.java:315)
    at net.kotek.jdbm.DBCache.updateCacheEntries(DBCache.java:146)
    at net.kotek.jdbm.DBCacheMRU.close(DBCacheMRU.java:183)
    at JDBMTest.test(JDBMTest.java:38)
......
Owner

jankotek commented Apr 29, 2012

Locale uses advanced java serialization not supported by JDBM. I added custom serialization code for Locale, so this issue is sorted. But in future we will have to add better error message for this type of serialization.

jankotek closed this Apr 29, 2012

@jankotek jankotek added a commit that referenced this issue Jun 19, 2012

@jankotek jankotek Fixed issue #74 d247a92
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment