Skip to content

Commit 8166086

Browse files
dreab8beikov
authored andcommitted
Upgrade Gradle to 8.8, upgrade checkframework to 0.6.40, fix HibernateProcessor resources creation causing whole tests recompilation
1 parent 0db4148 commit 8166086

File tree

12 files changed

+44
-28
lines changed

12 files changed

+44
-28
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ plugins {
2525
id 'org.hibernate.orm.database-service' apply false
2626
id 'biz.aQute.bnd' version '6.3.1' apply false
2727

28-
id 'org.checkerframework' version '0.6.34'
28+
id 'org.checkerframework' version '0.6.40'
2929
id 'org.hibernate.orm.build.jdks'
3030

3131
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'

gradle/java-module.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ tasks.withType(JavaCompile).configureEach { task ->
477477
}
478478

479479
checkerFramework {
480+
excludeTests = true
480481
checkers = [
481482
'org.checkerframework.checker.nullness.NullnessChecker'
482483
]

gradlew

+7-7
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
145145
case $MAX_FD in #(
146146
max*)
147147
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
148-
# shellcheck disable=SC3045
148+
# shellcheck disable=SC2039,SC3045
149149
MAX_FD=$( ulimit -H -n ) ||
150150
warn "Could not query maximum file descriptor limit"
151151
esac
152152
case $MAX_FD in #(
153153
'' | soft) :;; #(
154154
*)
155155
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
156-
# shellcheck disable=SC3045
156+
# shellcheck disable=SC2039,SC3045
157157
ulimit -n "$MAX_FD" ||
158158
warn "Could not set maximum file descriptor limit to $MAX_FD"
159159
esac
@@ -202,11 +202,11 @@ fi
202202
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203203
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204204

205-
# Collect all arguments for the java command;
206-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
207-
# shell script including quotes and variable substitutions, so put them in
208-
# double quotes to make sure that they get re-expanded; and
209-
# * put everything else in single quotes, so that it's not re-expanded.
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
210210

211211
set -- \
212212
"-Dorg.gradle.appname=$APP_BASE_NAME" \

hibernate-core/src/main/java/org/hibernate/engine/spi/ActionQueue.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import org.hibernate.type.ForeignKeyDirection;
5858
import org.hibernate.type.Type;
5959

60+
import org.checkerframework.checker.nullness.qual.NonNull;
6061
import org.checkerframework.checker.nullness.qual.Nullable;
6162

