What is the proper way to delegate paste handler execute method when no customization is needed?

I have a custom paste handler that handles pasting file lists into a markdown document to automatically insert links to documents and images. I also detect if the clipboard contains an image and handle saving it to a file and inserting an image link to it.

It works as expected but some users are reporting exceptions when I delegate the call to the original paste handler.

In the constructor I store the passed originalPasteHandler argument in a final field.

In the overridden doExecute(final Editor editor, Caret caret, final DataContext dataContext) I test for proper context for custom handling the action and if not handled delegate the call via:

if (myOriginalHandler != null) {
    myOriginalHandler.execute(editor, caret, dataContext);
}

The exceptions vary a lot and the only common element is my custom handler delegating to original paste handler. I suspect that I might be doing it wrong.

Here are some examples of exceptions generated when delegating to original paste handler:

Exception details:

    "os.name": "Mac OS X",
    "java.version": "1.8.0_112-release",
    "java.vm.vendor": "JetBrains s.r.o",
    "app.name": "IDEA",
    "app.name.full": "IntelliJ IDEA",
    "app.name.version": "IntelliJ IDEA",
    "app.build": "IU-162.2032.8",
    "app.version.major": "2016",
    "app.version.minor": "2.4",
    "update.channel.status": "release",
    "plugin.name": "Markdown Navigator",
    "plugin.version": "2.3.5",
    "last.action": "OpenFile",

com.intellij.psi.PsiInvalidElementAccessException: Element class com.intellij.psi.impl.source.tree.java.ClassElement of type CLASS  
at com.intellij.psi.PsiInvalidElementAccessException.createByNode(PsiInvalidElementAccessException.java:93)  
at com.intellij.psi.impl.source.SubstrateRef$2.getContainingFile(SubstrateRef.java:96)  
at com.intellij.extapi.psi.StubBasedPsiElementBase.getContainingFile(StubBasedPsiElementBase.java:242)  
at com.intellij.diagram.DiagramDataModel.containsRegardlessInjection(DiagramDataModel.java:247)  
at com.intellij.diagram.DiagramDataModel.hasFile(DiagramDataModel.java:223)  
at com.intellij.uml.UmlGraphBuilder$1.documentChanged(UmlGraphBuilder.java:88)  
at sun.reflect.GeneratedMethodAccessor241.invoke(Unknown Source)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at java.lang.reflect.Method.invoke(Method.java:498)  
at com.intellij.util.EventDispatcher.dispatch(EventDispatcher.java:99)  
at com.intellij.util.EventDispatcher.access$200(EventDispatcher.java:35)  
at com.intellij.util.EventDispatcher$2.invoke(EventDispatcher.java:79)  
at com.sun.proxy.$Proxy24.documentChanged(Unknown Source)  
at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:782)  
at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:718)  
at com.intellij.openapi.editor.impl.DocumentImpl.insertString(DocumentImpl.java:480)  
at com.intellij.openapi.editor.EditorModificationUtil.insertStringAtCaretNoScrolling(EditorModificationUtil.java:123)  
at com.intellij.openapi.editor.EditorModificationUtil.insertStringAtCaret(EditorModificationUtil.java:88)  
at com.intellij.openapi.editor.EditorModificationUtil.insertStringAtCaret(EditorModificationUtil.java:80)  
at com.intellij.codeInsight.editorActions.PasteHandler.a(PasteHandler.java:199)  
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:898)  
at com.intellij.codeInsight.editorActions.PasteHandler.a(PasteHandler.java:197)  
at com.intellij.codeInsight.editorActions.PasteHandler.execute(PasteHandler.java:124)  
at com.intellij.codeInsight.editorActions.PasteHandler.doExecute(PasteHandler.java:77)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler$4.perform(EditorActionHandler.java:217)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doIfEnabled(EditorActionHandler.java:109)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:214)  
at com.vladsch.idea.multimarkdown.editor.actions.handlers.MarkdownPasteHandler.doExecute(MarkdownPasteHandler.java:130)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler$4.perform(EditorActionHandler.java:217)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doIfEnabled(EditorActionHandler.java:109)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:214)  
at com.intellij.openapi.editor.actionSystem.EditorAction.lambda$actionPerformed$0(EditorAction.java:100)  
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:129)  
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:109)  
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:88)  
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:197)  
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:213)  
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:587)  
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.a(IdeKeyEventDispatcher.java:634)  
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:199)  
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:633)  
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.d(IdeKeyEventDispatcher.java:477)  
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:211)  
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:607)  
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:385)  
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)
Exception details:
    "os.name": "Windows 10",
    "java.version": "1.8.0_112-release",
    "java.vm.vendor": "JetBrains s.r.o",
    "app.name": "IDEA",
    "app.name.full": "IntelliJ IDEA",
    "app.name.version": "IntelliJ IDEA",
    "app.build": "IC-171.4694.23",
    "app.version.major": "2017",
    "app.version.minor": "1.4",
    "update.channel.status": "release",
    "plugin.name": "Markdown Navigator",
    "plugin.version": "2.3.7",
    "last.action": "TemplateProjectProperties",
    "previous.exception": "",
    
