java.lang.NullPointerException

Mirth Project | Eduardo Armendariz | 9 months ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    There are a couple of ways to encounter this issue currently. If you are out of any JSON object(state) then a quote would trigger a null pointer. For example you can either send a message to a channel like this, or paste this inside of a JSON message template. {code} {"test":"test"} test" {code} This was just an oversight because technically this is invalid JSON at this point but we still need to handle it gracefully. This issue will give you this exception: {code} Error repainting line range {0,0}: java.lang.NullPointerException at org.syntax.jedit.tokenmarker.JSONTokenMarker.markTokensImpl(JSONTokenMarker.java:58) at org.syntax.jedit.tokenmarker.TokenMarker.markTokens(TokenMarker.java:57) at org.syntax.jedit.TextAreaPainter.paintSyntaxLine(TextAreaPainter.java:594) at org.syntax.jedit.TextAreaPainter.paintLine(TextAreaPainter.java:548) at org.syntax.jedit.TextAreaPainter.paint(TextAreaPainter.java:410) at javax.swing.JComponent.paintToOffscreen(JComponent.java:5219) at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1572) at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1495) at javax.swing.RepaintManager.paint(RepaintManager.java:1265) at javax.swing.JComponent._paintImmediately(JComponent.java:5167) at javax.swing.JComponent.paintImmediately(JComponent.java:4978) at javax.swing.RepaintManager$4.run(RepaintManager.java:824) at javax.swing.RepaintManager$4.run(RepaintManager.java:807) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:807) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:782) at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:731) at javax.swing.RepaintManager.access$1300(RepaintManager.java:64) at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1720) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) at java.awt.EventQueue.dispatchEvent(EventQueue.java:726) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) {code} Having said that...you can also run into this with valid JSON unfortunately. If you have the following JSON: {code} { "test":"test", "test2": "test2"} {code} What happens is that when MirthSyntaxArea calls the setText method it will fire of a DocumentHandler that will try to set the caret to the last line. The way that the JEditTextArea was implement, it currently will try to mark the tokens on this line(without having painted the panel yet). Our JsonTokenMarker depends on the states being set on previous lines to paint the current line, so when trying to mark a line that starts with a quote you can see why it would run into the same issue as above. So it will try to paint this line: "test2": "test2"} Since no states have been defined for the line before it will run into the same null pointer. This would be the resulting strack trace: {code} Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at org.syntax.jedit.tokenmarker.JSONTokenMarker.markTokensImpl(JSONTokenMarker.java:58) at org.syntax.jedit.tokenmarker.TokenMarker.markTokens(TokenMarker.java:57) at org.syntax.jedit.JEditTextArea._offsetToX(JEditTextArea.java:704) at org.syntax.jedit.JEditTextArea.scrollTo(JEditTextArea.java:581) at org.syntax.jedit.JEditTextArea.scrollToCaret(JEditTextArea.java:543) at org.syntax.jedit.JEditTextArea.select(JEditTextArea.java:1323) at org.syntax.jedit.JEditTextArea$DocumentHandler.insertUpdate(JEditTextArea.java:2072) at javax.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:201) at org.syntax.jedit.SyntaxDocument.fireInsertUpdate(SyntaxDocument.java:150) at javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java:748) at javax.swing.text.AbstractDocument.insertString(AbstractDocument.java:707) at org.syntax.jedit.MirthPlainDocument.insertString(MirthPlainDocument.java:122) at org.syntax.jedit.JEditTextArea.setText(JEditTextArea.java:1024) at com.mirth.connect.client.ui.components.MirthSyntaxTextArea.setText(MirthSyntaxTextArea.java:167) at com.mirth.connect.client.ui.TemplatePanel.setMessage(TemplatePanel.java:240) at com.mirth.connect.client.ui.editors.MessageTemplatePanel.setOutboundMessage(MessageTemplatePanel.java:104) at com.mirth.connect.client.ui.editors.TabbedTemplatePanel.setOutgoingMessage(TabbedTemplatePanel.java:115) at com.mirth.connect.client.ui.editors.transformer.TransformerPane.load(TransformerPane.java:206) at com.mirth.connect.client.ui.ChannelSetup.editTransformer(ChannelSetup.java:279) at com.mirth.connect.client.ui.Frame.doEditTransformer(Frame.java:2965) 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:497) at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71) at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275) at java.beans.EventHandler.invokeInternal(EventHandler.java:482) at java.beans.EventHandler.access$000(EventHandler.java:279) at java.beans.EventHandler$1.run(EventHandler.java:430) at java.security.AccessController.doPrivileged(Native Method) at java.beans.EventHandler.invoke(EventHandler.java:428) at com.sun.proxy.$Proxy49.actionPerformed(Unknown Source) at org.jdesktop.swingx.action.BoundAction.actionPerformed(BoundAction.java:231) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) at org.jdesktop.swingx.JXHyperlink.fireActionPerformed(JXHyperlink.java:264) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289) at java.awt.Component.processMouseEvent(Component.java:6525) at javax.swing.JComponent.processMouseEvent(JComponent.java:3324) at java.awt.Component.processEvent(Component.java:6290) at java.awt.Container.processEvent(Container.java:2234) at java.awt.Component.dispatchEventImpl(Component.java:4881) at java.awt.Container.dispatchEventImpl(Container.java:2292) at java.awt.Component.dispatchEvent(Component.java:4703) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462) at java.awt.Container.dispatchEventImpl(Container.java:2278) at java.awt.Window.dispatchEventImpl(Window.java:2750) at java.awt.Component.dispatchEvent(Component.java:4703) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86) at java.awt.EventQueue$4.run(EventQueue.java:731) at java.awt.EventQueue$4.run(EventQueue.java:729) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) {code} This ticket will just be used to track the NPE but I felt it would be good to include how it's not so obvious where this NPE can come from.

    Mirth Project | 9 months ago | Eduardo Armendariz
    java.lang.NullPointerException

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.syntax.jedit.tokenmarker.JSONTokenMarker.markTokensImpl()
    2. org.syntax.jedit
      TextAreaPainter.paint
      1. org.syntax.jedit.tokenmarker.JSONTokenMarker.markTokensImpl(JSONTokenMarker.java:58)
      2. org.syntax.jedit.tokenmarker.TokenMarker.markTokens(TokenMarker.java:57)
      3. org.syntax.jedit.TextAreaPainter.paintSyntaxLine(TextAreaPainter.java:594)
      4. org.syntax.jedit.TextAreaPainter.paintLine(TextAreaPainter.java:548)
      5. org.syntax.jedit.TextAreaPainter.paint(TextAreaPainter.java:410)
      5 frames
    3. Java RT
      EventDispatchThread.run
      1. javax.swing.JComponent.paintToOffscreen(JComponent.java:5219)
      2. javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1572)
      3. javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1495)
      4. javax.swing.RepaintManager.paint(RepaintManager.java:1265)
      5. javax.swing.JComponent._paintImmediately(JComponent.java:5167)
      6. javax.swing.JComponent.paintImmediately(JComponent.java:4978)
      7. javax.swing.RepaintManager$4.run(RepaintManager.java:824)
      8. javax.swing.RepaintManager$4.run(RepaintManager.java:807)
      9. java.security.AccessController.doPrivileged(Native Method)
      10. java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
      11. javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:807)
      12. javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:782)
      13. javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:731)
      14. javax.swing.RepaintManager.access$1300(RepaintManager.java:64)
      15. javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1720)
      16. java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
      17. java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
      18. java.awt.EventQueue.access$500(EventQueue.java:97)
      19. java.awt.EventQueue$3.run(EventQueue.java:709)
      20. java.awt.EventQueue$3.run(EventQueue.java:703)
      21. java.security.AccessController.doPrivileged(Native Method)
      22. java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
      23. java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
      24. java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
      25. java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
      26. java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
      27. java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
      28. java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
      29. java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
      29 frames