6263
import static org.hibernate.proxy.HibernateProxy.extractLazyInitializer;
@@ -992,7 +993,7 @@ private abstract static class AbstractTransactionCompletionProcessQueue<T> {
992993
protected SessionImplementor session;
993994
// Concurrency handling required when transaction completion process is dynamically registered
994995
// inside event listener (HHH-7478).
995-
protected Queue<T> processes = new ConcurrentLinkedQueue<>();
996+
protected ConcurrentLinkedQueue<@NonNull T> processes = new ConcurrentLinkedQueue<>();
996997

997998
private AbstractTransactionCompletionProcessQueue(SessionImplementor session) {
998999
this.session = session;
@@ -1020,9 +1021,10 @@ private BeforeTransactionCompletionProcessQueue(SessionImplementor session) {
10201021
}
10211022

10221023
public void beforeTransactionCompletion() {
1023-
while ( !processes.isEmpty() ) {
1024+
BeforeTransactionCompletionProcess process;
1025+
while ( ( process = processes.poll() ) != null ) {
10241026
try {
1025-
processes.poll().doBeforeTransactionCompletion( session );
1027+
process.doBeforeTransactionCompletion( session );
10261028
}
10271029
catch (HibernateException he) {
10281030
throw he;
@@ -1050,9 +1052,10 @@ public void addSpaceToInvalidate(String space) {
10501052
}
10511053

10521054
public void afterTransactionCompletion(boolean success) {
1053-
while ( !processes.isEmpty() ) {
1055+
AfterTransactionCompletionProcess process;
1056+
while ( ( process = processes.poll() ) != null ) {
10541057
try {
1055-
processes.poll().doAfterTransactionCompletion( success, session );
1058+
process.doAfterTransactionCompletion( success, session );
10561059
}
10571060
catch (CacheException ce) {
10581061
LOG.unableToReleaseCacheLock( ce );

hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/internal/NativeEnumDdlTypeImpl.java

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import org.hibernate.type.descriptor.sql.DdlType;
1616
import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
1717

18-
import org.checkerframework.checker.units.qual.N;
19-
2018
import static org.hibernate.type.SqlTypes.ENUM;
2119

2220
/**

tooling/metamodel-generator/src/main/java/org/hibernate/processor/ContainsAttributeTypeVisitor.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import javax.lang.model.type.TypeMirror;
1515
import javax.lang.model.util.SimpleTypeVisitor8;
1616

17+
import org.hibernate.processor.util.NullnessUtil;
18+
1719
import static org.hibernate.processor.util.Constants.COLLECTIONS;
1820
import static org.hibernate.processor.util.StringUtil.isProperty;
1921
import static org.hibernate.processor.util.TypeUtils.getCollectionElementType;
@@ -32,14 +34,13 @@ class ContainsAttributeTypeVisitor extends SimpleTypeVisitor8<Boolean, Element>
3234
@Override
3335
public Boolean visitDeclared(DeclaredType declaredType, Element element) {
3436
TypeElement returnedElement = (TypeElement) context.getTypeUtils().asElement(declaredType);
35-
36-
final String returnTypeName = returnedElement.getQualifiedName().toString();
37+
final String returnTypeName = NullnessUtil.castNonNull( returnedElement ).getQualifiedName().toString();
3738
final String collection = COLLECTIONS.get(returnTypeName);
3839
if (collection != null) {
3940
final TypeMirror collectionElementType =
4041
getCollectionElementType( declaredType, returnTypeName, null, context );
4142
final Element collectionElement = context.getTypeUtils().asElement(collectionElementType);
42-
if ( ElementKind.TYPE_PARAMETER == collectionElement.getKind() ) {
43+
if ( ElementKind.TYPE_PARAMETER == NullnessUtil.castNonNull( collectionElement ).getKind() ) {
4344
return false;
4445
}
4546
returnedElement = (TypeElement) collectionElement;

tooling/metamodel-generator/src/main/java/org/hibernate/processor/Context.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.util.List;
1414
import java.util.Map;
1515
import java.util.Set;
16+
import java.util.TreeSet;
1617
import javax.annotation.processing.ProcessingEnvironment;
1718
import javax.lang.model.element.AnnotationMirror;
1819
import javax.lang.model.element.AnnotationValue;
@@ -504,6 +505,6 @@ public Map<String,Set<String>> getEnumTypesByValue() {
504505
}
505506

506507
public void addEnumValue(String type, String value) {
507-
enumTypesByValue.computeIfAbsent( value, s -> new HashSet<>() ).add( type );
508+
enumTypesByValue.computeIfAbsent( value, s -> new TreeSet<>() ).add( type );
508509
}
509510
}

tooling/metamodel-generator/src/main/java/org/hibernate/processor/HibernateProcessor.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,12 @@ private void writeIndex() {
704704
final ProcessingEnvironment processingEnvironment = context.getProcessingEnvironment();
705705
context.getEntityNameMappings().forEach((entityName, className) -> {
706706
try (Writer writer = processingEnvironment.getFiler()
707-
.createResource(StandardLocation.SOURCE_OUTPUT, ENTITY_INDEX, entityName)
707+
.createResource(
708+
StandardLocation.SOURCE_OUTPUT,
709+
ENTITY_INDEX,
710+
entityName,
711+
processingEnvironment.getElementUtils().getTypeElement( className )
712+
)
708713
.openWriter()) {
709714
writer.append(className);
710715
}
@@ -715,8 +720,12 @@ private void writeIndex() {
715720
}
716721
});
717722
context.getEnumTypesByValue().forEach((valueName, enumTypeNames) -> {
718-
try (Writer writer = processingEnvironment.getFiler()
719-
.createResource(StandardLocation.SOURCE_OUTPUT, ENTITY_INDEX, '.' + valueName)
723+
try (Writer writer = processingEnvironment.getFiler().createResource(
724+
StandardLocation.SOURCE_OUTPUT,
725+
ENTITY_INDEX,
726+
'.' + valueName,
727+
processingEnvironment.getElementUtils().getTypeElement( enumTypeNames.iterator().next() )
728+
)
720729
.openWriter()) {
721730
for (String enumTypeName : enumTypeNames) {
722731
writer.append(enumTypeName).append(" ");

tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/DataMetaAttributeGenerationVisitor.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.checkerframework.checker.nullness.qual.Nullable;
1010
import org.hibernate.processor.Context;
1111
import org.hibernate.processor.util.Constants;
12+
import org.hibernate.processor.util.NullnessUtil;
1213

1314
import javax.lang.model.element.Element;
1415
import javax.lang.model.element.TypeElement;
@@ -72,7 +73,7 @@ private Types typeUtils() {
7273
public @Nullable DataAnnotationMetaAttribute visitDeclared(DeclaredType declaredType, Element element) {
7374
final TypeElement returnedElement = (TypeElement) typeUtils().asElement( declaredType );
7475
// WARNING: .toString() is necessary here since Name equals does not compare to String
75-
final String returnTypeName = returnedElement.getQualifiedName().toString();
76+
final String returnTypeName = NullnessUtil.castNonNull( returnedElement ).getQualifiedName().toString();
7677
final String collection = Constants.COLLECTIONS.get( returnTypeName );
7778
final String targetEntity = getTargetEntity( element.getAnnotationMirrors() );
7879
if ( collection != null ) {

tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/MetaAttributeGenerationVisitor.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.hibernate.processor.util.AccessType;
1212
import org.hibernate.processor.util.AccessTypeInformation;
1313
import org.hibernate.processor.util.Constants;
14+
import org.hibernate.processor.util.NullnessUtil;
1415

1516
import javax.lang.model.element.AnnotationMirror;
1617
import javax.lang.model.element.Element;
@@ -84,8 +85,9 @@ private Types typeUtils() {
8485
@Override
8586
public @Nullable AnnotationMetaAttribute visitDeclared(DeclaredType declaredType, Element element) {
8687
final TypeElement returnedElement = (TypeElement) typeUtils().asElement( declaredType );
88+
assert returnedElement != null;
8789
// WARNING: .toString() is necessary here since Name equals does not compare to String
88-
final String returnTypeName = returnedElement.getQualifiedName().toString();
90+
final String returnTypeName = NullnessUtil.castNonNull( returnedElement ).getQualifiedName().toString();
8991
final String collection = Constants.COLLECTIONS.get( returnTypeName );
9092
final String targetEntity = getTargetEntity( element.getAnnotationMirrors() );
9193
if ( collection != null ) {
@@ -109,7 +111,7 @@ private AnnotationMetaAttribute createMetaCollectionAttribute(
109111
getCollectionElementType( declaredType, returnTypeName, explicitTargetEntity, context );
110112
if ( collectionElementType.getKind() == TypeKind.DECLARED ) {
111113
final TypeElement collectionElement = (TypeElement) typeUtils().asElement( collectionElementType );
112-
setAccessType( collectionElementType, collectionElement );
114+
setAccessType( collectionElementType, NullnessUtil.castNonNull( collectionElement ) );
113115
}
114116
}
115117
return createMetaAttribute( declaredType, element, collection, targetEntity );

tooling/metamodel-generator/src/main/java/org/hibernate/processor/util/BasicAttributeVisitor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77
package org.hibernate.processor.util;
88

9+
import org.hibernate.internal.util.NullnessUtil;
910
import org.hibernate.processor.Context;
10-
import org.hibernate.processor.util.Constants;
1111

1212
import javax.lang.model.element.Element;
1313
import javax.lang.model.element.ElementKind;
@@ -46,7 +46,7 @@ public Boolean visitPrimitive(PrimitiveType primitiveType, Element element) {
4646
public Boolean visitArray(ArrayType arrayType, Element element) {
4747
final TypeElement componentElement = (TypeElement)
4848
context.getTypeUtils().asElement( arrayType.getComponentType() );
49-
return BASIC_ARRAY_TYPES.contains( componentElement.getQualifiedName().toString() );
49+
return BASIC_ARRAY_TYPES.contains( NullnessUtil.castNonNull( componentElement ).getQualifiedName().toString() );
5050
}
5151

5252
@Override

tooling/metamodel-generator/src/main/java/org/hibernate/processor/util/TypeUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ static class EmbeddedAttributeVisitor extends SimpleTypeVisitor8<@Nullable TypeE
665665
public @Nullable TypeElement visitDeclared(DeclaredType declaredType, Element element) {
666666
final TypeElement returnedElement = (TypeElement)
667667
context.getTypeUtils().asElement( declaredType );
668-
return containsAnnotation( returnedElement, EMBEDDABLE ) ? returnedElement : null;
668+
return containsAnnotation( NullnessUtil.castNonNull( returnedElement ), EMBEDDABLE ) ? returnedElement : null;
669669
}
670670

671671
@Override

0 commit comments

Comments
 (0)