java.lang.NullPointerException   
at com.intellij.codeInsight.editorActions.CopyPasteFoldingProcessor.processTransferableData(CopyPasteFoldingProcessor.java:101)   
at com.intellij.codeInsight.editorActions.PasteHandler.doPaste(PasteHandler.java:215)   
at com.intellij.codeInsight.editorActions.PasteHandler.execute(PasteHandler.java:121)   
at com.intellij.codeInsight.editorActions.PasteHandler.doExecute(PasteHandler.java:74)   
at com.intellij.openapi.editor.actionSystem.EditorActionHandler$4.perform(EditorActionHandler.java:217)   
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doIfEnabled(EditorActionHandler.java:109)   
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:214)   
at com.vladsch.idea.multimarkdown.editor.actions.handlers.MarkdownPasteHandler.doExecute(MarkdownPasteHandler.java:133)   
at com.intellij.openapi.editor.actionSystem.EditorActionHandler$4.perform(EditorActionHandler.java:217)   
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doIfEnabled(EditorActionHandler.java:109)   
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:214)   
at com.intellij.openapi.editor.actionSystem.EditorAction.lambda$actionPerformed$0(EditorAction.java:98)   
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:149)   
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:109)   
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:107)   
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:86)   
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:215)   
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:232)   
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:570)   
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$processAction$2(IdeKeyEventDispatcher.java:619)   
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:193)   
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:618)   
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:477)   
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:211)   
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:633)   
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:365)   
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)   
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)   
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:109)   
at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:184)   
at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:229)   
at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:227)   
at java.security.AccessController.doPrivileged(Native Method)   
at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:227)   
at java.awt.Dialog.show(Dialog.java:1084)   
at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:735)   
at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:457)   
at com.intellij.openapi.ui.DialogWrapper.invokeShow(DialogWrapper.java:1696)   
at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1645)   
at com.intellij.openapi.options.newEditor.SettingsDialog.lambda$show$0(SettingsDialog.java:77)   
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:86)   
at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:151)   
at com.intellij.openapi.options.newEditor.SettingsDialog.show(SettingsDialog.java:77)   
at com.intellij.ide.actions.ShowSettingsUtilImpl.showSettingsDialog(ShowSettingsUtilImpl.java:94)   
at com.intellij.ide.actions.TemplateProjectPropertiesAction.actionPerformed(TemplateProjectPropertiesAction.java:28)   
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:215)   
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:232)   
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.java:309)   
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:929)   
at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:136)   
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:299)   
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)   
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:116)   
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:86)   
at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:109)   
at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:118)   
at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:122)   
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:116)   
at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:513)   
at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:45)   
at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:533)   
at java.awt.Component.processMouseEvent(Component.java:6541)   
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)   
at java.awt.Component.processEvent(Component.java:6306)   
at java.awt.Container.processEvent(Container.java:2236)   
at java.awt.Component.dispatchEventImpl(Component.java:4897)   
at java.awt.Container.dispatchEventImpl(Container.java:2294)   
at java.awt.Component.dispatchEvent(Component.java:4719)   
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)   
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)   
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)   
at java.awt.Container.dispatchEventImpl(Container.java:2280)   
at java.awt.Window.dispatchEventImpl(Window.java:2746)   
at java.awt.Component.dispatchEvent(Component.java:4719)   
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)   
at java.awt.EventQueue.access$500(EventQueue.java:98)   
at java.awt.EventQueue$3.run(EventQueue.java:715)   
at java.awt.EventQueue$3.run(EventQueue.java:709)   
at java.security.AccessController.doPrivileged(Native Method)   
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)   
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)   
at java.awt.EventQueue$4.run(EventQueue.java:737)   
at java.awt.EventQueue$4.run(EventQueue.java:735)   
at java.security.AccessController.doPrivileged(Native Method)   
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)   
at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)   
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:827)   
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:651)   
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:365)   
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)
Exception details:

    "os.name": "Mac OS X",
    "java.version": "1.8.0_40-release",
    "java.vm.vendor": "Oracle Corporation",
    "app.name": "WebStorm",
    "app.build": "WS-145.597",
    "app.version.major": "2016",
    "app.version.minor": "1.1",
    "update.channel.status": "release",
    "plugin.name": "Markdown Navigator",
    "plugin.version": "2.3.7",
    "last.action": "CloseProject",
    "previous.exception": "",
    "error.message": "Comparison method violates its general contract!",
    
