HHH-12519 - Use Forbidden APIs library (Gradle plugin) to check our use of APIs

- fixing failures in non-core projects
This commit is contained in:
Steve Ebersole 2018-05-12 21:22:42 -05:00
parent ad5f63bf64
commit 9f293b113b
8 changed files with 29 additions and 9 deletions

View File

@ -328,7 +328,7 @@ task forbiddenApisSystemOut(type: CheckForbiddenApis, dependsOn: compileJava) {
task forbiddenApisUnsafe(type: CheckForbiddenApis, dependsOn: compileJava) {
classesDirs = project.files( project.sourceSets.main.java.outputDir )
classpath = project.sourceSets.main.compileClasspath + project.sourceSets.main.runtimeClasspath
bundledSignatures += "jdk-unsafe-${project.targetCompatibility}".toString()
bundledSignatures += "jdk-unsafe-${baselineJavaVersion}".toString()
// unfortunately we currently have many uses of default Locale implicitly (~370) which need to be fixed
// before we can fully enabled this check

View File

@ -18,10 +18,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import org.hibernate.HibernateException;
import org.hibernate.boot.jaxb.Origin;
import org.hibernate.boot.jaxb.SourceType;
@ -34,9 +30,15 @@ import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.envers.configuration.internal.MappingCollector;
import org.hibernate.service.ServiceRegistry;
import org.jboss.jandex.IndexView;
import org.jboss.logging.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
/**
* @author Steve Ebersole
*/
@ -115,7 +117,7 @@ public class AdditionalJaxbMappingProducerImpl implements AdditionalJaxbMappingP
w.flush();
}
catch (IOException e1) {
e1.printStackTrace();
throw new RuntimeException( "Error dumping enhanced class", e1 );
}
log.tracef( "Envers-generate entity mapping -----------------------------\n%s", baos.toString() );

View File

@ -22,6 +22,7 @@ import org.hibernate.cfg.Environment;
import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator;
import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.internal.build.AllowSysOut;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.Stoppable;
@ -146,6 +147,7 @@ public class JtaAwareConnectionProviderImpl implements ConnectionProvider, Confi
return delegate.unwrap( unwrapType );
}
@AllowSysOut
private void delist(Connection connection) {
// todo : verify the incoming connection is the currently enlisted one?
try {

View File

@ -9,7 +9,10 @@ package org.hibernate.testing.junit4;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.function.Consumer;
import javax.persistence.SharedCacheMode;
@ -29,6 +32,7 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.internal.build.AllowSysOut;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jdbc.AbstractReturningWork;
@ -420,6 +424,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
}
@SuppressWarnings( {"UnnecessaryBoxing", "UnnecessaryUnboxing"})
@AllowSysOut
protected void assertAllDataRemoved() {
if ( !createSchema() ) {
return; // no tables were created...

View File

@ -36,6 +36,8 @@ import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.internal.build.AllowPrintStacktrace;
import org.hibernate.internal.build.AllowSysOut;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.jdbc.Work;
import org.hibernate.mapping.Collection;
@ -397,6 +399,8 @@ public class BaseNonConfigCoreFunctionalTestCase extends BaseUnitTestCase {
releaseResources();
}
@AllowSysOut
@AllowPrintStacktrace
protected void releaseResources() {
if ( sessionFactory != null ) {
try {
@ -508,6 +512,7 @@ public class BaseNonConfigCoreFunctionalTestCase extends BaseUnitTestCase {
}
@SuppressWarnings( {"UnnecessaryBoxing", "UnnecessaryUnboxing"})
@AllowSysOut
protected void assertAllDataRemoved() {
if ( !createSchema() ) {
return; // no tables were created...

View File

@ -13,6 +13,8 @@ import java.util.LinkedHashSet;
import java.util.List;
import org.hibernate.internal.SessionFactoryRegistry;
import org.hibernate.internal.build.AllowPrintStacktrace;
import org.hibernate.internal.build.AllowSysOut;
import org.hibernate.testing.AfterClassOnce;
import org.hibernate.testing.BeforeClassOnce;
@ -183,6 +185,8 @@ public class TestClassMetadata {
}
}
@AllowSysOut
@AllowPrintStacktrace
private void invokeCallback(Method callback, Object target) {
try {
performCallbackInvocation( callback, target );

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.testing.schema;
import java.io.FileWriter;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.sql.Connection;
@ -17,6 +16,7 @@ import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.internal.build.AllowSysOut;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.tool.schema.Action;
import org.hibernate.tool.schema.spi.DelayedDropRegistryNotAvailableImpl;
@ -70,6 +70,7 @@ public class SchemaCreateHelper {
);
}
@AllowSysOut
public static void toStdOut(Metadata metadata) {
toWriter( metadata, new OutputStreamWriter( System.out ) );
}

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.testing.schema;
import java.io.FileWriter;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Map;
@ -15,6 +14,7 @@ import org.hibernate.boot.Metadata;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.internal.build.AllowSysOut;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.tool.schema.Action;
import org.hibernate.tool.schema.spi.DelayedDropRegistryNotAvailableImpl;
@ -39,6 +39,7 @@ public class SchemaUpdateHelper {
);
}
@AllowSysOut
public static void toStdout(Metadata metadata) {
toWriter( metadata, new OutputStreamWriter( System.out ) );
}