Index: trunk/src/oauth/signpost/AbstractOAuthProvider.java
===================================================================
--- trunk/src/oauth/signpost/AbstractOAuthProvider.java	(revision 9226)
+++ trunk/src/oauth/signpost/AbstractOAuthProvider.java	(revision 9227)
@@ -12,4 +12,5 @@
 
 import java.io.BufferedReader;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.HashMap;
@@ -28,5 +29,5 @@
  * you will probably inherit from this class, since it takes a lot of work from
  * you.
- * 
+ *
  * @author Matthias Kaeppler
  */
@@ -128,5 +129,5 @@
      * </ul>
      * </p>
-     * 
+     *
      * @param consumer
      *        the {@link OAuthConsumer} that should be used to sign the request
@@ -168,5 +169,5 @@
                 consumer.setAdditionalParameters(customOAuthParams);
             }
-            
+
             if (this.listener != null) {
                 this.listener.prepareRequest(request);
@@ -174,5 +175,5 @@
 
             consumer.sign(request);
-            
+
             if (this.listener != null) {
                 this.listener.prepareSubmission(request);
@@ -230,11 +231,14 @@
             return;
         }
-        BufferedReader reader = new BufferedReader(new InputStreamReader(response.getContent()));
         StringBuilder responseBody = new StringBuilder();
-
-        String line = reader.readLine();
-        while (line != null) {
-            responseBody.append(line);
-            line = reader.readLine();
+        InputStream content = response.getContent();
+        if (content != null) {
+            BufferedReader reader = new BufferedReader(new InputStreamReader(content));
+
+            String line = reader.readLine();
+            while (line != null) {
+                responseBody.append(line);
+                line = reader.readLine();
+            }
         }
 
@@ -251,5 +255,5 @@
      * Overrride this method if you want to customize the logic for building a
      * request object for the given endpoint URL.
-     * 
+     *
      * @param endpointUrl
      *        the URL to which the request will go
@@ -263,5 +267,5 @@
      * Override this method if you want to customize the logic for how the given
      * request is sent to the server.
-     * 
+     *
      * @param request
      *        the request to send
@@ -275,5 +279,5 @@
      * Called when the connection is being finalized after receiving the
      * response. Use this to do any cleanup / resource freeing.
-     * 
+     *
      * @param request
      *        the request that has been sent
@@ -295,5 +299,5 @@
      * token reply. You must call {@link #setResponseParameters} with the set of
      * parameters before using this method.
-     * 
+     *
      * @param key
      *        the parameter name
Index: trunk/src/org/openstreetmap/josm/gui/oauth/OsmLoginFailedException.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/OsmLoginFailedException.java	(revision 9226)
+++ trunk/src/org/openstreetmap/josm/gui/oauth/OsmLoginFailedException.java	(revision 9227)
@@ -2,20 +2,16 @@
 package org.openstreetmap.josm.gui.oauth;
 
+/**
+ * OSM login failure exception.
+ * @since 2746
+ */
 public class OsmLoginFailedException extends OsmOAuthAuthorizationException {
 
-    public OsmLoginFailedException() {
-        super();
-    }
-
-    public OsmLoginFailedException(String arg0, Throwable arg1) {
-        super(arg0, arg1);
-    }
-
-    public OsmLoginFailedException(String arg0) {
-        super(arg0);
-    }
-
-    public OsmLoginFailedException(Throwable arg0) {
-        super(arg0);
+    /**
+     * Constructs a new {@code OsmLoginFailedException} with the specified cause.
+     * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method).
+     */
+    public OsmLoginFailedException(Throwable cause) {
+        super(cause);
     }
 }
Index: trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java	(revision 9226)
+++ trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java	(revision 9227)
@@ -50,14 +50,4 @@
         private String token;
         private String userName;
-    }
-
-    /**
-     * Creates a new authorisation client with default OAuth parameters
-     *
-     */
-    public OsmOAuthAuthorizationClient() {
-        oauthProviderParameters = OAuthParameters.createDefault(Main.pref.get("osm-server.url"));
-        consumer = oauthProviderParameters.buildConsumer();
-        provider = oauthProviderParameters.buildProvider(consumer);
     }
 
@@ -241,5 +231,5 @@
     }
 
-    protected String buildPostRequest(Map<String, String> parameters) throws OsmOAuthAuthorizationException {
+    protected static String buildPostRequest(Map<String, String> parameters) {
         StringBuilder sb = new StringBuilder(32);
 
@@ -322,4 +312,6 @@
      * Submits a request to the OSM website for a OAuth form. The OSM website replies a session token in
      * a hidden parameter.
+     * @param sessionId session id
+     * @param requestToken request token
      *
      * @throws OsmOAuthAuthorizationException if something went wrong
Index: trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationException.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationException.java	(revision 9226)
+++ trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationException.java	(revision 9227)
@@ -2,20 +2,24 @@
 package org.openstreetmap.josm.gui.oauth;
 
+/**
+ * OSM OAuth authorization exception.
+ * @since 2746
+ */
 public class OsmOAuthAuthorizationException extends Exception {
 
-    public OsmOAuthAuthorizationException() {
-        super();
+    /**
+     * Constructs a new {@code OsmLoginFailedException} with the specified detail message.
+     * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
+     */
+    public OsmOAuthAuthorizationException(String message) {
+        super(message);
     }
 
-    public OsmOAuthAuthorizationException(String arg0, Throwable arg1) {
-        super(arg0, arg1);
-    }
-
-    public OsmOAuthAuthorizationException(String arg0) {
-        super(arg0);
-    }
-
-    public OsmOAuthAuthorizationException(Throwable arg0) {
-        super(arg0);
+    /**
+     * Constructs a new {@code OsmLoginFailedException} with the specified cause.
+     * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method).
+     */
+    public OsmOAuthAuthorizationException(Throwable cause) {
+        super(cause);
     }
 }
Index: trunk/src/org/openstreetmap/josm/io/ProgressInputStream.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/ProgressInputStream.java	(revision 9226)
+++ trunk/src/org/openstreetmap/josm/io/ProgressInputStream.java	(revision 9227)
@@ -10,4 +10,5 @@
 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
+import org.openstreetmap.josm.tools.CheckParameterUtil;
 
 /**
@@ -23,5 +24,5 @@
      * Constructs a new {@code ProgressInputStream}.
      *
-     * @param in the stream to monitor
+     * @param in the stream to monitor. Must not be null
      * @param size the total size which will be sent
      * @param progressMonitor the monitor to report to
@@ -29,4 +30,5 @@
      */
     public ProgressInputStream(InputStream in, long size, ProgressMonitor progressMonitor) {
+        CheckParameterUtil.ensureParameterNotNull(in, "in");
         if (progressMonitor == null) {
             progressMonitor = NullProgressMonitor.INSTANCE;
@@ -43,4 +45,5 @@
      * @param con the connection to monitor
      * @param progressMonitor the monitor to report to
+     * @throws OsmTransferException if any I/O error occurs
      */
     public ProgressInputStream(URLConnection con, ProgressMonitor progressMonitor) throws OsmTransferException {
Index: trunk/src/org/openstreetmap/josm/tools/HttpClient.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 9226)
+++ trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 9227)
@@ -231,4 +231,5 @@
          * @see HttpURLConnection#getErrorStream()
          */
+        @SuppressWarnings("resource")
         public InputStream getContent() throws IOException {
             InputStream in;
@@ -238,21 +239,23 @@
                 in = connection.getErrorStream();
             }
-            in = new ProgressInputStream(in, getContentLength(), monitor);
-            in = "gzip".equalsIgnoreCase(getContentEncoding()) ? new GZIPInputStream(in) : in;
-            Compression compression = Compression.NONE;
-            if (uncompress) {
-                final String contentType = getContentType();
-                Main.debug("Uncompressing input stream according to Content-Type header: {0}", contentType);
-                compression = Compression.forContentType(contentType);
-            }
-            if (uncompressAccordingToContentDisposition && Compression.NONE.equals(compression)) {
-                final String contentDisposition = getHeaderField("Content-Disposition");
-                final Matcher matcher = Pattern.compile("filename=\"([^\"]+)\"").matcher(contentDisposition);
-                if (matcher.find()) {
-                    Main.debug("Uncompressing input stream according to Content-Disposition header: {0}", contentDisposition);
-                    compression = Compression.byExtension(matcher.group(1));
+            if (in != null) {
+                in = new ProgressInputStream(in, getContentLength(), monitor);
+                in = "gzip".equalsIgnoreCase(getContentEncoding()) ? new GZIPInputStream(in) : in;
+                Compression compression = Compression.NONE;
+                if (uncompress) {
+                    final String contentType = getContentType();
+                    Main.debug("Uncompressing input stream according to Content-Type header: {0}", contentType);
+                    compression = Compression.forContentType(contentType);
                 }
-            }
-            in = compression.getUncompressedInputStream(in);
+                if (uncompressAccordingToContentDisposition && Compression.NONE.equals(compression)) {
+                    final String contentDisposition = getHeaderField("Content-Disposition");
+                    final Matcher matcher = Pattern.compile("filename=\"([^\"]+)\"").matcher(contentDisposition);
+                    if (matcher.find()) {
+                        Main.debug("Uncompressing input stream according to Content-Disposition header: {0}", contentDisposition);
+                        compression = Compression.byExtension(matcher.group(1));
+                    }
+                }
+                in = compression.getUncompressedInputStream(in);
+            }
             return in;
         }
Index: trunk/test/unit/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClientTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClientTest.java	(revision 9227)
+++ trunk/test/unit/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClientTest.java	(revision 9227)
@@ -0,0 +1,46 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.oauth;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.data.oauth.OAuthParameters;
+import org.openstreetmap.josm.data.oauth.OAuthToken;
+import org.openstreetmap.josm.io.OsmTransferCanceledException;
+
+/**
+ * Unit tests of {@link OsmOAuthAuthorizationClient} class.
+ */
+public class OsmOAuthAuthorizationClientTest {
+
+    /**
+     * Setup tests
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        JOSMFixture.createUnitTestFixture().init();
+    }
+
+    /**
+     * Unit test of {@link OsmOAuthAuthorizationClient}.
+     * @throws OsmOAuthAuthorizationException if OAuth authorization error occurs
+     * @throws OsmTransferCanceledException  if OSM transfer error occurs
+     * @throws MalformedURLException in case of invalid URL
+     */
+    @Test
+    public void testOsmOAuthAuthorizationClient() throws OsmTransferCanceledException, OsmOAuthAuthorizationException, MalformedURLException {
+        OsmOAuthAuthorizationClient client = new OsmOAuthAuthorizationClient(OAuthParameters.createDefault());
+        OAuthToken requestToken = client.getRequestToken(null);
+        assertNotNull(requestToken);
+        String url = client.getAuthoriseUrl(requestToken);
+        assertNotNull(url);
+        System.out.println(new URL(url));
+        //OAuthToken accessToken = client.getAccessToken(null);
+        //assertNotNull(accessToken);
+    }
+}
