question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPE in clipboard copy

See original GitHub issue

I get an NPE when pressing Ctrl+C, but only if the selection includes a line separator and ends at the beginning of a line.

This is a regression. Used 0.7-M3 before where it worked. So I checked out various commits to find out the commit that broke it. It is commit a2aa8813e48e91e9eef461c20d28c5eac8724592. It works when I checkout the previous commit.

To reproduce, run this little app and press Ctrl+C:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.CodeArea;

public class ClipboardCopyNPE extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        CodeArea area = new CodeArea("abc\ndef\nghi");
        VirtualizedScrollPane<CodeArea> vsPane = new VirtualizedScrollPane<>(area);

        area.selectRange(2, 4);
        
        Scene scene = new Scene(vsPane, 400, 400);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

The NPE is:

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
	at org.fxmisc.richtext.model.SuperCodec$1.encodeSuper(SuperCodec.java:33)
	at org.fxmisc.richtext.model.SuperCodec$1.encodeSuper(SuperCodec.java:1)
	at org.fxmisc.richtext.model.SuperCodec.encode(SuperCodec.java:15)
	at org.fxmisc.richtext.model.StyledText$2.encode(StyledText.java:94)
	at org.fxmisc.richtext.model.StyledText$2.encode(StyledText.java:1)
	at org.fxmisc.richtext.model.SuperCodec$1.encodeSuper(SuperCodec.java:35)
	at org.fxmisc.richtext.model.SuperCodec$1.encodeSuper(SuperCodec.java:1)
	at org.fxmisc.richtext.model.SuperCodec.encode(SuperCodec.java:15)
	at org.fxmisc.richtext.model.ReadOnlyStyledDocument$3.encode(ReadOnlyStyledDocument.java:139)
	at org.fxmisc.richtext.model.ReadOnlyStyledDocument$3.encode(ReadOnlyStyledDocument.java:1)
	at org.fxmisc.richtext.model.SuperCodec$1.encodeSuper(SuperCodec.java:35)
	at org.fxmisc.richtext.model.SuperCodec$1.encodeSuper(SuperCodec.java:1)
	at org.fxmisc.richtext.model.SuperCodec.encode(SuperCodec.java:15)
	at org.fxmisc.richtext.model.ReadOnlyStyledDocument$2.encode(ReadOnlyStyledDocument.java:116)
	at org.fxmisc.richtext.model.ReadOnlyStyledDocument$2.encode(ReadOnlyStyledDocument.java:1)
	at org.fxmisc.richtext.ClipboardActions.lambda$0(ClipboardActions.java:67)
	at java.util.Optional.ifPresent(Optional.java:159)
	at org.fxmisc.richtext.ClipboardActions.copy(ClipboardActions.java:60)
	at org.fxmisc.richtext.GenericStyledAreaBehavior.lambda$28(GenericStyledAreaBehavior.java:149)
	at org.fxmisc.wellbehaved.event.template.InputMapTemplate.lambda$consume$32(InputMapTemplate.java:107)
	at org.fxmisc.wellbehaved.event.template.PatternActionTemplate.lambda$null$44(InputMapTemplate.java:242)
	at java.util.Optional.map(Optional.java:215)
	at org.fxmisc.wellbehaved.event.template.PatternActionTemplate.lambda$getInputHandlerTemplateMap$45(InputMapTemplate.java:242)
	at org.fxmisc.wellbehaved.event.template.InputHandlerTemplateMap.lambda$sequence$39(InputHandlerTemplateMap.java:25)
	at org.fxmisc.wellbehaved.event.template.InputMapTemplate$1.lambda$null$30(InputMapTemplate.java:92)
	at org.fxmisc.wellbehaved.event.template.InputHandlerTemplateMap.lambda$sequence$39(InputHandlerTemplateMap.java:24)
	at org.fxmisc.wellbehaved.event.template.InputMapTemplate$HandlerTemplateConsumer$1.lambda$accept$29(InputMapTemplate.java:36)
	at org.fxmisc.wellbehaved.event.InputHandler.handle(InputHandler.java:15)
	at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
	at javafx.event.Event.fireEvent(Event.java:198)
	at javafx.scene.Scene$KeyHandler.process(Scene.java:3964)
	at javafx.scene.Scene$KeyHandler.access$1800(Scene.java:3910)
	at javafx.scene.Scene.impl_processKeyEvent(Scene.java:2040)
	at javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2501)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:217)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:149)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent$353(GlassViewEventHandler.java:248)
	at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:247)
	at com.sun.glass.ui.View.handleKeyEvent(View.java:546)
	at com.sun.glass.ui.View.notifyKey(View.java:966)
	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
	at java.lang.Thread.run(Thread.java:748)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
JordanMartinezcommented, Sep 6, 2017

Mm… I implemented that class in #553 as a way to make it easier for others to implement custom objects in the area. However, I later realized in #550 (which was created before #553 but merged after it) that such an approach wouldn’t work because sometimes a segment is reduced to an empty one, but isn’t the singleton used in that class. (This is also partly why I proposed #567: once a style is separated from a segment, one can use an empty segment as a singleton because its style isn’t a part of that segment.). That’s not difficult to fix, but I won’t be able to get to it until tomorrow.

0reactions
JordanMartinezcommented, Sep 7, 2017

Closed by #578

Read more comments on GitHub >

github_iconTop Results From Across the Web

NullPointerException when trying to copy/paste from/into ...
After Restart, I can try to copy anything anywhere, even use Java Toolkit.getDefaultToolkit().getSystemClipboard() function with no error, but ...
Read more >
Copy data as text to clipboard NPE - workbench - Codeberg.org
2020-12-10 10:13:36 ERROR Could not copy text data to clipboard java.lang.NullPointerException java.lang.NullPointerException at workbench.db.exporter.
Read more >
mlopatkin / android-log-viewer / issues / #18 - NPE when copy line ...
Open brief logfile. Try to copy line from it. Expected result: line should be copied into clipboard. Actual result: NPE occurs and line...
Read more >
480150 – NPE in ClipboardProxy.getFunc or JVM Crash on ...
Created attachment 257361 [details] BreakClipboard.java I'm experiencing either a JVM crash or a NPE inside Clipboard proxy when using SWTBot for copy and ......
Read more >
#13646 (NPE at LayerPositionStrategy when inserting a node from ...
copy node fom a layer to clipboard; switch to OSM-Layer; Insert from Clipboard to layer ... NullPointerException at org.openstreetmap.josm.gui.layer.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found