Changeset 18665 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2023-02-16T16:01:49+01:00 (23 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmConnection.java
r18651 r18665 11 11 import java.util.Base64; 12 12 import java.util.Objects; 13 import java.util.Optional; 13 14 import java.util.concurrent.CountDownLatch; 14 15 import java.util.concurrent.TimeUnit; … … 215 216 } 216 217 CountDownLatch done = new CountDownLatch(1); 217 Consumer< IOAuthToken> consumer = authToken -> {218 Consumer<Optional<IOAuthToken>> consumer = authToken -> { 218 219 if (!remoteControlIsRunning) { 219 220 RemoteControl.stop(); … … 221 222 // Clean up old token/password 222 223 OAuthAccessTokenHolder.getInstance().setAccessToken(null); 223 OAuthAccessTokenHolder.getInstance().setAccessToken(OsmApi.getOsmApi().getServerUrl(), authToken );224 OAuthAccessTokenHolder.getInstance().setAccessToken(OsmApi.getOsmApi().getServerUrl(), authToken.orElse(null)); 224 225 OAuthAccessTokenHolder.getInstance().save(CredentialsManager.getInstance()); 225 226 done.countDown(); … … 229 230 OsmScopes.read_prefs, OsmScopes.write_prefs, 230 231 OsmScopes.write_api, OsmScopes.write_notes); 231 synchronized (done) { 232 // Only wait at most 5 minutes 233 int counter = 0; 234 while (done.getCount() >= 0 && counter < 5) { 235 try { 236 if (done.await(1, TimeUnit.MINUTES)) { 237 break; 238 } 239 } catch (InterruptedException e) { 240 Thread.currentThread().interrupt(); 241 Logging.trace(e); 242 consumer.accept(null); 243 throw new MissingOAuthAccessTokenException(e); 232 // Only wait at most 5 minutes 233 int counter = 0; 234 while (done.getCount() >= 0 && counter < 5) { 235 try { 236 if (done.await(1, TimeUnit.MINUTES)) { 237 break; 244 238 } 245 counter++; 246 } 239 } catch (InterruptedException e) { 240 Thread.currentThread().interrupt(); 241 Logging.trace(e); 242 consumer.accept(null); 243 throw new MissingOAuthAccessTokenException(e); 244 } 245 counter++; 247 246 } 248 247 }
Note:
See TracChangeset
for help on using the changeset viewer.