java.lang.IllegalArgumentException: Comparison method violates its general contract!  
at java.util.TimSort.mergeHi(TimSort.java:899)  
at java.util.TimSort.mergeAt(TimSort.java:516)  
at java.util.TimSort.mergeCollapse(TimSort.java:441)  
at java.util.TimSort.sort(TimSort.java:245)  
at java.util.Arrays.sort(Arrays.java:1438)  
at sun.awt.datatransfer.DataTransferer.setToSortedDataFlavorArray(DataTransferer.java:2410)  
at sun.awt.datatransfer.ClipboardTransferable.<init>(ClipboardTransferable.java:101)  
at sun.awt.datatransfer.SunClipboard.getContents(SunClipboard.java:143)  
at sun.lwawt.macosx.CClipboard.getContents(CClipboard.java:62)  
at com.intellij.ide.ClipboardSynchronizer$ClipboardHandler.getContents(ClipboardSynchronizer.java:147)  
at com.intellij.ide.ClipboardSynchronizer$MacClipboardHandler.a(ClipboardSynchronizer.java:187)  
at com.intellij.ide.ClipboardSynchronizer$MacClipboardHandler.getContents(ClipboardSynchronizer.java:198)  
at com.intellij.ide.ClipboardSynchronizer$MacClipboardHandler.areDataFlavorsAvailable(ClipboardSynchronizer.java:192)  
at com.intellij.ide.ClipboardSynchronizer.areDataFlavorsAvailable(ClipboardSynchronizer.java:99)  
at com.intellij.ide.CopyPasteManagerEx.areDataFlavorsAvailable(CopyPasteManagerEx.java:77)  
at com.intellij.openapi.editor.EditorModificationUtil.getContentsToPasteToEditor(EditorModificationUtil.java:184)  
at com.intellij.codeInsight.editorActions.PasteHandler.execute(PasteHandler.java:82)  
at com.intellij.codeInsight.editorActions.PasteHandler.doExecute(PasteHandler.java:77)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler$4.perform(EditorActionHandler.java:217)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doIfEnabled(EditorActionHandler.java:109)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:214)  
at com.vladsch.idea.multimarkdown.editor.actions.handlers.MarkdownPasteHandler.doExecute(MarkdownPasteHandler.java:133)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler$4.perform(EditorActionHandler.java:217)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doIfEnabled(EditorActionHandler.java:109)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:214)  
at com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction.java:98)  
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:124)  
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:109)  
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:83)  
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$3.performAction(IdeKeyEventDispatcher.java:595)  
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:646)  
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.b(IdeKeyEventDispatcher.java:485)  
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:215)  
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:631)  
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:386)  
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)
Exception details:

    "os.name": "Windows 10",
    "java.version": "1.8.0_112-release",
    "java.vm.vendor": "JetBrains s.r.o",
    "app.name": "PhpStorm",
    "app.name.full": "PhpStorm",
    "app.build": "PS-171.4694.2",
    "app.version.major": "2017",
    "app.version.minor": "1.4",
    "update.channel.status": "release",
    "plugin.name": "Markdown Navigator",
    "plugin.version": "2.3.7",
    "last.action": "EditorPaste",
    "previous.exception": "",


