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

NPE when yaml configuration contains null value

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 13.0.8.Final, 14.0.0.Dev02
    • Configuration
    • None
    • 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 84ce93c20751e987d23dff15afa4e21b05d9be5c)
      +++ b/server/rest/src/test/java/org/infinispan/rest/resources/CacheResourceV2Test.java (date 1649159830069)
      @@ -876,6 +876,9 @@
      " <memory>\n" +
      " <object size=\"20\"/>\n" +
      " </memory>\n" +
      + " <persistence>\n" +
      + " <file-store/>\n" +
      + " </persistence>\n" +
      " </distributed-cache>\n" +
      " </cache-container>\n" +
      "</infinispan>";
      @@ -893,7 +896,7 @@
      public void testConversionFromJSON() throws Exception {
      RestRawClient rawClient = client.raw();

      • String json = "{\"distributed-cache\":{\"mode\":\"SYNC\",\"memory\": {\"storage\":\"OBJECT\",\"max-count\":\"20\"}

        }}";
        + String json = "{\"distributed-cache\":{\"mode\":\"SYNC\",\"memory\":

        {\"storage\":\"OBJECT\",\"max-count\":\"20\"}

        ,\"persistence\":{\"file-store\":{}}}}";

      CompletionStage<RestResponse> response = rawClient.post("/rest/v2/caches?action=convert", Collections.singletonMap("Accept", APPLICATION_XML_TYPE), json, APPLICATION_JSON_TYPE);
      assertThat(response).isOk();
      @@ -912,7 +915,9 @@
      " mode: 'SYNC'\n" +
      " memory:\n" +
      " storage: 'OBJECT'\n" +

      • " maxCount: 20";
        + " maxCount: 20\n" +
        + " persistence:\n" +
        + " fileStore: null";

      CompletionStage<RestResponse> response = rawClient.post("/rest/v2/caches?action=convert", Collections.singletonMap("Accept", APPLICATION_XML_TYPE), yaml, APPLICATION_YAML_TYPE);
      assertThat(response).isOk();

      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 84ce93c20751e987d23dff15afa4e21b05d9be5c) +++ b/server/rest/src/test/java/org/infinispan/rest/resources/CacheResourceV2Test.java (date 1649159830069) @@ -876,6 +876,9 @@ " <memory>\n" + " <object size=\"20\"/>\n" + " </memory>\n" + + " <persistence>\n" + + " <file-store/>\n" + + " </persistence>\n" + " </distributed-cache>\n" + " </cache-container>\n" + "</infinispan>"; @@ -893,7 +896,7 @@ public void testConversionFromJSON() throws Exception { RestRawClient rawClient = client.raw(); String json = "{\"distributed-cache\":{\"mode\":\"SYNC\",\"memory\": {\"storage\":\"OBJECT\",\"max-count\":\"20\"} }}"; + String json = "{\"distributed-cache\":{\"mode\":\"SYNC\",\"memory\": {\"storage\":\"OBJECT\",\"max-count\":\"20\"} ,\"persistence\":{\"file-store\":{}}}}"; CompletionStage<RestResponse> response = rawClient.post("/rest/v2/caches?action=convert", Collections.singletonMap("Accept", APPLICATION_XML_TYPE), json, APPLICATION_JSON_TYPE); assertThat(response).isOk(); @@ -912,7 +915,9 @@ " mode: 'SYNC'\n" + " memory:\n" + " storage: 'OBJECT'\n" + " maxCount: 20"; + " maxCount: 20\n" + + " persistence:\n" + + " fileStore: null"; CompletionStage<RestResponse> response = rawClient.post("/rest/v2/caches?action=convert", Collections.singletonMap("Accept", APPLICATION_XML_TYPE), yaml, APPLICATION_YAML_TYPE); assertThat(response).isOk();

      Attempting to convert the following yaml config via /v2/caches?action=convert endpoint throws a NPE:

      11:42:59,338 ERROR (blocking-thread--p3-t1) [org.infinispan.rest.RestRequestHandler] ISPN012005: An error occurred while responding to the client java.util.concurrent.CompletionException: org.infinispan.commons.CacheConfigurationException: java.lang.NullPointerException
      	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
      	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
      	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1702)
      	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
      	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
      	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
      	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
      	at java.base/java.lang.Thread.run(Thread.java:829)
      Caused by: org.infinispan.commons.CacheConfigurationException: java.lang.NullPointerException
      	at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:163)
      	at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:145)
      	at org.infinispan.rest.resources.CacheResourceV2.lambda$convert$5(CacheResourceV2.java:333)
      	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
      	... 5 more
      Caused by: java.lang.NullPointerException
      	at org.infinispan.commons.configuration.io.yaml.YamlConfigurationReader.nextElement(YamlConfigurationReader.java:419)
      	at org.infinispan.commons.configuration.io.ConfigurationReader.inTag(ConfigurationReader.java:143)
      	at org.infinispan.configuration.parsing.CacheParser.parseDistributedCache(CacheParser.java:1226)
      	at org.infinispan.configuration.parsing.CacheParser.readElement(CacheParser.java:116)
      	at org.infinispan.configuration.parsing.ParserRegistry.parseElement(ParserRegistry.java:209)
      	at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:187)
      	at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:175)
      	at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:157)
      	... 8 more
      

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

              Created:
              Updated: