Index: /trunk/src/org/openstreetmap/josm/tools/Base64.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Base64.java	(revision 7059)
+++ /trunk/src/org/openstreetmap/josm/tools/Base64.java	(revision 7060)
@@ -4,5 +4,13 @@
 import java.nio.ByteBuffer;
 
+/**
+ * This class implements an encoder for encoding byte and character data using the
+ * <a href="https://en.wikipedia.org/wiki/Base64">Base64</a> encoding scheme as specified in
+ * <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a> ("base64", default) and
+ * <a href="http://tools.ietf.org/html/rfc4648#section-4">RFC 4648</a> ("base64url").
+ * @since 195
+ */
 public final class Base64 {
+    // TODO: Remove this class when switching to Java 8 (finally integrated in Java SE as java.util.Base64.Encoder)
 
     private Base64() {
@@ -10,11 +18,25 @@
     }
     
+    /** "base64": RFC 2045 default encoding */
     private static String encDefault = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+    /** "base64url": RFC 4648 url-safe encoding */
     private static String encUrlSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
 
+    /**
+     * Encodes all characters from the specified string into a new String using the Base64 default encoding scheme.
+     * @param s the string to encode
+     * @return A new string containing the resulting encoded characters.
+     */
     public static String encode(String s) {
         return encode(s, false);
     }
 
+    /**
+     * Encodes all characters from the specified string into a new String using a supported Base64 encoding scheme.
+     * @param s the string to encode
+     * @param urlsafe if {@code true}, uses "base64url" encoding, otherwise use the "base64" default encoding
+     * @return A new string containing the resulting encoded characters.
+     * @since 3840
+     */
     public static String encode(String s, boolean urlsafe) {
         StringBuilder out = new StringBuilder();
@@ -35,8 +57,22 @@
     }
 
+    /**
+     * Encodes all remaining bytes from the specified byte buffer into a new string using the Base64 default encoding scheme.
+     * Upon return, the source buffer's position will be updated to its limit; its limit will not have been changed.
+     * @param s the source ByteBuffer to encode
+     * @return A new string containing the resulting encoded characters.
+     */
     public static String encode(ByteBuffer s) {
         return encode(s, false);
     }
 
+    /**
+     * Encodes all remaining bytes from the specified byte buffer into a new string using a supported Base64 encoding scheme.
+     * Upon return, the source buffer's position will be updated to its limit; its limit will not have been changed.
+     * @param s the source ByteBuffer to encode
+     * @param urlsafe if {@code true}, uses "base64url" encoding, otherwise use the "base64" default encoding
+     * @return A new string containing the resulting encoded characters.
+     * @since 3840
+     */
     public static String encode(ByteBuffer s, boolean urlsafe) {
         StringBuilder out = new StringBuilder();
Index: /trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java	(revision 7059)
+++ /trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java	(revision 7060)
@@ -216,4 +216,5 @@
         ) {
             gzip.write(debugText.getBytes(Utils.UTF_8));
+            gzip.finish();
 
             return new URL(Main.getJOSMWebsite()+"/josmticket?" +
Index: /trunk/test/unit/org/openstreetmap/josm/tools/BugReportExceptionHandlerTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/tools/BugReportExceptionHandlerTest.java	(revision 7060)
+++ /trunk/test/unit/org/openstreetmap/josm/tools/BugReportExceptionHandlerTest.java	(revision 7060)
@@ -0,0 +1,56 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.tools;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.zip.GZIPInputStream;
+
+import javax.xml.bind.DatatypeConverter;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.ShowStatusReportAction;
+
+/**
+ * Bug report unit tests.
+ */
+public class BugReportExceptionHandlerTest {
+
+    /**
+     * Setup tests.
+     */
+    @Before
+    public void setUp() {
+        Main.commandLineArgs = new String[0];
+        Main.determinePlatformHook();
+        Main.initApplicationPreferences();
+    }
+
+    /**
+     * Test method for {@link org.openstreetmap.josm.tools.BugReportExceptionHandler#getBugReportUrl(java.lang.String)}.
+     * @throws IOException 
+     */
+    @Test
+    public void testGetBugReportUrl() throws IOException {
+        String report = ShowStatusReportAction.getReportHeader();
+        String url = BugReportExceptionHandler.getBugReportUrl(report).toExternalForm();
+        String prefix = Main.getJOSMWebsite()+"/josmticket?gdata=";
+        assertTrue(url.startsWith(prefix));
+        
+        String gdata = url.substring(prefix.length());
+        // JAXB only provides support for "base64" decoding while we encode url in "base64url", so switch encoding, only for test purpose
+        byte[] data = DatatypeConverter.parseBase64Binary(gdata.replace('-', '+').replace('_', '/'));
+        byte[] buff = new byte[8192];
+        try (GZIPInputStream is = new GZIPInputStream(new ByteArrayInputStream(data))) {
+            StringBuilder sb = new StringBuilder();
+            for (int n = is.read(buff); n > 0; n = is.read(buff)) {
+                sb.append(new String(buff, 0, n, Utils.UTF_8));
+            }
+            assertEquals(report, sb.toString());
+        }
+    }
+}
