Hide utility class constructors
Update all utility classes so that they have a private constructor. This prevents users from accidentally creating an instance, when they should just use the static methods directly. Issue gh-8945
This commit is contained in:
@@ -19,7 +19,10 @@ package org.springframework.security.access.annotation.sec2150;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.security.access.intercept.method.MockMethodInvocation;
|
||||
|
||||
public class MethodInvocationFactory {
|
||||
public final class MethodInvocationFactory {
|
||||
|
||||
private MethodInvocationFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* In order to reproduce the bug for SEC-2150, we must have a proxy object that
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package org.springframework.security.access.expression.method;
|
||||
|
||||
public class SecurityRules {
|
||||
public final class SecurityRules {
|
||||
|
||||
private SecurityRules() {
|
||||
}
|
||||
|
||||
public static boolean disallow() {
|
||||
return false;
|
||||
|
||||
@@ -27,8 +27,6 @@ public class FieldUtilsTests {
|
||||
|
||||
@Test
|
||||
public void gettingAndSettingProtectedFieldIsSuccessful() throws Exception {
|
||||
new FieldUtils();
|
||||
|
||||
Object tc = new TestClass();
|
||||
|
||||
assertThat(FieldUtils.getProtectedFieldValue("protectedField", tc)).isEqualTo("x");
|
||||
|
||||
@@ -33,8 +33,6 @@ public class MethodInvocationUtilsTests {
|
||||
|
||||
@Test
|
||||
public void createFromClassReturnsMethodWithNoArgInfoForMethodWithNoArgs() {
|
||||
new MethodInvocationUtils();
|
||||
|
||||
MethodInvocation mi = MethodInvocationUtils.createFromClass(String.class, "length");
|
||||
assertThat(mi).isNotNull();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user