|
25 | 25 | import java.util.concurrent.locks.Lock; |
26 | 26 | import java.util.concurrent.locks.ReentrantLock; |
27 | 27 |
|
| 28 | + |
28 | 29 | import org.springframework.lang.Nullable; |
29 | 30 | import org.springframework.util.Assert; |
30 | | -import org.springframework.util.ObjectUtils; |
31 | 31 |
|
32 | 32 | /** |
33 | 33 | * Base class for {@link Declarable} classes. |
|
40 | 40 | */ |
41 | 41 | public abstract class AbstractDeclarable implements Declarable { |
42 | 42 |
|
43 | | - private final Lock lock = new ReentrantLock(); |
| 43 | + private final Lock lock = new ReentrantLock(); |
44 | 44 |
|
45 | 45 | private boolean shouldDeclare = true; |
46 | 46 |
|
@@ -103,18 +103,16 @@ public void setIgnoreDeclarationExceptions(boolean ignoreDeclarationExceptions) |
103 | 103 |
|
104 | 104 | @Override |
105 | 105 | public void setAdminsThatShouldDeclare(Object... adminArgs) { |
106 | | - this.declaringAdmins = new ArrayList<>(); |
107 | | - if (ObjectUtils.isEmpty(adminArgs)) { |
108 | | - return; |
109 | | - } |
110 | | - |
111 | | - if (adminArgs.length > 1) { |
112 | | - Assert.noNullElements(adminArgs, "'admins' cannot contain null elements"); |
113 | | - this.declaringAdmins.addAll(Arrays.asList(adminArgs)); |
114 | | - } |
115 | | - else if (adminArgs[0] != null) { |
116 | | - this.declaringAdmins.add(adminArgs[0]); |
| 106 | + Collection<Object> admins = new ArrayList<>(); |
| 107 | + if (adminArgs != null) { |
| 108 | + if (adminArgs.length > 1) { |
| 109 | + Assert.noNullElements(adminArgs, "'admins' cannot contain null elements"); |
| 110 | + } |
| 111 | + if (adminArgs.length > 0 && !(adminArgs.length == 1 && adminArgs[0] == null)) { |
| 112 | + admins.addAll(Arrays.asList(adminArgs)); |
| 113 | + } |
117 | 114 | } |
| 115 | + this.declaringAdmins = admins; |
118 | 116 | } |
119 | 117 |
|
120 | 118 | @Override |
|
0 commit comments