java.lang.IndexOutOfBoundsException: Wrong line range: [1, 419); lineCount: '138'   
at com.intellij.diff.util.DiffUtil.getLines(DiffUtil.java:914)   
at com.intellij.openapi.vcs.ex.LineStatusTrackerBase.b(LineStatusTrackerBase.java:550)   
at com.intellij.openapi.vcs.ex.LineStatusTrackerBase.a(LineStatusTrackerBase.java:498)   
at com.intellij.openapi.vcs.ex.LineStatusTrackerBase.a(LineStatusTrackerBase.java:474)   
at com.intellij.openapi.vcs.ex.LineStatusTrackerBase.e(LineStatusTrackerBase.java:307)   
at com.intellij.openapi.vcs.ex.LineStatusTrackerBase.access$200(LineStatusTrackerBase.java:43)   
at com.intellij.openapi.vcs.ex.LineStatusTrackerBase$MyApplicationListener.afterWriteActionFinished(LineStatusTrackerBase.java:339)   
at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)   
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   
at java.lang.reflect.Method.invoke(Method.java:498)   
at com.intellij.util.EventDispatcher.dispatch(EventDispatcher.java:99)   
at com.intellij.util.EventDispatcher.access$200(EventDispatcher.java:35)   
at com.intellij.util.EventDispatcher$2.invoke(EventDispatcher.java:79)   
at com.sun.proxy.$Proxy12.afterWriteActionFinished(Unknown Source)   
at com.intellij.openapi.application.impl.ApplicationImpl.e(ApplicationImpl.java:1420)   
at com.intellij.openapi.application.impl.ApplicationImpl.c(ApplicationImpl.java:1246)   
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1026)   
at com.intellij.codeInsight.editorActions.PasteHandler.a(PasteHandler.java:225)   
at com.intellij.codeInsight.editorActions.PasteHandler.execute(PasteHandler.java:121)   
at com.intellij.codeInsight.editorActions.PasteHandler.doExecute(PasteHandler.java:74)   
at com.intellij.openapi.editor.actionSystem.EditorActionHandler$4.perform(EditorActionHandler.java:217)   
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doIfEnabled(EditorActionHandler.java:109)   
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:214)   
at com.vladsch.idea.multimarkdown.editor.actions.handlers.MarkdownPasteHandler.doExecute(MarkdownPasteHandler.java:133)   
at com.intellij.openapi.editor.actionSystem.EditorActionHandler$4.perform(EditorActionHandler.java:217)   
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doIfEnabled(EditorActionHandler.java:109)   
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:214)   
at com.intellij.openapi.editor.actionSystem.EditorAction.lambda$actionPerformed$0(EditorAction.java:98)   
at com.intellij.openapi.command.impl.CoreCommandProcessor.a(CoreCommandProcessor.java:149)   
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:109)   
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:107)   
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:86)   
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:215)   
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:232)   
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:570)   
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.a(IdeKeyEventDispatcher.java:619)   
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:193)   
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:618)   
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.d(IdeKeyEventDispatcher.java:477)   
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:211)   
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:633)   
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:365)   
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)

There are also a few exceptions in formatting on PhpStorm and PyCharm also in delegated paste handler calls:

