Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-11161

Thin client's cache get by user defined key returns null

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Duplicate
    • Affects Version/s: 2.7
    • Fix Version/s: 2.8
    • Component/s: thin client
    • Labels:
      None

      Description

      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:

      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);
              }
          }
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                antonovsergey93 Sergey Antonov
                Reporter:
                antonovsergey93 Sergey Antonov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: