You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Sergey Antonov (JIRA)" <ji...@apache.org> on 2019/01/31 13:06:00 UTC
[jira] [Created] (IGNITE-11161) ClientCache get by user defined key
returns null
Sergey Antonov created IGNITE-11161:
---------------------------------------
Summary: ClientCache get by user defined key returns null
Key: IGNITE-11161
URL: https://issues.apache.org/jira/browse/IGNITE-11161
Project: Ignite
Issue Type: Bug
Components: thin client
Affects Versions: 2.7
Reporter: Sergey Antonov
Assignee: Sergey Antonov
Fix For: 2.8
Scenario:
* Start server node with predefined cache and activate cluster.
* Connect thin java client to cluster
* Put entry to the cache with user defined key (custom class) from server node.
* Try get value from thin client by the same key.
Expected:
* Returns putted value
Actual:
* Returns null
Reproducer:
{code:java}
import java.util.Objects;
import org.apache.ignite.Ignition;
import org.apache.ignite.client.IgniteClient;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.ClientConfiguration;
import org.apache.ignite.configuration.ClientConnectorConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
@RunWith(JUnit4.class)
public class ClientTestGet extends GridCommonAbstractTest {
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
return super.getConfiguration(igniteInstanceName)
.setClientConnectorConfiguration(new ClientConnectorConfiguration())
.setDataStorageConfiguration(new DataStorageConfiguration())
.setCacheConfiguration(new CacheConfiguration().setName(DEFAULT_CACHE_NAME).setWriteSynchronizationMode(FULL_SYNC));
}
@Override protected void beforeTest() throws Exception {
super.beforeTest();
cleanPersistenceDir();
}
@Test
public void testGet() throws Exception {
IgniteConfiguration serverCfg = getConfiguration("server");
IgniteEx server = startGrid(serverCfg);
server.cluster().active(true);
IgniteClient client = Ignition.startClient(
new ClientConfiguration().setAddresses("127.0.0.1:" + serverCfg.getClientConnectorConfiguration().getPort())
);
server.cache(DEFAULT_CACHE_NAME).put(new Key(0), 0);
Object serverVal = server.cache(DEFAULT_CACHE_NAME).get(new Key(0));
Object clientVal = client.cache(DEFAULT_CACHE_NAME).get(new Key(0));
assertEquals(serverVal, clientVal);
}
private static class Key {
private final int i;
private Key(int i) {
this.i = i;
}
/** {@inheritDoc} */
@Override public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
return i == ((Key)o).i;
}
/** {@inheritDoc} */
@Override public int hashCode() {
return Objects.hash(i);
}
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(Key.class, this);
}
}
}
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)