Exception details:

    "os.name": "Mac OS X",
    "java.version": "1.8.0_76-release",
    "java.vm.vendor": "Oracle Corporation",
    "app.name": "PhpStorm",
    "app.name.full": "PhpStorm",
    "app.build": "PS-145.1616",
    "app.version.major": "2016",
    "app.version.minor": "1.2",
    "update.channel.status": "release",
    "plugin.name": "Markdown Navigator",
    "plugin.version": "2.3.7",
    "last.action": "CloseProject",
    "previous.exception": "",

java.lang.Throwable  
at com.jetbrains.php.lang.formatter.PhpFormattingModelBuilder.createModel(PhpFormattingModelBuilder.java:1)  
at com.intellij.formatting.InitialInfoBuilder.assertInvalidRanges(InitialInfoBuilder.java:517)  
at com.intellij.formatting.WhiteSpace.append(WhiteSpace.java:127)  
at com.intellij.formatting.InitialInfoBuilder.a(InitialInfoBuilder.java:201)  
at com.intellij.formatting.InitialInfoBuilder.a(InitialInfoBuilder.java:320)  
at com.intellij.formatting.InitialInfoBuilder.iteration(InitialInfoBuilder.java:146)  
at com.intellij.formatting.FormatProcessor$WrapBlocksState.doIteration(FormatProcessor.java:1409)  
at com.intellij.formatting.FormatProcessor$State.iteration(FormatProcessor.java:1339)  
at com.intellij.formatting.FormatProcessor.iteration(FormatProcessor.java:283)  
at com.intellij.formatting.FormatterImpl.a(FormatterImpl.java:540)  
at com.intellij.formatting.FormatterImpl.a(FormatterImpl.java:513)  
at com.intellij.formatting.FormatterImpl.adjustLineIndentsForRange(FormatterImpl.java:393)  
at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$6.doPerform(CodeStyleManagerImpl.java:397)  
at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerRunnable.perform(CodeStyleManagerRunnable.java:109)  
at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.adjustLineIndent(CodeStyleManagerImpl.java:400)  
at com.intellij.codeInsight.editorActions.PasteHandler.a(PasteHandler.java:321)  
at com.intellij.codeInsight.editorActions.PasteHandler.access$000(PasteHandler.java:62)  
at com.intellij.codeInsight.editorActions.PasteHandler$3.run(PasteHandler.java:251)  
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1009)  
at com.intellij.codeInsight.editorActions.PasteHandler.a(PasteHandler.java:237)  
at com.intellij.codeInsight.editorActions.PasteHandler.execute(PasteHandler.java:130)  
at com.intellij.codeInsight.editorActions.PasteHandler.doExecute(PasteHandler.java:77)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler$4.perform(EditorActionHandler.java:217)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doIfEnabled(EditorActionHandler.java:109)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:214)  
at com.vladsch.idea.multimarkdown.editor.actions.handlers.MarkdownPasteHandler.doExecute(MarkdownPasteHandler.java:133)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler$4.perform(EditorActionHandler.java:217)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doIfEnabled(EditorActionHandler.java:109)  
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:214)  
at com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction.java:98)  
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:124)  
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:109)  
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:83)  
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$3.performAction(IdeKeyEventDispatcher.java:595)  
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:646)  
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.d(IdeKeyEventDispatcher.java:485)  
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:215)  
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:631)  
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:386)  
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)
0
10 comments

You do the delegation correctly, the exceptions that you've given here have nothing to do with your plugin, they would happen also if your paste handler was not in the invocation chain.

We do receive these exceptions and try to fix them, if users send reports to us via IDEA's fatal error reporter. But if you or your plugin's users have specific use cases, that lead to such exceptions, it can be helpful to raise a ticket in YouTrack with steps to reproduce.

0

Thanks Dmitry. I will open YouTrack tickets for these issues if I can figure out specific use cases.

Most of the issues submitted by users do not include use case details, only the exception and system details. It appears that these issues are intermittent and dependent on timing.

 

0

Dmitry, I did open a report but not sure if one report is significant. The errors are all over the place and not related to a single cause.

