Check that nullable annotations are from org.springframework.lang

Fix a few incorrect nullable annotation imports and add a checkstyle
rule to ensure they don't return.

Closes gh-28410
This commit is contained in:
Phillip Webb
2022-05-03 11:09:14 -07:00
parent 68bb4023eb
commit 63b129a3f7
12 changed files with 31 additions and 26 deletions

View File

@@ -27,6 +27,9 @@
<!-- spring-core -->
<suppress files="[\\/]src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/]asm[\\/]" checks=".*" />
<suppress files="[\\/]src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/]cglib[\\/]" checks=".*" />
<suppress files="[\\/]src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/]lang[\\/]" checks="IllegalImport" id="bannedImports" message="javax"/>
<suppress files="[\\/]src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/]core[\\/]annotation[\\/]" checks="IllegalImport" id="bannedImports" message="javax"/>
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]core[\\/]annotation[\\/]" checks="IllegalImport" id="bannedImports" message="javax"/>
<suppress files="ByteArrayEncoder" checks="SpringLambda" />
<suppress files="SocketUtils" checks="HideUtilityClassConstructor" />
<suppress files="ResolvableType" checks="FinalClass" />

View File

@@ -106,7 +106,7 @@
<property name="id" value="bannedImports"/>
<property name="regexp" value="true" />
<property name="illegalClasses"
value="^reactor\.core\.support\.Assert,^org\.slf4j\.LoggerFactory" />
value="^reactor\.core\.support\.Assert,^org\.slf4j\.LoggerFactory,^(?!org\.springframework).*(NonNull|Nonnull|NonNullApi|NonNullFields|Nullable)$" />
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
<property name="id" value="bannedJUnit3Imports"/>