Index: eclipse/JOSM (Java 8).launch
===================================================================
--- eclipse/JOSM (Java 8).launch	(revision 15755)
+++ eclipse/JOSM (Java 8).launch	(working copy)
@@ -12,5 +12,5 @@
 <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.openstreetmap.josm.gui.MainApplication"/>
 <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="--debug"/>
 <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="JOSM"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Xverify:none"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Xverify:none -Xmx2G"/>
 </launchConfiguration>
Index: src/org/openstreetmap/josm/io/auth/CredentialsManager.java
===================================================================
--- src/org/openstreetmap/josm/io/auth/CredentialsManager.java	(revision 15755)
+++ src/org/openstreetmap/josm/io/auth/CredentialsManager.java	(working copy)
@@ -131,6 +131,7 @@
                 UserIdentityManager.getInstance().setPartiallyIdentified(username);
             }
         }
+        purgeCredentialsCache(requestorType); // see #11914
         delegate.store(requestorType, host, credentials);
     }
 
@@ -137,7 +138,19 @@
     @Override
     public CredentialsAgentResponse getCredentials(RequestorType requestorType, String host, boolean noSuccessWithLastResponse)
             throws CredentialsAgentException {
-        return delegate.getCredentials(requestorType, host, noSuccessWithLastResponse);
+        CredentialsAgentResponse credentials = delegate.getCredentials(requestorType, host, noSuccessWithLastResponse);
+        if (requestorType == RequestorType.SERVER) {
+            // see #11914
+            String userName = credentials.getUsername();
+            userName = userName == null ? "" : userName.trim();
+            if (!Objects.equals(UserIdentityManager.getInstance().getUserName(), userName)) {
+                if (userName.isEmpty())
+                    UserIdentityManager.getInstance().setAnonymous();
+                else
+                    UserIdentityManager.getInstance().setPartiallyIdentified(userName);
+            }
+        }
+        return credentials;
     }
 
     @Override