I have been glancing over these reports and pulling out ones that are caused by my plugin and possibly caused by my plugin and ignored the rest. I never did an assessment of how many of these I got until today.

I received a total of 575 exception reports for MarkdownPasteHandler. Out of these 540 are not flagged as related to the plugin. There could be a few stragglers in the 540 but not significant enough to change the ratio.

I am still getting these almost on a daily basis and was wondering if anyone at JetBrains would be interested in the stack trace and other exception report information contained in these.

I can pull them from the database and either save as SQL, JSON or other format.

0

There's no easy way currenty for you to submit those back to us. You can submit existing via YouTrack, but they'll keep coming.

Ideally, editor action extension mechanism needs to be rewritten, so that all added handlers do not appear in stack trace. But that won't happen soon. For now, you can probably just silence those exceptions in your plugin by catching and logging them.

0

Dmitry, a rewrite is needed but that would only affect future IDE versions. In the mean time you are not getting relevant reports to help diagnose these issues.

My concern was not for getting these “spurious” reports. After two years of practice, I can identify a paste handler exception report faster than I can identify spam. So it is no trouble nor a distraction.

As for the rewrite for the mechanism would it help if I proposed a solution with a patch?

I would probably use the current implementation with a twist. Instead of each extension getting a pointer to “Previous Implementation” which performs the default paste action, they would all get a pointer to a dummy implementation which does nothing but flag that the extension point did not handle the paste.

If no extension handles the paste then default implementation is used and no plugin paste handler will be attributed exceptions caused by default implementation because they never invoke it.

This would create minimal effect on plugins currently implementing the extension point and on the current code other than looping over the extensions and checking if they invoked the default handler.

0

Your proposal can change the semantics of handlers - e.g. a handler might want to do some post-processing after the original handler's logic is executed. There are actually quite a few of such cases in the platform itself. I'm afraid a completely new API is needed to fix this problem.

0

In that case I can see the difficulty. You either need a new API and have to drop the old one with no grace period because there is no way to seamlessly support both or you need to find a way of getting the extension out of the stack trace while leaving it in the call chain to handle post processing while remaining on the AWT thread. It looks like a gordian knot.

0

I think I found a simple solution to this problem by attributing the exception to the guilty party and generating the proper exception report.

I stumbled on the idea while doing my morning browsing through the changes in intellij-community project update and saw changed code adding a try/catch around extension calls. I don’t know why I did not think of this before. Just change exception handler to what IDE uses to attribute plugin errors but on the original handler class:

if (myOriginalHandler != null) {
    try {
        myOriginalHandler.execute(editor, caret, dataContext);
    } catch (Throwable e) {
        LOG.error(PluginException.createByClass(e, myOriginalHandler.getClass()));
    }
}

From a quick look at the code, I think this will do the trick.

0

The same but should be compatible all the way back to 2016. The previous implementation is 2019 only.

if (myOriginalHandler != null) {
    try {
        myOriginalHandler.execute(editor, caret, dataContext);
    } catch (Throwable e) {
        PluginId pluginId = PluginManagerCore.getPluginByClassName(myOriginalHandler.getClass().getName());
        LOG.error(new PluginException(e, pluginId));
    }
}
0

Success! Changed to handle API evolution from 2016 to 2019.

Tested in 2019.3 by causing an exception in original paste handler. Passed it a non-null caret parameter:

if (myOriginalHandler != null) {
    try {
        myOriginalHandler.execute(editor, caret, dataContext);
    } catch (Throwable e) {
        PluginId pluginId;
        try {
            // this one is 2019(ish) only
            pluginId = PluginManagerCore.getPluginOrPlatformByClassName(myOriginalHandler.getClass().getName());
        } catch (Throwable ignored) {
            // use old implementation, goes back to 2016
            pluginId = PluginManagerCore.getPluginByClassName(myOriginalHandler.getClass().getName());
        }
        LOG.error(new PluginException("execute() delegated to original paste handler, " + e.getMessage(), e, pluginId));
    }
}

 

 

0

Please sign in to leave a comment.