Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-3143

Cannot store custom objects via HotRod and read via REST

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Done
    • Major
    • 5.3.0.CR1
    • 5.3.0.Beta2
    • None
    • None

    Description

      The following test fails when added to EmbeddedRestHotRodTest

      public void testCustomObjectHotRodPutEmbeddedRestGet() throws Exception{
            final String key = "4";
            Person p = new Person("Martin");
            // 1. Put with Hot Rod
            RemoteCache<String, Object> remote = cacheFactory.getHotRodCache();
            assertEquals(null, remote.withFlags(Flag.FORCE_RETURN_VALUE).put(key, p));
      
            // 2. Get with Embedded
            assertTrue(cacheFactory.getEmbeddedCache().get(key) instanceof Person);
            assertEquals(p.getName(), ((Person) cacheFactory.getEmbeddedCache().get(key)).getName());
      
            // 3. Get with REST
            HttpMethod get = new GetMethod(cacheFactory.getRestUrl() + "/" + key);
            cacheFactory.getRestClient().executeMethod(get);
      
            assertEquals(HttpServletResponse.SC_OK, get.getStatusCode());  
      //^^^ fails here - status code 500, status text: NullPointerException
      
            Object returnedPerson = remote.getRemoteCacheManager().getMarshaller().objectFromByteBuffer(get.getResponseBodyAsString().getBytes());
            assertTrue(returnedPerson instanceof Person);
            assertEquals(p.getName(), ((Person) returnedPerson).getName());
         }
      
         public static class Person implements Serializable {
      
            private String name;
      
            public Person(String name) {
               this.name = name;
            }
      
            public String getName() {
               return name;
            }
         }
      

      Storing and retrieving String keys works correctly.

      Attachments

        Activity

          People

            rh-ee-galder Galder ZamarreƱo
            mgencur Martin Gencur
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: