Uploaded image for project: 'Red Hat Data Grid'
  1. Red Hat Data Grid
  2. JDG-5531

YamlConfigurationReader throws NPE for valid cache configuration

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • RHDG 8.4 GA
    • RHDG 8.3.1 GA, RHDG 8.x GA
    • API and Configuration
    • None
    • False
    • None
    • False
    • Hide
      Index: server/rest/src/test/java/org/infinispan/rest/resources/CacheResourceV2Test.java
      IDEA additional info:
      Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
      <+>UTF-8
      ===================================================================
      diff --git a/server/rest/src/test/java/org/infinispan/rest/resources/CacheResourceV2Test.java b/server/rest/src/test/java/org/infinispan/rest/resources/CacheResourceV2Test.java
      --- a/server/rest/src/test/java/org/infinispan/rest/resources/CacheResourceV2Test.java	(revision 1bf88ed7dc19e3eb0ce118d3878183428f6e8aae)
      +++ b/server/rest/src/test/java/org/infinispan/rest/resources/CacheResourceV2Test.java	(date 1660663539193)
      @@ -22,6 +22,7 @@
       import static org.infinispan.rest.RequestHeader.ACCEPT_HEADER;
       import static org.infinispan.rest.RequestHeader.KEY_CONTENT_TYPE_HEADER;
       import static org.infinispan.rest.assertion.ResponseAssertion.assertThat;
      +import static org.infinispan.util.concurrent.CompletionStages.await;
       import static org.infinispan.util.concurrent.CompletionStages.join;
       import static org.testng.Assert.assertNull;
       import static org.testng.Assert.fail;
      @@ -911,6 +912,34 @@
             return response.getBody();
          }
       
      +   @Test
      +   public void testReproducer() throws Exception {
      +      RestRawClient rawClient = client.raw();
      +
      +      String xml = "      <replicated-cache name=\"product-cache\" mode=\"SYNC\" statistics=\"true\">\n" +
      +            "        <encoding media-type=\"application/json\"/>\n" +
      +            "        <memory max-count=\"1000\" when-full=\"REMOVE\"/>\n" +
      +            "        <expiration lifespan=\"600000\"/>\n" +
      +            "        <security>\n" +
      +            "          <authorization roles=\"product-admin product-reader product-writer\"/>\n" +
      +            "        </security>\n" +
      +            "      </replicated-cache>";
      +
      +      CompletionStage<RestResponse> response = rawClient.post("/rest/v2/caches?action=convert", Collections.singletonMap("Accept", APPLICATION_YAML_TYPE), xml, APPLICATION_XML_TYPE);
      +
      +      RestResponse r = await(response);
      +      assertThat(r).isOk();
      +      String yaml = r.getBody();
      +
      +      response = rawClient.post("/rest/v2/caches?action=convert", Collections.singletonMap("Accept", APPLICATION_XML_TYPE), yaml, APPLICATION_YAML_TYPE);
      +      assertThat(response).isOk();
      +      checkXML(response);
      +
      +      response = rawClient.post("/rest/v2/caches?action=convert", Collections.singletonMap("Accept", APPLICATION_JSON_TYPE), yaml, APPLICATION_YAML_TYPE);
      +      assertThat(response).isOk();
      +      checkJSON(response, "");
      +   }
      +
          @Test
          public void testConversionFromXML() {
             RestRawClient rawClient = client.raw();
      
      
      Show
      Index: server/ rest /src/test/java/org/infinispan/ rest /resources/CacheResourceV2Test.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/server/ rest /src/test/java/org/infinispan/ rest /resources/CacheResourceV2Test.java b/server/ rest /src/test/java/org/infinispan/ rest /resources/CacheResourceV2Test.java --- a/server/ rest /src/test/java/org/infinispan/ rest /resources/CacheResourceV2Test.java (revision 1bf88ed7dc19e3eb0ce118d3878183428f6e8aae) +++ b/server/ rest /src/test/java/org/infinispan/ rest /resources/CacheResourceV2Test.java (date 1660663539193) @@ -22,6 +22,7 @@ import static org.infinispan. rest .RequestHeader.ACCEPT_HEADER; import static org.infinispan. rest .RequestHeader.KEY_CONTENT_TYPE_HEADER; import static org.infinispan. rest .assertion.ResponseAssertion.assertThat; + import static org.infinispan.util.concurrent.CompletionStages.await; import static org.infinispan.util.concurrent.CompletionStages.join; import static org.testng.Assert.assertNull; import static org.testng.Assert.fail; @@ -911,6 +912,34 @@ return response.getBody(); } + @Test + public void testReproducer() throws Exception { + RestRawClient rawClient = client.raw(); + + String xml = " <replicated-cache name=\" product-cache\ " mode=\" SYNC\ " statistics=\" true \ ">\n" + + " <encoding media-type=\" application/json\ "/>\n" + + " <memory max-count=\" 1000\ " when-full=\" REMOVE\ "/>\n" + + " <expiration lifespan=\" 600000\ "/>\n" + + " <security>\n" + + " <authorization roles=\" product-admin product-reader product-writer\ "/>\n" + + " </security>\n" + + " </replicated-cache>" ; + + CompletionStage<RestResponse> response = rawClient.post( "/ rest /v2/caches?action=convert" , Collections.singletonMap( "Accept" , APPLICATION_YAML_TYPE), xml, APPLICATION_XML_TYPE); + + RestResponse r = await(response); + assertThat(r).isOk(); + String yaml = r.getBody(); + + response = rawClient.post( "/ rest /v2/caches?action=convert" , Collections.singletonMap( "Accept" , APPLICATION_XML_TYPE), yaml, APPLICATION_YAML_TYPE); + assertThat(response).isOk(); + checkXML(response); + + response = rawClient.post( "/ rest /v2/caches?action=convert" , Collections.singletonMap( "Accept" , APPLICATION_JSON_TYPE), yaml, APPLICATION_YAML_TYPE); + assertThat(response).isOk(); + checkJSON(response, ""); + } + @Test public void testConversionFromXML() { RestRawClient rawClient = client.raw();

    Description

      The following cache configuration results in a NullPointerException when parsed:

      replicatedCache: 
        encoding: 
          key: 
            mediaType: application/json
          value: 
            mediaType: application/json
        expiration: 
          lifespan: "600000"
        memory: 
          maxCount: "1000"
          whenFull: REMOVE
        mode: SYNC
        security: 
          authorization: 
            enabled: "true"
            roles: 
              - product-admin
              - product-reader
              - product-writer
        statistics: "true"
      

      Attachments

        Issue Links

          Activity

            People

              ttarrant@redhat.com Tristan Tarrant
              remerson@redhat.com Ryan Emerson
              Fabrizio Asta Fabrizio Asta
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: