HHH-13859 Avoid attempting to index a module-info.class via Jandex

This commit is contained in:
Sanne Grinovero 2020-02-11 12:44:04 +00:00
parent 5defe54d31
commit d3fdb657d6
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,24 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.boot.archive.scan.internal;
import org.hibernate.boot.archive.spi.ArchiveContext;
import org.hibernate.boot.archive.spi.ArchiveEntry;
import org.hibernate.boot.archive.spi.ArchiveEntryHandler;
public final class NoopEntryHandler implements ArchiveEntryHandler {
public static final ArchiveEntryHandler NOOP_INSTANCE = new NoopEntryHandler();
private NoopEntryHandler() {
//Use the singleton.
}
@Override
public void handleEntry(ArchiveEntry entry, ArchiveContext context) {
}
}

View File

@ -10,6 +10,7 @@ import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.hibernate.boot.archive.scan.internal.NoopEntryHandler;
import org.hibernate.boot.archive.scan.internal.ScanResultCollector;
import org.hibernate.boot.archive.spi.ArchiveContext;
import org.hibernate.boot.archive.spi.ArchiveDescriptor;
@ -132,6 +133,12 @@ public abstract class AbstractScannerImpl implements Scanner {
if ( nameWithinArchive.endsWith( "package-info.class" ) ) {
return packageEntryHandler;
}
else if ( nameWithinArchive.endsWith( "module-info.class" ) ) {
//There's two reasons to skip this: the most important one is that Jandex
//is unable to analyze them, so we need to dodge it.
//Secondarily, we have no use for these so let's save the effort.
return NoopEntryHandler.NOOP_INSTANCE;
}
else if ( nameWithinArchive.endsWith( ".class" ) ) {
return classEntryHandler;
}