提交 fdda9ca6 编写于 作者: J Jesse Glick

[FIXED JENKINS-16332] Ensure that User records are saved when the fullName is...

[FIXED JENKINS-16332] Ensure that User records are saved when the fullName is not recoverable from the id.
Otherwise User.get(id).getFullName() after restarting Jenkins will produce the wrong result.
上级 3ec7e562
......@@ -62,6 +62,9 @@ Upcoming changes</a>
<li class=bug>
Random class loading error mostly known to affect static analysis plugins.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-12124">issue 12124</a>)
<li class=bug>
After restarting Jenkins, users known only from changelogs could be shown as <code>First Last _first.last@some.org_</code>, breaking mail delivery.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16332">issue 16332</a>)
<li class=bug>
CLI <code>build -s -v</code> command caused 100% CPU usage on the master.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20965">issue 20965</a>)
......
......@@ -350,9 +350,13 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
if (LOGGER.isLoggable(Level.FINE) && !fullName.equals(prev.getFullName())) {
LOGGER.log(Level.FINE, "mismatch on fullName (‘" + fullName + "’ vs. ‘" + prev.getFullName() + "’) for ‘" + id + "’", new Throwable());
}
}
if (LOGGER.isLoggable(Level.FINE) && id.equals(fullName) && fullName.matches(".+ _\\S+@\\S+_")) {
LOGGER.log(Level.FINE, "[JENKINS-16332] Suspicious fullName being stored: " + fullName, new Throwable());
} else if (!id.equals(fullName) && !getConfigFileFor(id).exists()) {
// JENKINS-16332: since the fullName may not be recoverable from the id, and various code may store the id only, we must save the fullName
try {
u.save();
} catch (IOException x) {
LOGGER.log(Level.WARNING, null, x);
}
}
}
return u;
......
......@@ -32,6 +32,7 @@ import hudson.security.AccessDeniedException2;
import hudson.security.GlobalMatrixAuthorizationStrategy;
import hudson.security.HudsonPrivateSecurityRealm;
import hudson.security.Permission;
import hudson.tasks.MailAddressResolver;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Collections;
......@@ -266,6 +267,16 @@ public class UserTest {
assertNotNull("User should be saved with all changes.", user.getProperty(SomeUserProperty.class));
}
@Bug(16332)
@Test public void unrecoverableFullName() throws Throwable {
User u = User.get("John Smith <jsmith@nowhere.net>");
assertEquals("jsmith@nowhere.net", MailAddressResolver.resolve(u));
String id = u.getId();
User.clear(); // simulate Jenkins restart
u = User.get(id);
assertEquals("jsmith@nowhere.net", MailAddressResolver.resolve(u));
}
@Test
public void testDelete() throws IOException {
User user = User.get("John Smith", true, Collections.emptyMap());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册