Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-55575

Chart Macro Makes Confluence Hang/Crash

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Medium Medium
    • None
    • 6.6.0, 6.7.0, 6.8.1, 7.19.17
    • Macros - Chart

      Summary

      Chart macro crashes or makes Confluence unresponsive  depending on the settings and values used to compose the graph.

      Steps to Reproduce

      1. Create a page
      2. Add the Chart macro with the following settings:
        • Type = timeSeries
        • Content Orientation = vertical
        • Date format = MMM yyyy
        • Time Period - Month
      3. Create a table with 2 columns in the body of the chart macro
        • First column = Date
        • Second column = Value
      4. Add two lines with these values:
        1. Jan 21 2018 | 123123
        2. Feb 222018 | 123456
      5. Edit the Chart macro to preview the graph

      For some reason, if we put the data with the year altogether, the macro breaks and the instance stops responding.

      This also happens if the date has two <span> tag in the source code:

      <td colspan="1"><span>Jan 28 </span><span>2019</span></td>
      

      Expected Results

      The graph will work or the macro prints out a message indicating an issue with the format of the input value.

      Actual Results

      The application hangs and may eventually crash with high CPU or heap exhaustion.

      Without thread dumps, stuck threads referencing a page that contains the chart will be recorded within the catalina logs.  The related stack trace will reference a Java package utilized by the Chart macro along with some method involving date processing - for example:

      03-May-2024 13:54:32.309 WARNING [Catalina-utility-1] org.apache.catalina.valves.StuckThreadDetectionValve.notifyStuckThreadDetected Thread [https-jsse-nio-8443-exec-30] (id=[352]) has been active for [64,158] milliseconds (since [5/3/24 1:53 PM]) to serve the same request for [https://samplesite.com/display/Somespace/Page+with+Chart+macro?src=contextnavpagetreemode] and may be stuck (configured threshold for this StuckThreadDetectionValve is [60] seconds). There is/are [1] thread(s) in total that are monitored by this Valve and may be stuck.
      	java.lang.Throwable
      		at java.base@11.0.20.1/sun.util.calendar.JulianCalendar$Date.setNormalizedYear(Unknown Source)
      		at java.base@11.0.20.1/sun.util.calendar.JulianCalendar.getCalendarDateFromFixedDate(Unknown Source)
      		at java.base@11.0.20.1/java.util.GregorianCalendar.computeFields(Unknown Source)
      		at java.base@11.0.20.1/java.util.GregorianCalendar.computeFields(Unknown Source)
      		at java.base@11.0.20.1/java.util.Calendar.setTimeInMillis(Unknown Source)
      		at java.base@11.0.20.1/java.util.Calendar.setTime(Unknown Source)
      		at org.jfree.chart.axis.DateTickUnit.addToDate(DateTickUnit.java:239)
      		at org.jfree.chart.axis.DateAxis.refreshTicksHorizontal(DateAxis.java:1629)
      		at org.jfree.chart.axis.DateAxis.refreshTicks(DateAxis.java:1556)
      		at org.jfree.chart.axis.ValueAxis.reserveSpace(ValueAxis.java:807)
      

      If thread dumps are captured while rendering the page - you may see a blocked thread like the following:

      "http-nio-8681-exec-4" #174 daemon prio=5 os_prio=0 tid=0x00007f22204b7000 nid=0xf03 runnable [0x00007f20f5e5c000]
         java.lang.Thread.State: RUNNABLE
        at java.text.SimpleDateFormat.subFormat(SimpleDateFormat.java:1338)
        at java.text.SimpleDateFormat.format(SimpleDateFormat.java:966)
        at java.text.SimpleDateFormat.format(SimpleDateFormat.java:936)
        at java.text.DateFormat.format(DateFormat.java:345)
        at org.jfree.chart.axis.DateAxis.refreshTicksHorizontal(DateAxis.java:1437)
        at org.jfree.chart.axis.DateAxis.refreshTicks(DateAxis.java:1395)
        at org.jfree.chart.axis.ValueAxis.reserveSpace(ValueAxis.java:768)
        at org.jfree.chart.plot.XYPlot.calculateDomainAxisSpace(XYPlot.java:2041)
        at org.jfree.chart.plot.XYPlot.calculateAxisSpace(XYPlot.java:1998)
        at org.jfree.chart.plot.XYPlot.draw(XYPlot.java:2130)
        at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1039)
        at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1213)
        at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1193)
        at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1178)
        at com.atlassian.confluence.extra.chart.ChartMacro.getChartImage(ChartMacro.java:418)
        at com.atlassian.confluence.extra.chart.ChartMacro.execute(ChartMacro.java:321)
        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 com.atlassian.confluence.macro.xhtml.XhtmlMacroManager$ResourceAwareMacroInvocationHandler.invoke(XhtmlMacroManager.java:203)
        at com.sun.proxy.$Proxy2506.execute(Unknown Source)
        at com.atlassian.confluence.content.render.xhtml.view.macro.ViewMacroMarshaller.executeMacro(ViewMacroMarshaller.java:273)
        at com.atlassian.confluence.content.render.xhtml.view.macro.ViewMacroMarshaller.marshalInternal(ViewMacroMarshaller.java:193)
        at com.atlassian.confluence.content.render.xhtml.view.macro.ViewMacroMarshaller.lambda$marshal$0(ViewMacroMarshaller.java:148)
        at com.atlassian.confluence.content.render.xhtml.view.macro.ViewMacroMarshaller$$Lambda$1240/1715426872.marshal(Unknown Source)
        at com.atlassian.confluence.impl.content.render.xhtml.analytics.MetricsCollectingMarshaller.marshal(MetricsCollectingMarshaller.java:52)
        at com.atlassian.confluence.content.render.xhtml.view.macro.ViewMacroMarshaller.marshal(ViewMacroMarshaller.java:155)
        at com.atlassian.confluence.content.render.xhtml.view.macro.ViewMacroMarshaller.marshal(ViewMacroMarshaller.java:58)
        at com.atlassian.confluence.content.render.xhtml.DefaultXhtmlContent.convertMacroDefinitionToView(DefaultXhtmlContent.java:145)
      

      Eventually, the thread becomes BLOCKED:

      "http-nio-8681-exec-4" #174 daemon prio=5 os_prio=0 tid=0x00007f22204b7000 nid=0xf03 waiting for monitor entry [0x00007f20f5e5c000]
         java.lang.Thread.State: BLOCKED (on object monitor)
        at java.util.SimpleTimeZone.getOffsets(SimpleTimeZone.java:551)
        - waiting to lock <0x00000000d7615f10> (a java.util.SimpleTimeZone)
        at java.util.SimpleTimeZone.getOffset(SimpleTimeZone.java:540)
        at sun.util.calendar.ZoneInfo.getOffsets(ZoneInfo.java:293)
        at sun.util.calendar.ZoneInfo.getOffsets(ZoneInfo.java:236)
        at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2340)
        at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2818)
        at java.util.Calendar.updateTime(Calendar.java:3393)
        at java.util.Calendar.getTimeInMillis(Calendar.java:1782)
        at java.util.Calendar.getTime(Calendar.java:1755)
        at org.jfree.data.time.Year.getFirstMillisecond(Year.java:241)
        at org.jfree.data.time.Year.peg(Year.java:180)
        at org.jfree.data.time.Year. (Year.java:131)
        at org.jfree.data.time.Year. (Year.java:118)
        at org.jfree.chart.axis.DateAxis.refreshTicksHorizontal(DateAxis.java:1491)
        at org.jfree.chart.axis.DateAxis.refreshTicks(DateAxis.java:1395)
        at org.jfree.chart.axis.ValueAxis.reserveSpace(ValueAxis.java:768)
        at org.jfree.chart.plot.XYPlot.calculateDomainAxisSpace(XYPlot.java:2041)
        at org.jfree.chart.plot.XYPlot.calculateAxisSpace(XYPlot.java:1998)
        at org.jfree.chart.plot.XYPlot.draw(XYPlot.java:2130)
        at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1039)
        at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1213)
        at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1193)
        at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1178)
        at com.atlassian.confluence.extra.chart.ChartMacro.getChartImage(ChartMacro.java:418)
        at com.atlassian.confluence.extra.chart.ChartMacro.execute(ChartMacro.java:321)
      

      Or a thread consuming high CPU on a sustained basis:

      "https-jsse-nio-8443-exec-56" #377 daemon prio=5 os_prio=0 cpu=197196.31ms elapsed=30743.30s tid=0x00007fd970186800 nid=0x6c4b runnable  [0x00007fd804035000]
         java.lang.Thread.State: RUNNABLE
      	at sun.java2d.loops.MaskFill.FillAAPgram(java.desktop@11.0.20.1/Native Method)
      	at sun.java2d.pipe.AlphaColorPipe.fillParallelogram(java.desktop@11.0.20.1/Unknown Source)
      	at sun.java2d.pipe.PixelToParallelogramConverter.drawGeneralLine(java.desktop@11.0.20.1/Unknown Source)
      	at sun.java2d.pipe.PixelToParallelogramConverter.draw(java.desktop@11.0.20.1/Unknown Source)
      	at sun.java2d.SunGraphics2D.draw(java.desktop@11.0.20.1/Unknown Source)
      	at org.jfree.chart.renderer.category.AbstractCategoryItemRenderer.drawRangeLine(AbstractCategoryItemRenderer.java:840)
      	at org.jfree.chart.plot.CategoryPlot.drawRangeGridlines(CategoryPlot.java:3948)
      	at org.jfree.chart.plot.CategoryPlot.draw(CategoryPlot.java:3576)
      	at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1235)
      	at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1409)
      	at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1389)
      	at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1374)
      	at com.atlassian.confluence.extra.chart.ChartMacro.getChartImage(ChartMacro.java:412)
      	at com.atlassian.confluence.extra.chart.ChartMacro.execute(ChartMacro.java:328)
      

      Notes

      In this example we simply keep the day and year together, which causes the problem.

      However, it's important to note that other combinations that do not conform to Java's SimpleDataFormat may result in the same problem.

      Workaround

      To fix an incorrect date format contained with the Chart macro configuration:

      • If the page containing the Chart macro is displayable, edit the Chart macro configuration natively or the page's source code using the Source Code Editor plugin and look for multiple span tags in the same cell of the table.
      • If the page containing the Chart macro can't be displayed, disable the Chart plugin:
        • Click on > Manage Apps
        • Enter chart in the search field
        • Change the dropdown list to System
        • (i)You should see chart-plugin being filtered below after all the apps have been loaded
        • Click chart-plugin to expand it
        • Click Disable
        • Then edit the Chart macro configuration natively or the page source as mentioned above.

      Also, note that LTS Confluence 8.5.x should now display a message indicating a formatting issue with the input data - for example:

      Incorrect data values found in the content. Date format: yyyy-mm-dd HH:mm

      As such, another option would be to upgrade to this LTS release. 

              mandreacchio Michael Andreacchio
              emallmann Eduardo Mallmann (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: