From ad36a76968efc1a5d4d40bf7d8c73136658ced3f Mon Sep 17 00:00:00 2001 From: Jan Schatteman Date: Wed, 12 Jul 2023 23:16:13 +0200 Subject: [PATCH] HHH-16515 - Add o.h.jdbc to nullness checking Signed-off-by: Jan Schatteman --- gradle/java-module.gradle | 2 +- .../src/main/java/org/hibernate/HibernateException.java | 5 +++-- .../main/java/org/hibernate/jdbc/BatchFailedException.java | 4 +++- .../src/main/java/org/hibernate/jdbc/WorkExecutor.java | 4 +++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gradle/java-module.gradle b/gradle/java-module.gradle index 376962189c..8f31a2f2d2 100644 --- a/gradle/java-module.gradle +++ b/gradle/java-module.gradle @@ -544,7 +544,7 @@ checkerFramework { extraJavacArgs = [ '-AsuppressWarnings=initialization', // stubs is passed directly through options.compilerArgumentProviders - '-AonlyDefs=^org\\.hibernate\\.(exception|integrator|jpamodelgen|service|spi|pretty|stat|engine\\.(config|jndi|profile|transaction)|(action|context|bytecode)\\.spi)\\.' + '-AonlyDefs=^org\\.hibernate\\.(jdbc|exception|integrator|jpamodelgen|service|spi|pretty|stat|engine\\.(config|jndi|profile|transaction)|(action|context|bytecode)\\.spi)\\.' ] } diff --git a/hibernate-core/src/main/java/org/hibernate/HibernateException.java b/hibernate-core/src/main/java/org/hibernate/HibernateException.java index cc7fac2aac..6a2885b5b4 100644 --- a/hibernate-core/src/main/java/org/hibernate/HibernateException.java +++ b/hibernate-core/src/main/java/org/hibernate/HibernateException.java @@ -7,6 +7,7 @@ package org.hibernate; import jakarta.persistence.PersistenceException; +import org.checkerframework.checker.nullness.qual.Nullable; /** * The base type for exceptions thrown by Hibernate. @@ -31,7 +32,7 @@ public class HibernateException extends PersistenceException { * * @param cause The underlying cause. */ - public HibernateException(Throwable cause) { + public HibernateException(@Nullable Throwable cause) { super( cause ); } @@ -41,7 +42,7 @@ public class HibernateException extends PersistenceException { * @param message The message explaining the reason for the exception. * @param cause The underlying cause. */ - public HibernateException(String message, Throwable cause) { + public HibernateException(String message, @Nullable Throwable cause) { super( message, cause ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/jdbc/BatchFailedException.java b/hibernate-core/src/main/java/org/hibernate/jdbc/BatchFailedException.java index f0e55f5b25..cd5fcf217b 100644 --- a/hibernate-core/src/main/java/org/hibernate/jdbc/BatchFailedException.java +++ b/hibernate-core/src/main/java/org/hibernate/jdbc/BatchFailedException.java @@ -7,6 +7,8 @@ package org.hibernate.jdbc; import org.hibernate.HibernateException; +import org.checkerframework.checker.nullness.qual.Nullable; + /** * Indicates a failed batch entry (-3 return). * @@ -17,7 +19,7 @@ public class BatchFailedException extends HibernateException { super( s ); } - public BatchFailedException(String string, Throwable root) { + public BatchFailedException(String string, @Nullable Throwable root) { super( string, root ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/jdbc/WorkExecutor.java b/hibernate-core/src/main/java/org/hibernate/jdbc/WorkExecutor.java index 5da608bda4..189c0276f7 100644 --- a/hibernate-core/src/main/java/org/hibernate/jdbc/WorkExecutor.java +++ b/hibernate-core/src/main/java/org/hibernate/jdbc/WorkExecutor.java @@ -9,6 +9,8 @@ package org.hibernate.jdbc; import java.sql.Connection; import java.sql.SQLException; +import org.checkerframework.checker.nullness.qual.Nullable; + /** * A visitor used for executing a discrete piece of work encapsulated in a * {@link Work} or {@link ReturningWork} instance. @@ -33,7 +35,7 @@ public class WorkExecutor { * @throws SQLException Thrown during execution of the underlying JDBC interaction. * @throws org.hibernate.HibernateException Generally indicates a wrapped SQLException. */ - public T executeWork(Work work, Connection connection) throws SQLException { + public @Nullable T executeWork(Work work, Connection connection) throws SQLException { work.execute( connection ); return null; }