Skip to content

Commit 34dd5fe

Browse files
committed
Remove redundant throws clauses
Removes exceptions that are declared in a method's signature but never thrown by the method itself or its implementations/derivatives.
1 parent f0515a0 commit 34dd5fe

File tree

418 files changed

+1146
-1273
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

418 files changed

+1146
-1273
lines changed

acl/src/main/java/org/springframework/security/acls/jdbc/AclClassIdUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ && canConvertFromStringTo(classIdTypeFrom(resultSet))) {
7474
return identifier;
7575
}
7676

77-
private boolean hasValidClassIdType(ResultSet resultSet) throws SQLException {
77+
private boolean hasValidClassIdType(ResultSet resultSet) {
7878
boolean hasClassIdType = false;
7979
try {
8080
hasClassIdType = classIdTypeFrom(resultSet) != null;

acl/src/test/java/org/springframework/security/acls/AclFormattingUtilsTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class AclFormattingUtilsTests {
3232
// ~ Methods
3333
// ========================================================================================================
3434
@Test
35-
public final void testDemergePatternsParametersConstraints() throws Exception {
35+
public final void testDemergePatternsParametersConstraints() {
3636
try {
3737
AclFormattingUtils.demergePatterns(null, "SOME STRING");
3838
fail("It should have thrown IllegalArgumentException");
@@ -63,7 +63,7 @@ public final void testDemergePatternsParametersConstraints() throws Exception {
6363
}
6464

6565
@Test
66-
public final void testDemergePatterns() throws Exception {
66+
public final void testDemergePatterns() {
6767
String original = "...........................A...R";
6868
String removeBits = "...............................R";
6969
assertThat(AclFormattingUtils.demergePatterns(original, removeBits)).isEqualTo(
@@ -76,7 +76,7 @@ public final void testDemergePatterns() throws Exception {
7676
}
7777

7878
@Test
79-
public final void testMergePatternsParametersConstraints() throws Exception {
79+
public final void testMergePatternsParametersConstraints() {
8080
try {
8181
AclFormattingUtils.mergePatterns(null, "SOME STRING");
8282
fail("It should have thrown IllegalArgumentException");
@@ -106,7 +106,7 @@ public final void testMergePatternsParametersConstraints() throws Exception {
106106
}
107107

108108
@Test
109-
public final void testMergePatterns() throws Exception {
109+
public final void testMergePatterns() {
110110
String original = "...............................R";
111111
String extraBits = "...........................A....";
112112
assertThat(AclFormattingUtils.mergePatterns(original, extraBits)).isEqualTo(
@@ -119,7 +119,7 @@ public final void testMergePatterns() throws Exception {
119119
}
120120

121121
@Test
122-
public final void testBinaryPrints() throws Exception {
122+
public final void testBinaryPrints() {
123123
assertThat(AclFormattingUtils.printBinary(15)).isEqualTo(
124124
"............................****");
125125

acl/src/test/java/org/springframework/security/acls/AclPermissionCacheOptimizerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
public class AclPermissionCacheOptimizerTests {
3737

3838
@Test
39-
public void eagerlyLoadsRequiredAcls() throws Exception {
39+
public void eagerlyLoadsRequiredAcls() {
4040
AclService service = mock(AclService.class);
4141
AclPermissionCacheOptimizer pco = new AclPermissionCacheOptimizer(service);
4242
ObjectIdentityRetrievalStrategy oidStrat = mock(ObjectIdentityRetrievalStrategy.class);

acl/src/test/java/org/springframework/security/acls/AclPermissionEvaluatorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
public class AclPermissionEvaluatorTests {
3838

3939
@Test
40-
public void hasPermissionReturnsTrueIfAclGrantsPermission() throws Exception {
40+
public void hasPermissionReturnsTrueIfAclGrantsPermission() {
4141
AclService service = mock(AclService.class);
4242
AclPermissionEvaluator pe = new AclPermissionEvaluator(service);
4343
ObjectIdentity oid = mock(ObjectIdentity.class);

acl/src/test/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationCollectionFilteringProviderTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
@SuppressWarnings({ "unchecked" })
3838
public class AclEntryAfterInvocationCollectionFilteringProviderTests {
3939
@Test
40-
public void objectsAreRemovedIfPermissionDenied() throws Exception {
40+
public void objectsAreRemovedIfPermissionDenied() {
4141
AclService service = mock(AclService.class);
4242
Acl acl = mock(Acl.class);
4343
when(acl.isGranted(any(), any(), anyBoolean())).thenReturn(
@@ -63,7 +63,7 @@ public void objectsAreRemovedIfPermissionDenied() throws Exception {
6363
}
6464

6565
@Test
66-
public void accessIsGrantedIfNoAttributesDefined() throws Exception {
66+
public void accessIsGrantedIfNoAttributesDefined() {
6767
AclEntryAfterInvocationCollectionFilteringProvider provider = new AclEntryAfterInvocationCollectionFilteringProvider(
6868
mock(AclService.class), Arrays.asList(mock(Permission.class)));
6969
Object returned = new Object();
@@ -75,7 +75,7 @@ public void accessIsGrantedIfNoAttributesDefined() throws Exception {
7575
}
7676

7777
@Test
78-
public void nullReturnObjectIsIgnored() throws Exception {
78+
public void nullReturnObjectIsIgnored() {
7979
AclService service = mock(AclService.class);
8080
AclEntryAfterInvocationCollectionFilteringProvider provider = new AclEntryAfterInvocationCollectionFilteringProvider(
8181
service, Arrays.asList(mock(Permission.class)));

acl/src/test/java/org/springframework/security/acls/afterinvocation/AclEntryAfterInvocationProviderTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
public class AclEntryAfterInvocationProviderTests {
3838

3939
@Test(expected = IllegalArgumentException.class)
40-
public void rejectsMissingPermissions() throws Exception {
40+
public void rejectsMissingPermissions() {
4141
try {
4242
new AclEntryAfterInvocationProvider(mock(AclService.class), null);
4343
fail("Exception expected");
@@ -72,7 +72,7 @@ public void accessIsAllowedIfPermissionIsGranted() {
7272
}
7373

7474
@Test
75-
public void accessIsGrantedIfNoAttributesDefined() throws Exception {
75+
public void accessIsGrantedIfNoAttributesDefined() {
7676
AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider(
7777
mock(AclService.class), Arrays.asList(mock(Permission.class)));
7878
Object returned = new Object();
@@ -85,7 +85,7 @@ public void accessIsGrantedIfNoAttributesDefined() throws Exception {
8585
}
8686

8787
@Test
88-
public void accessIsGrantedIfObjectTypeNotSupported() throws Exception {
88+
public void accessIsGrantedIfObjectTypeNotSupported() {
8989
AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider(
9090
mock(AclService.class), Arrays.asList(mock(Permission.class)));
9191
provider.setProcessDomainObjectClass(String.class);
@@ -131,7 +131,7 @@ public void accessIsDeniedIfPermissionIsNotGranted() {
131131
}
132132

133133
@Test
134-
public void nullReturnObjectIsIgnored() throws Exception {
134+
public void nullReturnObjectIsIgnored() {
135135
AclService service = mock(AclService.class);
136136
AclEntryAfterInvocationProvider provider = new AclEntryAfterInvocationProvider(
137137
service, Arrays.asList(mock(Permission.class)));

acl/src/test/java/org/springframework/security/acls/domain/AclImplTests.java

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class AclImplTests {
5454
// ========================================================================================================
5555

5656
@Before
57-
public void setUp() throws Exception {
57+
public void setUp() {
5858
SecurityContextHolder.getContext().setAuthentication(auth);
5959
authzStrategy = mock(AclAuthorizationStrategy.class);
6060
mockAuditLogger = mock(AuditLogger.class);
@@ -63,12 +63,12 @@ public void setUp() throws Exception {
6363
}
6464

6565
@After
66-
public void tearDown() throws Exception {
66+
public void tearDown() {
6767
SecurityContextHolder.clearContext();
6868
}
6969

7070
@Test(expected = IllegalArgumentException.class)
71-
public void constructorsRejectNullObjectIdentity() throws Exception {
71+
public void constructorsRejectNullObjectIdentity() {
7272
try {
7373
new AclImpl(null, 1, authzStrategy, pgs, null, null, true, new PrincipalSid(
7474
"joe"));
@@ -80,7 +80,7 @@ public void constructorsRejectNullObjectIdentity() throws Exception {
8080
}
8181

8282
@Test(expected = IllegalArgumentException.class)
83-
public void constructorsRejectNullId() throws Exception {
83+
public void constructorsRejectNullId() {
8484
try {
8585
new AclImpl(objectIdentity, null, authzStrategy, pgs, null, null, true,
8686
new PrincipalSid("joe"));
@@ -93,7 +93,7 @@ public void constructorsRejectNullId() throws Exception {
9393

9494
@SuppressWarnings("deprecation")
9595
@Test(expected = IllegalArgumentException.class)
96-
public void constructorsRejectNullAclAuthzStrategy() throws Exception {
96+
public void constructorsRejectNullAclAuthzStrategy() {
9797
try {
9898
new AclImpl(objectIdentity, 1, null, new DefaultPermissionGrantingStrategy(
9999
mockAuditLogger), null, null, true, new PrincipalSid("joe"));
@@ -105,7 +105,7 @@ public void constructorsRejectNullAclAuthzStrategy() throws Exception {
105105
}
106106

107107
@Test
108-
public void insertAceRejectsNullParameters() throws Exception {
108+
public void insertAceRejectsNullParameters() {
109109
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
110110
true, new PrincipalSid("joe"));
111111
try {
@@ -123,7 +123,7 @@ public void insertAceRejectsNullParameters() throws Exception {
123123
}
124124

125125
@Test
126-
public void insertAceAddsElementAtCorrectIndex() throws Exception {
126+
public void insertAceAddsElementAtCorrectIndex() {
127127
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
128128
true, new PrincipalSid("joe"));
129129
MockAclService service = new MockAclService();
@@ -166,7 +166,7 @@ public void insertAceAddsElementAtCorrectIndex() throws Exception {
166166
}
167167

168168
@Test(expected = NotFoundException.class)
169-
public void insertAceFailsForNonExistentElement() throws Exception {
169+
public void insertAceFailsForNonExistentElement() {
170170
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
171171
true, new PrincipalSid("joe"));
172172
MockAclService service = new MockAclService();
@@ -180,7 +180,7 @@ public void insertAceFailsForNonExistentElement() throws Exception {
180180
}
181181

182182
@Test
183-
public void deleteAceKeepsInitialOrdering() throws Exception {
183+
public void deleteAceKeepsInitialOrdering() {
184184
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
185185
true, new PrincipalSid("joe"));
186186
MockAclService service = new MockAclService();
@@ -217,7 +217,7 @@ public void deleteAceKeepsInitialOrdering() throws Exception {
217217
}
218218

219219
@Test
220-
public void deleteAceFailsForNonExistentElement() throws Exception {
220+
public void deleteAceFailsForNonExistentElement() {
221221
AclAuthorizationStrategyImpl strategy = new AclAuthorizationStrategyImpl(
222222
new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority(
223223
"ROLE_AUDITING"), new SimpleGrantedAuthority("ROLE_GENERAL"));
@@ -232,7 +232,7 @@ public void deleteAceFailsForNonExistentElement() throws Exception {
232232
}
233233

234234
@Test
235-
public void isGrantingRejectsEmptyParameters() throws Exception {
235+
public void isGrantingRejectsEmptyParameters() {
236236
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
237237
true, new PrincipalSid("joe"));
238238
Sid ben = new PrincipalSid("ben");
@@ -251,7 +251,7 @@ public void isGrantingRejectsEmptyParameters() throws Exception {
251251
}
252252

253253
@Test
254-
public void isGrantingGrantsAccessForAclWithNoParent() throws Exception {
254+
public void isGrantingGrantsAccessForAclWithNoParent() {
255255
Authentication auth = new TestingAuthenticationToken("ben", "ignored",
256256
"ROLE_GENERAL", "ROLE_GUEST");
257257
auth.setAuthenticated(true);
@@ -297,7 +297,7 @@ public void isGrantingGrantsAccessForAclWithNoParent() throws Exception {
297297
}
298298

299299
@Test
300-
public void isGrantingGrantsAccessForInheritableAcls() throws Exception {
300+
public void isGrantingGrantsAccessForInheritableAcls() {
301301
Authentication auth = new TestingAuthenticationToken("ben", "ignored",
302302
"ROLE_GENERAL");
303303
auth.setAuthenticated(true);
@@ -379,7 +379,7 @@ public void isGrantingGrantsAccessForInheritableAcls() throws Exception {
379379
}
380380

381381
@Test
382-
public void updatedAceValuesAreCorrectlyReflectedInAcl() throws Exception {
382+
public void updatedAceValuesAreCorrectlyReflectedInAcl() {
383383
Authentication auth = new TestingAuthenticationToken("ben", "ignored",
384384
"ROLE_GENERAL");
385385
auth.setAuthenticated(true);
@@ -411,7 +411,7 @@ public void updatedAceValuesAreCorrectlyReflectedInAcl() throws Exception {
411411
}
412412

413413
@Test
414-
public void auditableEntryFlagsAreUpdatedCorrectly() throws Exception {
414+
public void auditableEntryFlagsAreUpdatedCorrectly() {
415415
Authentication auth = new TestingAuthenticationToken("ben", "ignored",
416416
"ROLE_AUDITING", "ROLE_GENERAL");
417417
auth.setAuthenticated(true);
@@ -449,7 +449,7 @@ public void auditableEntryFlagsAreUpdatedCorrectly() throws Exception {
449449
}
450450

451451
@Test
452-
public void gettersAndSettersAreConsistent() throws Exception {
452+
public void gettersAndSettersAreConsistent() {
453453
Authentication auth = new TestingAuthenticationToken("ben", "ignored",
454454
"ROLE_GENERAL");
455455
auth.setAuthenticated(true);
@@ -485,7 +485,7 @@ public void gettersAndSettersAreConsistent() throws Exception {
485485
}
486486

487487
@Test
488-
public void isSidLoadedBehavesAsExpected() throws Exception {
488+
public void isSidLoadedBehavesAsExpected() {
489489
List<Sid> loadedSids = Arrays.asList(new PrincipalSid("ben"),
490490
new GrantedAuthoritySid("ROLE_IGNORED"));
491491
MutableAcl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null,
@@ -513,22 +513,21 @@ public void isSidLoadedBehavesAsExpected() throws Exception {
513513
}
514514

515515
@Test(expected = NotFoundException.class)
516-
public void insertAceRaisesNotFoundExceptionForIndexLessThanZero() throws Exception {
516+
public void insertAceRaisesNotFoundExceptionForIndexLessThanZero() {
517517
AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
518518
true, new PrincipalSid("joe"));
519519
acl.insertAce(-1, mock(Permission.class), mock(Sid.class), true);
520520
}
521521

522522
@Test(expected = NotFoundException.class)
523-
public void deleteAceRaisesNotFoundExceptionForIndexLessThanZero() throws Exception {
523+
public void deleteAceRaisesNotFoundExceptionForIndexLessThanZero() {
524524
AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
525525
true, new PrincipalSid("joe"));
526526
acl.deleteAce(-1);
527527
}
528528

529529
@Test(expected = NotFoundException.class)
530-
public void insertAceRaisesNotFoundExceptionForIndexGreaterThanSize()
531-
throws Exception {
530+
public void insertAceRaisesNotFoundExceptionForIndexGreaterThanSize() {
532531
AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
533532
true, new PrincipalSid("joe"));
534533
// Insert at zero, OK.
@@ -539,7 +538,7 @@ public void insertAceRaisesNotFoundExceptionForIndexGreaterThanSize()
539538

540539
// SEC-1151
541540
@Test(expected = NotFoundException.class)
542-
public void deleteAceRaisesNotFoundExceptionForIndexEqualToSize() throws Exception {
541+
public void deleteAceRaisesNotFoundExceptionForIndexEqualToSize() {
543542
AclImpl acl = new AclImpl(objectIdentity, 1, authzStrategy, pgs, null, null,
544543
true, new PrincipalSid("joe"));
545544
acl.insertAce(0, mock(Permission.class), mock(Sid.class), true);
@@ -549,7 +548,7 @@ public void deleteAceRaisesNotFoundExceptionForIndexEqualToSize() throws Excepti
549548

550549
// SEC-1795
551550
@Test
552-
public void changingParentIsSuccessful() throws Exception {
551+
public void changingParentIsSuccessful() {
553552
AclImpl parentAcl = new AclImpl(objectIdentity, 1L, authzStrategy,
554553
mockAuditLogger);
555554
AclImpl childAcl = new AclImpl(objectIdentity, 2L, authzStrategy, mockAuditLogger);

acl/src/test/java/org/springframework/security/acls/domain/AclImplementationSecurityCheckTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ public class AclImplementationSecurityCheckTests {
4141
// ========================================================================================================
4242

4343
@Before
44-
public void setUp() throws Exception {
44+
public void setUp() {
4545
SecurityContextHolder.clearContext();
4646
}
4747

4848
@After
49-
public void tearDown() throws Exception {
49+
public void tearDown() {
5050
SecurityContextHolder.clearContext();
5151
}
5252

5353
@Test
54-
public void testSecurityCheckNoACEs() throws Exception {
54+
public void testSecurityCheckNoACEs() {
5555
Authentication auth = new TestingAuthenticationToken("user", "password",
5656
"ROLE_GENERAL", "ROLE_AUDITING", "ROLE_OWNERSHIP");
5757
auth.setAuthenticated(true);
@@ -103,7 +103,7 @@ public void testSecurityCheckNoACEs() throws Exception {
103103
}
104104

105105
@Test
106-
public void testSecurityCheckWithMultipleACEs() throws Exception {
106+
public void testSecurityCheckWithMultipleACEs() {
107107
// Create a simple authentication with ROLE_GENERAL
108108
Authentication auth = new TestingAuthenticationToken("user", "password",
109109
"ROLE_GENERAL");
@@ -206,7 +206,7 @@ public void testSecurityCheckWithMultipleACEs() throws Exception {
206206
}
207207

208208
@Test
209-
public void testSecurityCheckWithInheritableACEs() throws Exception {
209+
public void testSecurityCheckWithInheritableACEs() {
210210
// Create a simple authentication with ROLE_GENERAL
211211
Authentication auth = new TestingAuthenticationToken("user", "password",
212212
"ROLE_GENERAL");
@@ -273,7 +273,7 @@ public void testSecurityCheckWithInheritableACEs() throws Exception {
273273
}
274274

275275
@Test
276-
public void testSecurityCheckPrincipalOwner() throws Exception {
276+
public void testSecurityCheckPrincipalOwner() {
277277
Authentication auth = new TestingAuthenticationToken("user", "password",
278278
"ROLE_ONE");
279279
auth.setAuthenticated(true);

0 commit comments

Comments
 (0)