Skip to content

Commit 1c86273

Browse files
committed
authority: Fix null pointer crash for deleted users
When a user had a certificate, i.e. an entry in the Gitblit Authority database, but the user was deleted from the Gitblit database, then the Authority application crashes upon loading. This patch prevents the crash. The deleted user is no longer shown in the Authority. But the database entry still is kept. This should be improved to show deleted users and give the possibility to delete them from the Authority's database. This fixes #1359
1 parent 0ca5cf2 commit 1c86273

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

releases.moxie

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ r34: {
1111
html: ~
1212
text: ~
1313
security: ~
14-
fixes: ~
14+
fixes:
15+
- Fix crash in Gitblit Authority when users were deleted from Gitblit but still had entries (certificates) in the Authority.
1516
changes:
1617
- Minimum Java required increased to Java 8
1718
additions: ~

src/main/java/com/gitblit/authority/GitblitAuthority.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,11 @@ private void load(File folder) {
299299
List<UserCertificateModel> list = UserCertificateConfig.KEY.parse(config).list;
300300
for (UserCertificateModel ucm : list) {
301301
ucm.user = userService.getUserModel(ucm.user.username);
302-
map.put(ucm.user.username, ucm);
302+
// Users may have been deleted, but are still present in authority.conf.
303+
// TODO: Currently this only keeps the app from crashing. It should provide means to show obsolete user entries and delete them.
304+
if (ucm.user != null) {
305+
map.put(ucm.user.username, ucm);
306+
}
303307
}
304308
} catch (IOException e) {
305309
e.printStackTrace();

0 commit comments

Comments
 (0)