Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded;
import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock;
import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper;
import org.hibernate.search.util.impl.test.SystemHelper;
import org.hibernate.search.util.impl.test.SystemHelper.SystemPropertyRestorer;
import org.hibernate.search.util.impl.test.annotation.TestForIssue;
import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog;

Expand Down Expand Up @@ -83,7 +85,7 @@ public void version() {
String propertyKey = "org.hibernate.search.version";
String expectedHibernateSearchVersion = System.getProperty( propertyKey );
if ( expectedHibernateSearchVersion == null ) {
throw new IllegalStateException( "This test can only be executed, because system property '"
throw new IllegalStateException( "This test cannot be executed, because system property '"
+ propertyKey + "' was not defined." );
}

Expand All @@ -101,6 +103,27 @@ public void version() {
assertThat( Version.getVersionString() ).isEqualTo( expectedHibernateSearchVersion );
}

@Test
@TestForIssue(jiraKey = "HSEARCH-4503")
public void versionLoggingDisabled() {
String propertyKey = "org.hibernate.search.version";
String expectedHibernateSearchVersion = System.getProperty( propertyKey );
if ( expectedHibernateSearchVersion == null ) {
throw new IllegalStateException( "This test cannot be executed, because system property '"
+ propertyKey + "' was not defined." );
}

try ( SystemPropertyRestorer systemPropertyChange = SystemHelper.setSystemProperty( "jboss.log-version", "false" ) ) {
logged.expectMessage( "HSEARCH000034" ).never();
logged.expectMessage( "Hibernate Search version" ).never();

backendMock.expectAnySchema( IndexedEntity.NAME );

ormSetupHelper.start()
.setup( IndexedEntity.class, ContainedEntity.class );
}
}

private static Matcher<? extends LogEvent> suspiciousLogEventMatcher() {
return new TypeSafeMatcher<LogEvent>() {
private final Level level = Level.WARN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.hibernate.search.engine.environment.bean.spi.BeanProvider;
import org.hibernate.search.mapper.orm.bootstrap.spi.HibernateOrmIntegrationBooterBehavior;
import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings;
import org.hibernate.search.mapper.orm.cfg.spi.HibernateOrmMapperSpiSettings;
import org.hibernate.search.mapper.orm.common.impl.HibernateOrmUtils;
import org.hibernate.search.mapper.orm.coordination.impl.CoordinationConfigurationContextImpl;
import org.hibernate.search.mapper.orm.logging.impl.Log;
Expand Down Expand Up @@ -63,6 +64,12 @@ public abstract class HibernateSearchPreIntegrationService implements Service, A
.withDefault( HibernateOrmMapperSettings.Defaults.ENABLED )
.build();

private static final ConfigurationProperty<Boolean> LOG_VERSION =
ConfigurationProperty.forKey( HibernateOrmMapperSpiSettings.JBOSS_LOG_VERSION )
.asBoolean()
.withDefault( HibernateOrmMapperSpiSettings.Defaults.JBOSS_LOG_VERSIONS )
.build();

public static class Contributor implements ServiceContributor {
@Override
public void contribute(StandardServiceRegistryBuilder serviceRegistryBuilder) {
Expand All @@ -88,7 +95,10 @@ public HibernateSearchPreIntegrationService initiateService(Map configurationVal
return null;
}
initiated = true;
log.version( Version.versionString() );

if ( LOG_VERSION.get( AllAwareConfigurationPropertySource.system() ) ) {
log.version( Version.versionString() );
}

ConfigurationPropertyChecker propertyChecker = ConfigurationPropertyChecker.create();
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ private HibernateOrmMapperSpiSettings() {
public static final String INTEGRATION_PARTIAL_BUILD_STATE =
PREFIX + Radicals.INTEGRATION_PARTIAL_BUILD_STATE;

public static final String JBOSS_LOG_VERSION =
// No Hibernate-specific prefix here; this controls the behavior of multiple JBoss libraries.
"jboss.log-version";

public static class Radicals {

private Radicals() {
Expand All @@ -34,6 +38,8 @@ public static final class Defaults {
private Defaults() {
}

public static final boolean JBOSS_LOG_VERSIONS = true;

}

}