Upgrade Gradle to 8.8, upgrade checkframework to 0.6.40, fix HibernateProcessor resources creation causing whole tests recompilation

This commit is contained in:
Andrea Boriero 2024-06-11 16:19:06 +02:00 committed by Christian Beikov
parent a4ba87bc65
commit 55ab762dde
10 changed files with 30 additions and 24 deletions

View File

@ -25,7 +25,7 @@ plugins {
id 'org.hibernate.orm.database-service' apply false
id 'biz.aQute.bnd' version '6.3.1' apply false
id 'org.checkerframework' version '0.6.34'
id 'org.checkerframework' version '0.6.40'
id 'org.hibernate.orm.build.jdks'
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'

View File

@ -477,6 +477,7 @@ tasks.withType(JavaCompile).configureEach { task ->
}
checkerFramework {
excludeTests = true
checkers = [
'org.checkerframework.checker.nullness.NullnessChecker'
]

14
gradlew vendored
View File

@ -145,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@ -153,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@ -202,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \

View File

@ -56,6 +56,7 @@ import org.hibernate.type.EntityType;
import org.hibernate.type.ForeignKeyDirection;
import org.hibernate.type.Type;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import static org.hibernate.proxy.HibernateProxy.extractLazyInitializer;
@ -981,7 +982,7 @@ public class ActionQueue {
protected SessionImplementor session;
// Concurrency handling required when transaction completion process is dynamically registered
// inside event listener (HHH-7478).
protected Queue<T> processes = new ConcurrentLinkedQueue<>();
protected ConcurrentLinkedQueue<@NonNull T> processes = new ConcurrentLinkedQueue<>();
private AbstractTransactionCompletionProcessQueue(SessionImplementor session) {
this.session = session;
@ -1009,9 +1010,10 @@ public class ActionQueue {
}
public void beforeTransactionCompletion() {
while ( !processes.isEmpty() ) {
BeforeTransactionCompletionProcess process;
while ( ( process = processes.poll() ) != null ) {
try {
processes.poll().doBeforeTransactionCompletion( session );
process.doBeforeTransactionCompletion( session );
}
catch (HibernateException he) {
throw he;
@ -1039,9 +1041,10 @@ public class ActionQueue {
}
public void afterTransactionCompletion(boolean success) {
while ( !processes.isEmpty() ) {
AfterTransactionCompletionProcess process;
while ( ( process = processes.poll() ) != null ) {
try {
processes.poll().doAfterTransactionCompletion( success, session );
process.doAfterTransactionCompletion( success, session );
}
catch (CacheException ce) {
LOG.unableToReleaseCacheLock( ce );

View File

@ -15,8 +15,6 @@ import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.sql.DdlType;
import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
import org.checkerframework.checker.units.qual.N;
import static org.hibernate.type.SqlTypes.ENUM;
/**

View File

@ -14,6 +14,8 @@ import javax.lang.model.type.ExecutableType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.SimpleTypeVisitor8;
import org.hibernate.processor.util.NullnessUtil;
import static org.hibernate.processor.util.Constants.COLLECTIONS;
import static org.hibernate.processor.util.StringUtil.isProperty;
import static org.hibernate.processor.util.TypeUtils.getCollectionElementType;
@ -32,14 +34,13 @@ class ContainsAttributeTypeVisitor extends SimpleTypeVisitor8<Boolean, Element>
@Override
public Boolean visitDeclared(DeclaredType declaredType, Element element) {
TypeElement returnedElement = (TypeElement) context.getTypeUtils().asElement(declaredType);
final String returnTypeName = returnedElement.getQualifiedName().toString();
final String returnTypeName = NullnessUtil.castNonNull( returnedElement ).getQualifiedName().toString();
final String collection = COLLECTIONS.get(returnTypeName);
if (collection != null) {
final TypeMirror collectionElementType =
getCollectionElementType( declaredType, returnTypeName, null, context );
final Element collectionElement = context.getTypeUtils().asElement(collectionElementType);
if ( ElementKind.TYPE_PARAMETER == collectionElement.getKind() ) {
if ( ElementKind.TYPE_PARAMETER == NullnessUtil.castNonNull( collectionElement ).getKind() ) {
return false;
}
returnedElement = (TypeElement) collectionElement;

View File

@ -9,6 +9,7 @@ package org.hibernate.processor.annotation;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.hibernate.processor.Context;
import org.hibernate.processor.util.Constants;
import org.hibernate.processor.util.NullnessUtil;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
@ -72,7 +73,7 @@ public class DataMetaAttributeGenerationVisitor extends SimpleTypeVisitor8<@Null
public @Nullable DataAnnotationMetaAttribute visitDeclared(DeclaredType declaredType, Element element) {
final TypeElement returnedElement = (TypeElement) typeUtils().asElement( declaredType );
// WARNING: .toString() is necessary here since Name equals does not compare to String
final String returnTypeName = returnedElement.getQualifiedName().toString();
final String returnTypeName = NullnessUtil.castNonNull( returnedElement ).getQualifiedName().toString();
final String collection = Constants.COLLECTIONS.get( returnTypeName );
final String targetEntity = getTargetEntity( element.getAnnotationMirrors() );
if ( collection != null ) {

View File

@ -11,6 +11,7 @@ import org.hibernate.processor.Context;
import org.hibernate.processor.util.AccessType;
import org.hibernate.processor.util.AccessTypeInformation;
import org.hibernate.processor.util.Constants;
import org.hibernate.processor.util.NullnessUtil;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
@ -84,8 +85,9 @@ public class MetaAttributeGenerationVisitor extends SimpleTypeVisitor8<@Nullable
@Override
public @Nullable AnnotationMetaAttribute visitDeclared(DeclaredType declaredType, Element element) {
final TypeElement returnedElement = (TypeElement) typeUtils().asElement( declaredType );
assert returnedElement != null;
// WARNING: .toString() is necessary here since Name equals does not compare to String
final String returnTypeName = returnedElement.getQualifiedName().toString();
final String returnTypeName = NullnessUtil.castNonNull( returnedElement ).getQualifiedName().toString();
final String collection = Constants.COLLECTIONS.get( returnTypeName );
final String targetEntity = getTargetEntity( element.getAnnotationMirrors() );
if ( collection != null ) {
@ -109,7 +111,7 @@ public class MetaAttributeGenerationVisitor extends SimpleTypeVisitor8<@Nullable
getCollectionElementType( declaredType, returnTypeName, explicitTargetEntity, context );
if ( collectionElementType.getKind() == TypeKind.DECLARED ) {
final TypeElement collectionElement = (TypeElement) typeUtils().asElement( collectionElementType );
setAccessType( collectionElementType, collectionElement );
setAccessType( collectionElementType, NullnessUtil.castNonNull( collectionElement ) );
}
}
return createMetaAttribute( declaredType, element, collection, targetEntity );

View File

@ -6,8 +6,8 @@
*/
package org.hibernate.processor.util;
import org.hibernate.internal.util.NullnessUtil;
import org.hibernate.processor.Context;
import org.hibernate.processor.util.Constants;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
@ -46,7 +46,7 @@ class BasicAttributeVisitor extends SimpleTypeVisitor8<Boolean, Element> {
public Boolean visitArray(ArrayType arrayType, Element element) {
final TypeElement componentElement = (TypeElement)
context.getTypeUtils().asElement( arrayType.getComponentType() );
return BASIC_ARRAY_TYPES.contains( componentElement.getQualifiedName().toString() );
return BASIC_ARRAY_TYPES.contains( NullnessUtil.castNonNull( componentElement ).getQualifiedName().toString() );
}
@Override

View File

@ -655,7 +655,7 @@ public final class TypeUtils {
public @Nullable String visitDeclared(DeclaredType declaredType, Element element) {
final TypeElement returnedElement = (TypeElement)
context.getTypeUtils().asElement( declaredType );
return containsAnnotation( returnedElement, EMBEDDABLE )
return containsAnnotation( NullnessUtil.castNonNull( returnedElement ), EMBEDDABLE )
? returnedElement.getQualifiedName().toString()
: null;
}