Index: trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java	(revision 8426)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java	(revision 8429)
@@ -468,6 +468,6 @@
             // select combobox with saving unix system selection (middle mouse paste)
             Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection();
-            if(sysSel != null) {
-                Transferable old = sysSel.getContents(null);
+            if (sysSel != null) {
+                Transferable old = Utils.getTransferableContent(sysSel);
                 cb.requestFocusInWindow();
                 cb.getEditor().selectAll();
Index: trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java	(revision 8426)
+++ trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java	(revision 8429)
@@ -26,4 +26,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.gui.widgets.JosmComboBox;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -134,6 +135,6 @@
             // save unix system selection (middle mouse paste)
             Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection();
-            if(sysSel != null) {
-                Transferable old = sysSel.getContents(null);
+            if (sysSel != null) {
+                Transferable old = Utils.getTransferableContent(sysSel);
                 editorComponent.select(start, end);
                 sysSel.setContents(old, null);
@@ -198,6 +199,6 @@
                         // save unix system selection (middle mouse paste)
                         Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection();
-                        if(sysSel != null) {
-                            Transferable old = sysSel.getContents(null);
+                        if (sysSel != null) {
+                            Transferable old = Utils.getTransferableContent(sysSel);
                             editorComponent.selectAll();
                             sysSel.setContents(old, null);
Index: trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 8426)
+++ trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 8429)
@@ -499,7 +499,7 @@
         try {
             Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(s), new ClipboardOwner() {
-
                 @Override
                 public void lostOwnership(Clipboard clpbrd, Transferable t) {
+                    // Do nothing
                 }
             });
@@ -512,9 +512,10 @@
 
     /**
-     * Extracts clipboard content as string.
-     * @return string clipboard contents if available, {@code null} otherwise.
-     */
-    public static String getClipboardContent() {
-        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+     * Extracts clipboard content as {@code Transferable} object.
+     * @param clipboard clipboard from which contents are retrieved
+     * @return clipboard contents if available, {@code null} otherwise.
+     * @since 8429
+     */
+    public static Transferable getTransferableContent(Clipboard clipboard) {
         Transferable t = null;
         for (int tries = 0; t == null && tries < 10; tries++) {
@@ -522,5 +523,6 @@
                 t = clipboard.getContents(null);
             } catch (IllegalStateException e) {
-                // Clipboard currently unavailable. On some platforms, the system clipboard is unavailable while it is accessed by another application.
+                // Clipboard currently unavailable.
+                // On some platforms, the system clipboard is unavailable while it is accessed by another application.
                 try {
                     Thread.sleep(1);
@@ -528,6 +530,18 @@
                     Main.warn("InterruptedException in "+Utils.class.getSimpleName()+" while getting clipboard content");
                 }
-            }
-        }
+            } catch (NullPointerException e) {
+                // JDK-6322854: On Linux/X11, NPE can happen for unknown reasons, on all versions of Java
+                Main.error(e);
+            }
+        }
+        return t;
+    }
+
+    /**
+     * Extracts clipboard content as string.
+     * @return string clipboard contents if available, {@code null} otherwise.
+     */
+    public static String getClipboardContent() {
+        Transferable t = getTransferableContent(Toolkit.getDefaultToolkit().getSystemClipboard());
         try {
             if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
@@ -547,5 +561,4 @@
      */
     public static String md5Hex(String data) {
-        byte[] byteData = data.getBytes(StandardCharsets.UTF_8);
         MessageDigest md = null;
         try {
@@ -554,4 +567,5 @@
             throw new RuntimeException(e);
         }
+        byte[] byteData = data.getBytes(StandardCharsets.UTF_8);
         byte[] byteDigest = md.digest(byteData);
         return toHexString(byteDigest);
