Uploaded image for project: 'Geode'
  1. Geode
  2. GEODE-6999

NPE When Using disk-usage-warning-percentage property

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.10.0
    • Component/s: configuration
    • Labels:

      Description

      Parsing the cache.xml or cluster.xml file causes the startup to fail with a NullPointerException:

       While parsing XML
      , caused by java.lang.NullPointerException
      	at org.apache.geode.internal.cache.GemFireCacheImpl.initializeDeclarativeCache(GemFireCacheImpl.java:1408)
      	at org.apache.geode.internal.cache.GemFireCacheImpl.initialize(GemFireCacheImpl.java:1243)
      	at org.apache.geode.internal.cache.InternalCacheBuilder.create(InternalCacheBuilder.java:219)
      	at org.apache.geode.internal.cache.InternalCacheBuilder.create(InternalCacheBuilder.java:171)
      	at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:142)
      	at org.apache.geode.internal.cache.xmlcache.CacheXmlParserJUnitTest.cacheXmlParserShouldCorrectlyHandleDiskUsageWarningPercentage(CacheXmlParserJUnitTest.java:161)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
      	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
      	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
      	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
      Caused by: java.lang.NullPointerException
      	at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1838)
      	at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
      	at java.lang.Float.parseFloat(Float.java:451)
      	at org.apache.geode.internal.cache.xmlcache.CacheXmlParser.parseFloat(CacheXmlParser.java:314)
      	at org.apache.geode.internal.cache.xmlcache.CacheXmlParser.startDiskStore(CacheXmlParser.java:1019)
      	at org.apache.geode.internal.cache.xmlcache.CacheXmlParser.startElement(CacheXmlParser.java:2664)
      	at org.apache.geode.internal.cache.xmlcache.CacheXmlParser$DefaultHandlerDelegate.startElement(CacheXmlParser.java:3431)
      	at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
      	at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
      	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
      	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
      	at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
      	at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
      	at org.apache.geode.internal.cache.xmlcache.CacheXmlParser.parse(CacheXmlParser.java:224)
      	at org.apache.geode.internal.cache.GemFireCacheImpl.loadCacheXml(GemFireCacheImpl.java:4285)
      	at org.apache.geode.internal.cache.GemFireCacheImpl.initializeDeclarativeCache(GemFireCacheImpl.java:1399)
      	... 31 more
      

      The problem is within the CacheXmlParser class, we get the disk-usage-critical-percentage attribute but verify for the nullity of disk-usage-warning-percentage instead, causing the NPE when parsing the null value:

      CacheXmlParser.java
      // Some comments here
      private void startDiskStore(Attributes atts) {
        ...
        
        String criticalPct = atts.getValue(DISK_USAGE_CRITICAL_PERCENTAGE);
        if (warnPct != null) {
          attrs.setDiskUsageCriticalPercentage(parseFloat(criticalPct));
        }
      
        stack.push(attrs);
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jjramos Juan José Ramos Cassella
                Reporter:
                jjramos Juan José Ramos Cassella
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m