Index: trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialog.java	(revision 9601)
+++ trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialog.java	(revision 9602)
@@ -34,29 +34,49 @@
  * This is non-modal dialog, always showing on top, which displays history information
  * about a given {@link org.openstreetmap.josm.data.osm.OsmPrimitive}.
- *
+ * @since 1709
  */
 public class HistoryBrowserDialog extends JDialog implements HistoryDataSetListener {
 
     /** the embedded browser */
-    private HistoryBrowser browser;
-    private CloseAction closeAction;
-    private JLabel titleLabel;
-
-    /**
-     * displays the title for this dialog
+    private final HistoryBrowser browser = new HistoryBrowser();
+    private final CloseAction closeAction = new CloseAction();
+    private final JLabel titleLabel = new JLabel("", JLabel.CENTER);
+
+    /**
+     * Constructs a new {@code HistoryBrowserDialog}.
+     *
+     * @param history the history to be displayed
+     */
+    public HistoryBrowserDialog(History history) {
+        super(JOptionPane.getFrameForComponent(Main.parent), false);
+        build();
+        setHistory(history);
+        setTitle(buildTitle(history));
+        pack();
+        if (getInsets().top > 0) {
+            titleLabel.setVisible(false);
+        }
+        HistoryDataSet.getInstance().addHistoryDataSetListener(this);
+        addWindowListener(new WindowClosingAdapter());
+    }
+
+    /**
+     * Constructs the title for this dialog
      *
      * @param h the current history
-     */
-    protected void renderTitle(History h) {
-        String title = "";
-        switch(h.getEarliest().getType()) {
-        case NODE:  title = marktr("History for node {0}"); break;
-        case WAY: title = marktr("History for way {0}"); break;
-        case RELATION:  title = marktr("History for relation {0}"); break;
-        }
-        setTitle(tr(
-                title,
-                Long.toString(h.getId())
-        ));
+     * @return the title for this dialog
+     */
+    static String buildTitle(History h) {
+        String title;
+        switch (h.getEarliest().getType()) {
+        case NODE: title = marktr("History for node {0}");
+            break;
+        case WAY: title = marktr("History for way {0}");
+            break;
+        case RELATION: title = marktr("History for relation {0}");
+            break;
+        default: title = "";
+        }
+        return tr(title, Long.toString(h.getId()));
     }
 
@@ -75,9 +95,6 @@
         setLayout(new BorderLayout());
 
-        titleLabel = new JLabel();
-        titleLabel.setHorizontalAlignment(JLabel.CENTER);
         add(titleLabel, BorderLayout.NORTH);
 
-        browser = new HistoryBrowser();
         add(browser, BorderLayout.CENTER);
 
@@ -88,5 +105,5 @@
         pnl.add(btn);
 
-        btn = new SideButton(closeAction = new CloseAction());
+        btn = new SideButton(closeAction);
         final String closeHistoryBrowserDialogKey = "CloseHistoryBrowserDialog";
         KeyStroke escapeKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
@@ -105,22 +122,4 @@
 
     /**
-     * Constructs a new {@code HistoryBrowserDialog}.
-     *
-     * @param history the history to be displayed
-     */
-    public HistoryBrowserDialog(History history) {
-        super(JOptionPane.getFrameForComponent(Main.parent), false);
-        build();
-        setHistory(history);
-        renderTitle(history);
-        pack();
-        if (getInsets().top > 0) {
-            titleLabel.setVisible(false);
-        }
-        HistoryDataSet.getInstance().addHistoryDataSetListener(this);
-        addWindowListener(new WindowClosingAdapter());
-    }
-
-    /**
      * Sets the current history.
      * @param history current history
@@ -140,8 +139,12 @@
     /* interface HistoryDataSetListener                                                   */
     /* ---------------------------------------------------------------------------------- */
+
     @Override
     public void historyUpdated(HistoryDataSet source, PrimitiveId primitiveId) {
         if (primitiveId == null || primitiveId.equals(browser.getHistory().getPrimitiveId())) {
-            browser.populate(source.getHistory(browser.getHistory().getPrimitiveId()));
+            History history = source.getHistory(browser.getHistory().getPrimitiveId());
+            if (history != null) {
+                browser.populate(history);
+            }
         }
     }
Index: trunk/test/unit/org/openstreetmap/josm/gui/history/HistoryBrowserDialogTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/history/HistoryBrowserDialogTest.java	(revision 9602)
+++ trunk/test/unit/org/openstreetmap/josm/gui/history/HistoryBrowserDialogTest.java	(revision 9602)
@@ -0,0 +1,37 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.history;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Date;
+
+import org.junit.Test;
+import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
+import org.openstreetmap.josm.data.osm.User;
+import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
+import org.openstreetmap.josm.data.osm.history.HistoryNode;
+import org.openstreetmap.josm.data.osm.history.HistoryRelation;
+import org.openstreetmap.josm.data.osm.history.HistoryWay;
+import org.openstreetmap.josm.tools.date.DateUtils;
+
+/**
+ * Unit tests of {@link HistoryBrowserDialog} class.
+ */
+public class HistoryBrowserDialogTest {
+
+    /**
+     * Test for {@link HistoryBrowserDialog#buildTitle}.
+     */
+    @Test
+    public void testBuildTitle() {
+        HistoryDataSet hds = new HistoryDataSet();
+        User user = User.createOsmUser(1, "");
+        Date date = DateUtils.fromString("2016-01-01");
+        hds.put(new HistoryNode(1, 1, true, user, 1, date, null));
+        assertEquals("History for node 1", HistoryBrowserDialog.buildTitle(hds.getHistory(1, OsmPrimitiveType.NODE)));
+        hds.put(new HistoryWay(1, 1, true, user, 1, date));
+        assertEquals("History for way 1", HistoryBrowserDialog.buildTitle(hds.getHistory(1, OsmPrimitiveType.WAY)));
+        hds.put(new HistoryRelation(1, 1, true, user, 1, date));
+        assertEquals("History for relation 1", HistoryBrowserDialog.buildTitle(hds.getHistory(1, OsmPrimitiveType.RELATION)));
+    }
+}
