Skip to content

Memcached client throwing NullPointerException #86

@tomersagi

Description

@tomersagi

After several successful retrievals I get the following:

java.lang.NullPointerException
    at com.schooner.MemCached.SchoonerSockIOPool.getConnection(Unknown Source)
    at com.schooner.MemCached.SchoonerSockIOPool.getSock(Unknown Source)
    at com.schooner.MemCached.AscIIClient.get(Unknown Source)
    at com.schooner.MemCached.AscIIClient.get(Unknown Source)
    at com.schooner.MemCached.AscIIClient.get(Unknown Source)
    at com.whalin.MemCached.MemCachedClient.get(Unknown Source)
    at com.hpe.labs.patchplanner.dm.indexer.IndexBasedRetriever$KVSRetriever.call(IndexBasedRetriever.java:199)

My code:

public Solution call(Long id) throws Exception {
                SockIOPool pool = IndexBasedSaver.initKVS(repoPath);
                MemCachedClient mmc = new MemCachedClient(IndexBasedSaver.POOL_NAME);
            try {
                Object res = mmc.get(id.toString());
                if (res == null) {
                    throw new Exception("Repository" + Arrays.toString(pool.getServers()) + " doesn't contain the solution key " + id);
                }
                return (Solution) res;
            }
                catch (Exception e) {
                    e.printStackTrace();
                    throw e;
                }
        }

The exception is thrown by the mmc.get(id.toString()); for id=25511.
Using telnet I'm able to retrieve a not null object for the same id.

init method code:

public static SockIOPool initKVS(String serverPath) {
        //initialize the SockIOPool that maintains the Memcached Server Connection Pool
        String[] servers = {serverPath};
        SockIOPool pool = SockIOPool.getInstance(POOL_NAME);
        pool.setServers(servers);
        pool.setFailover(true);
        pool.setInitConn(10);
        pool.setMinConn(5);
        pool.setMaxConn(250);
        pool.setMaintSleep(30);
        pool.setNagle(false);
        pool.setSocketTO(3000);
        pool.setAliveCheck(true);
        pool.initialize();
        return pool;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions