Skip to content

Commit e6b978e

Browse files
committed
perf(hibernate processor): fix null errors
1 parent 05764c3 commit e6b978e

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ private static String writeGeneratedAnnotation(Metamodel entity, Context context
306306
private static String writeSuppressWarnings(Context context) {
307307
final StringBuilder annotation = new StringBuilder("@SuppressWarnings({");
308308
final String[] warnings = context.getSuppressedWarnings();
309+
if (warnings == null || warnings.length == 0) {
310+
return "@SuppressWarnings({})";
311+
}
309312
for (int i = 0; i < warnings.length; i++) {
310313
if ( i>0 ) {
311314
annotation.append(", ");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ private void createMetaModelClasses() {
513513

514514
for ( Metamodel aux : context.getMetaAuxiliaries() ) {
515515
if ( !context.isAlreadyGenerated(aux)
516-
&& !isClassRecordOrInterfaceType( aux.getElement().getEnclosingElement() ) ) {
516+
&& !isClassRecordOrInterfaceType( requireNonNull( aux.getElement().getEnclosingElement() ) ) ) {
517517
context.logMessage( Diagnostic.Kind.OTHER,
518518
"Writing metamodel for auxiliary '" + aux + "'" );
519519
ClassWriter.writeFile( aux, context );

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ else if ( hasAnnotation( method, JD_DELETE ) ) {
420420
queryMethods.add( method );
421421
}
422422
}
423-
else if ( method.getEnclosingElement().getKind().isInterface()
423+
else if ( requireNonNull( method.getEnclosingElement() ).getKind().isInterface()
424424
&& !method.isDefault()
425425
&& !method.getModifiers().contains(Modifier.PRIVATE)
426426
&& !isSessionGetter(method) ) {
@@ -1507,7 +1507,7 @@ else if ( typeUtils.isSameType( backType, element.asType() ) ) {
15071507
}
15081508

15091509
private boolean isPersistent(Element memberOfClass, AccessType membersKind) {
1510-
return ( entityAccessTypeInfo.getAccessType() == membersKind
1510+
return ( ( entityAccessTypeInfo != null && entityAccessTypeInfo.getAccessType() == membersKind )
15111511
|| determineAnnotationSpecifiedAccessType( memberOfClass ) != null )
15121512
&& !containsAnnotation( memberOfClass, TRANSIENT )
15131513
&& !memberOfClass.getModifiers().contains( Modifier.TRANSIENT )

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ private List<Attribute> updateElementAttributes(StartElement startElement) {
158158
while ( existingAttributesIterator.hasNext() ) {
159159
Attribute attribute = existingAttributesIterator.next();
160160
if ( VERSION_ATTRIBUTE_NAME.equals( attribute.getName().getLocalPart() ) ) {
161-
if ( currentDocumentNamespaceUri.equals( DEFAULT_PERSISTENCE_NAMESPACE ) ) {
161+
if ( currentDocumentNamespaceUri != null &&
162+
currentDocumentNamespaceUri.equals( DEFAULT_PERSISTENCE_NAMESPACE ) ) {
162163
if ( !DEFAULT_PERSISTENCE_VERSION.equals( attribute.getName().getPrefix() ) ) {
163164
newElementAttributeList.add(
164165
xmlEventFactory.createAttribute(

0 commit comments

Comments
 (0)