Changeset 19660 in josm


Ignore:
Timestamp:
2026-10-23T23:18:23+02:00 (5 hours ago)
Author:
stoecker
Message:

fix #24969 - patch by DanProgs - fix sonar issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/oauth/TestAccessTokenTask.java

    r19651 r19660  
    77import java.io.IOException;
    88import java.net.HttpURLConnection;
     9import java.net.URI;
    910import java.net.URL;
    1011
    … …  
    8687        boolean authenticatorEnabled = true;
    8788        try {
    88             URL url = new URL(apiUrl + "/0.6/user/details");
     89            final URL url = URI.create(apiUrl + "/0.6/user/details").toURL();
    8990            authenticatorEnabled = DefaultAuthenticator.getInstance().isEnabled();
    9091            DefaultAuthenticator.getInstance().setEnabled(false);
    … …  
    9899
    99100            final String oauthKey = getAuthKey();
    100             if (connection.getResponse().getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED)
     101            if (connection.getResponse().getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
    101102                throw new OsmApiException(HttpURLConnection.HTTP_UNAUTHORIZED,
    102103                        tr("Retrieving user details with Access Token Key ''{0}'' was rejected.",
    103104                                oauthKey), null);
    104 
    105             if (connection.getResponse().getResponseCode() == HttpURLConnection.HTTP_FORBIDDEN)
     105            }
     106
     107            if (connection.getResponse().getResponseCode() == HttpURLConnection.HTTP_FORBIDDEN) {
    106108                throw new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN,
    107109                        tr("Retrieving user details with Access Token Key ''{0}'' was forbidden.", oauthKey), null);
    108 
    109             if (connection.getResponse().getResponseCode() != HttpURLConnection.HTTP_OK)
     110            }
     111
     112            if (connection.getResponse().getResponseCode() != HttpURLConnection.HTTP_OK) {
    110113                throw new OsmApiException(connection.getResponse().getResponseCode(),
    111114                        connection.getResponse().getHeaderField("Error"), null);
    112             Document d = XmlUtils.parseSafeDOM(connection.getResponse().getContent());
     115            }
     116            final Document d = XmlUtils.parseSafeDOM(connection.getResponse().getContent());
    113117            return OsmServerUserInfoReader.buildFromXML(d);
    114118        } catch (SAXException | ParserConfigurationException e) {
    … …  
    234238        try {
    235239            getProgressMonitor().indeterminateSubTask(tr("Retrieving user info..."));
    236             UserInfo userInfo = getUserDetails();
    237             if (canceled) return;
     240            final UserInfo userInfo = getUserDetails();
     241            if (canceled) {
     242                return;
     243            }
    238244            notifySuccess(userInfo);
    239245        } catch (OsmOAuthAuthorizationException e) {
    240             if (canceled) return;
     246            if (canceled) {
     247                return;
     248            }
    241249            Logging.error(e);
    242250            alertFailedSigning();
    243251        } catch (OsmApiException e) {
    244             if (canceled) return;
     252            if (canceled) {
     253                return;
     254            }
    245255            Logging.error(e);
    246256            if (e.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) {
    … …  
    256266            alertFailedConnection();
    257267        } catch (OsmTransferException e) {
    258             if (canceled) return;
     268            if (canceled) {
     269                return;
     270            }
    259271            Logging.error(e);
    260272            alertFailedConnection();
Note: See TracChangeset for help on using the changeset viewer.