11package hudson .plugins .git ;
22
33import hudson .MarkupText ;
4+ import hudson .Plugin ;
45import hudson .model .User ;
56import hudson .plugins .git .GitSCM .DescriptorImpl ;
67import hudson .scm .ChangeLogAnnotator ;
1819import java .text .ParseException ;
1920import java .text .SimpleDateFormat ;
2021import java .util .Collection ;
22+ import java .util .Collections ;
2123import java .util .Date ;
2224import java .util .HashSet ;
2325import java .util .List ;
@@ -411,13 +413,13 @@ public User findOrCreateUser(String csAuthor, String csAuthorEmail, boolean crea
411413 // Avoid exception from User.get("", false)
412414 return User .getUnknown ();
413415 }
414- user = User .get (csAuthorEmail , false );
416+ user = User .get (csAuthorEmail , false , Collections . emptyMap () );
415417
416418 if (user == null ) {
417419 try {
418- user = User .get (csAuthorEmail , !useExistingAccountWithSameEmail );
420+ user = User .get (csAuthorEmail , !useExistingAccountWithSameEmail , Collections . emptyMap () );
419421 boolean setUserDetails = true ;
420- if (user == null && useExistingAccountWithSameEmail && hasHudsonTasksMailer ()) {
422+ if (user == null && useExistingAccountWithSameEmail && hasMailerPlugin ()) {
421423 for (User existingUser : User .getAll ()) {
422424 if (csAuthorEmail .equalsIgnoreCase (getMail (existingUser ))) {
423425 user = existingUser ;
@@ -427,11 +429,11 @@ public User findOrCreateUser(String csAuthor, String csAuthorEmail, boolean crea
427429 }
428430 }
429431 if (user == null ) {
430- user = User .get (csAuthorEmail , true );
432+ user = User .get (csAuthorEmail , true , Collections . emptyMap () );
431433 }
432434 if (setUserDetails ) {
433435 user .setFullName (csAuthor );
434- if (hasHudsonTasksMailer ())
436+ if (hasMailerPlugin ())
435437 setMail (user , csAuthorEmail );
436438 user .save ();
437439 }
@@ -444,7 +446,7 @@ public User findOrCreateUser(String csAuthor, String csAuthorEmail, boolean crea
444446 // Avoid exception from User.get("", false)
445447 return User .getUnknown ();
446448 }
447- user = User .get (csAuthor , false );
449+ user = User .get (csAuthor , false , Collections . emptyMap () );
448450
449451 if (user == null ) {
450452 if (csAuthorEmail == null || csAuthorEmail .isEmpty ()) {
@@ -454,14 +456,14 @@ public User findOrCreateUser(String csAuthor, String csAuthorEmail, boolean crea
454456 // don't mess us up.
455457 String [] emailParts = csAuthorEmail .split ("@" );
456458 if (emailParts .length > 0 ) {
457- user = User .get (emailParts [0 ], true );
459+ user = User .get (emailParts [0 ], true , Collections . emptyMap () );
458460 } else {
459461 return User .getUnknown ();
460462 }
461463 }
462464 }
463465 // set email address for user if none is already available
464- if (fixEmpty (csAuthorEmail ) != null && hasHudsonTasksMailer () && !hasMail (user )) {
466+ if (fixEmpty (csAuthorEmail ) != null && hasMailerPlugin () && !hasMail (user )) {
465467 try {
466468 setMail (user , csAuthorEmail );
467469 } catch (IOException e ) {
@@ -491,14 +493,12 @@ private boolean hasMail(User user) {
491493 return email != null ;
492494 }
493495
494- private boolean hasHudsonTasksMailer () {
495- // TODO convert to checking for mailer plugin as plugin migrates to 1.509+
496- try {
497- Class .forName ("hudson.tasks.Mailer" );
498- return true ;
499- } catch (ClassNotFoundException e ) {
500- return false ;
496+ private boolean hasMailerPlugin () {
497+ Plugin p = Jenkins .get ().getPlugin ("mailer" );
498+ if (p != null ) {
499+ return p .getWrapper ().isActive ();
501500 }
501+ return false ;
502502 }
503503
504504 @ SuppressFBWarnings (value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" ,
0 commit comments