]> source.dussan.org Git - gitblit.git/commitdiff
Two slight improvement for custom UserService: 264/head 54/254/1
authorFabrice Bacchella <fbacchella@spamcop.net>
Tue, 26 May 2015 08:48:40 +0000 (10:48 +0200)
committerFabrice Bacchella <fbacchella@spamcop.net>
Tue, 26 May 2015 08:48:40 +0000 (10:48 +0200)
- try userRealm as a file only if class is not found, other exeptions are real error
- log userService only after setup, for better logging, as it can use gitblit.properties for custom .toString

src/main/java/com/gitblit/manager/UserManager.java

index 86be8bcd2c27114fa85019e3523fdc33132dd6cf..0d7ee9a55f6889160a4891b17b925d4626faa060 100644 (file)
@@ -83,9 +83,9 @@ public class UserManager implements IUserManager {
         * @param userService
         */
        public void setUserService(IUserService userService) {
-               logger.info(userService.toString());
                this.userService = userService;
                this.userService.setup(runtimeManager);
+               logger.info(userService.toString());
        }
 
        @Override
@@ -115,10 +115,12 @@ public class UserManager implements IUserManager {
                                        // check to see if this "file" is a custom user service class
                                        Class<?> realmClass = Class.forName(realm);
                                        service = (IUserService) realmClass.newInstance();
-                               } catch (Throwable t) {
+                               } catch (ClassNotFoundException t) {
                                        // typical file path configuration
                                        File realmFile = runtimeManager.getFileOrFolder(Keys.realm.userService, "${baseFolder}/users.conf");
                                        service = createUserService(realmFile);
+                               } catch (InstantiationException | IllegalAccessException  e) {
+                                       logger.error("failed to instanciate user service {}: {}", realm, e.getMessage());
                                }
                        }
                        setUserService(service);