HHH-16515 - Add o.h.pretty to nullness checking

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
Jan Schatteman 2023-04-27 19:42:39 +02:00 committed by Jan Schatteman
parent 6f18947249
commit 4a8c51f14f
3 changed files with 21 additions and 17 deletions

View File

@ -524,7 +524,7 @@ checkerFramework {
extraJavacArgs = [ extraJavacArgs = [
'-AsuppressWarnings=initialization', '-AsuppressWarnings=initialization',
"-Astubs=${project.rootDir}/checkerstubs", "-Astubs=${project.rootDir}/checkerstubs",
'-AonlyDefs=^org\\.hibernate\\.(jpamodelgen|spi)\\.' '-AonlyDefs=^org\\.hibernate\\.(jpamodelgen|spi|pretty)\\.'
] ]
} }

View File

@ -15,6 +15,8 @@ import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.checkerframework.checker.nullness.qual.Nullable;
/** /**
* MessageHelper methods for rendering log messages relating to managed * MessageHelper methods for rendering log messages relating to managed
* entities and collections typically used in log statements and exception * entities and collections typically used in log statements and exception
@ -39,7 +41,7 @@ public final class MessageHelper {
* @param id The entity id value. * @param id The entity id value.
* @return An info string, in the form [FooBar#1]. * @return An info string, in the form [FooBar#1].
*/ */
public static String infoString(String entityName, Object id) { public static String infoString(@Nullable String entityName, @Nullable Object id) {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
s.append( '[' ); s.append( '[' );
if ( entityName == null ) { if ( entityName == null ) {
@ -70,9 +72,9 @@ public final class MessageHelper {
* @return An info string, in the form [FooBar#1] * @return An info string, in the form [FooBar#1]
*/ */
public static String infoString( public static String infoString(
EntityPersister persister, @Nullable EntityPersister persister,
Object id, @Nullable Object id,
SessionFactoryImplementor factory) { @Nullable SessionFactoryImplementor factory) {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
s.append( '[' ); s.append( '[' );
Type idType; Type idType;
@ -118,8 +120,8 @@ public final class MessageHelper {
* @return An info string, in the form [FooBar#1] * @return An info string, in the form [FooBar#1]
*/ */
public static String infoString( public static String infoString(
EntityPersister persister, @Nullable EntityPersister persister,
Object id, @Nullable Object id,
Type identifierType, Type identifierType,
SessionFactoryImplementor factory) { SessionFactoryImplementor factory) {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
@ -152,7 +154,7 @@ public final class MessageHelper {
* @return An info string, in the form [FooBar#&lt;1,2,3&gt;] * @return An info string, in the form [FooBar#&lt;1,2,3&gt;]
*/ */
public static String infoString( public static String infoString(
EntityPersister persister, @Nullable EntityPersister persister,
Object[] ids, Object[] ids,
SessionFactoryImplementor factory) { SessionFactoryImplementor factory) {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
@ -183,7 +185,7 @@ public final class MessageHelper {
* @param persister The persister. * @param persister The persister.
* @return An info string, in the form [FooBar] * @return An info string, in the form [FooBar]
*/ */
public static String infoString(EntityPersister persister) { public static String infoString(@Nullable EntityPersister persister) {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
s.append( '[' ); s.append( '[' );
if ( persister == null ) { if ( persister == null ) {
@ -205,7 +207,7 @@ public final class MessageHelper {
* @param key The property value. * @param key The property value.
* @return An info string, in the form [Foo.bars#1] * @return An info string, in the form [Foo.bars#1]
*/ */
public static String infoString(String entityName, String propertyName, Object key) { public static String infoString(String entityName, String propertyName, @Nullable Object key) {
StringBuilder s = new StringBuilder() StringBuilder s = new StringBuilder()
.append( '[' ) .append( '[' )
.append( entityName ) .append( entityName )
@ -238,8 +240,8 @@ public final class MessageHelper {
* @return An info string, in the form [Foo.bars#1] * @return An info string, in the form [Foo.bars#1]
*/ */
public static String collectionInfoString( public static String collectionInfoString(
CollectionPersister persister, @Nullable CollectionPersister persister,
PersistentCollection<?> collection, @Nullable PersistentCollection<?> collection,
Object collectionKey, Object collectionKey,
SharedSessionContractImplementor session ) { SharedSessionContractImplementor session ) {
@ -284,7 +286,7 @@ public final class MessageHelper {
* @return An info string, in the form [Foo.bars#&lt;1,2,3&gt;] * @return An info string, in the form [Foo.bars#&lt;1,2,3&gt;]
*/ */
public static String collectionInfoString( public static String collectionInfoString(
CollectionPersister persister, @Nullable CollectionPersister persister,
Object[] ids, Object[] ids,
SessionFactoryImplementor factory) { SessionFactoryImplementor factory) {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
@ -317,8 +319,8 @@ public final class MessageHelper {
* @return An info string, in the form [Foo.bars#1] * @return An info string, in the form [Foo.bars#1]
*/ */
public static String collectionInfoString( public static String collectionInfoString(
CollectionPersister persister, @Nullable CollectionPersister persister,
Object id, @Nullable Object id,
SessionFactoryImplementor factory) { SessionFactoryImplementor factory) {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
s.append( '[' ); s.append( '[' );
@ -374,7 +376,7 @@ public final class MessageHelper {
* @param id The id value of the owner * @param id The id value of the owner
* @return An info string, in the form [Foo.bars#1] * @return An info string, in the form [Foo.bars#1]
*/ */
public static String collectionInfoString(String role, Object id) { public static String collectionInfoString(@Nullable String role, @Nullable Object id) {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
s.append( '[' ); s.append( '[' );
if( role == null ) { if( role == null ) {

View File

@ -18,6 +18,8 @@ import org.hibernate.engine.spi.Mapping;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.checkerframework.checker.nullness.qual.Nullable;
/** /**
* Defines a mapping between a Java type and one or more JDBC {@linkplain java.sql.Types types}, * Defines a mapping between a Java type and one or more JDBC {@linkplain java.sql.Types types},
* as well as describing the in-memory semantics of the given Java type, including: * as well as describing the in-memory semantics of the given Java type, including:
@ -320,7 +322,7 @@ public interface Type extends Serializable {
* *
* @throws HibernateException An error from Hibernate * @throws HibernateException An error from Hibernate
*/ */
String toLoggableString(Object value, SessionFactoryImplementor factory) String toLoggableString(@Nullable Object value, SessionFactoryImplementor factory)
throws HibernateException; throws HibernateException;
/** /**