Skip to content

Remove warnings #2116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 14, 2025
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ subprojects {

ext.publishScript = rootProject.rootDir.absolutePath + '/publish.gradle'

tasks.withType( JavaCompile ) {
tasks.withType( JavaCompile ).configureEach {
options.encoding = 'UTF-8'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,7 @@ else if ( action.performOnLazyProperty() && type.isEntityType() ) {
false
) );
}
else {
// Nothing to do, so just skip cascading to this lazy attribute.
continue;
}
// Nothing to do, so just skip cascading to this lazy attribute.
}
else {
Object child = persister.getValue( parent, i );
Expand Down Expand Up @@ -447,7 +444,7 @@ private static <T> CompletionStage<Void> cascadeLogicalOneToOneOrphanRemoval(
*
* @param type The type representing the attribute metadata
*
* @return True if the attribute represents a logical one to one association
* @return True if the attribute represents a logical one-to-one association
*/
private static boolean isLogicalOneToOne(Type type) {
return type.isEntityType() && ( (EntityType) type ).isLogicalOneToOne();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private ReactiveActionQueue actionQueue(EventSource session) {

/**
* Coordinates the processing necessary to get things ready for executions
* as db calls by preping the session caches and moving the appropriate
* as db calls by prepping the session caches and moving the appropriate
* entities and collections to their respective execution queues.
*
* @param event The flush event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
*/
package org.hibernate.reactive.id.impl;

import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;

import org.hibernate.reactive.id.ReactiveIdentifierGenerator;
import org.hibernate.reactive.session.ReactiveConnectionSupplier;

import io.vertx.core.Context;
import io.vertx.core.Vertx;
import io.vertx.core.net.impl.pool.CombinerExecutor;
import io.vertx.core.net.impl.pool.Executor;
import io.vertx.core.net.impl.pool.Task;

import org.hibernate.reactive.id.ReactiveIdentifierGenerator;
import org.hibernate.reactive.session.ReactiveConnectionSupplier;

import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;

import static org.hibernate.reactive.util.impl.CompletionStages.completedFuture;

/**
Expand Down Expand Up @@ -51,7 +51,7 @@ public abstract class BlockingIdentifierGenerator implements ReactiveIdentifierG
*/
protected abstract CompletionStage<Long> nextHiValue(ReactiveConnectionSupplier session);

//Not strictly necessary to put these fields into a dedicated class, but it help
//Not strictly necessary to put these fields into a dedicated class, but it helps
//to reason about what the current state is and what the CombinerExecutor is
//supposed to work on.
private static class GeneratorState {
Expand Down Expand Up @@ -138,7 +138,6 @@ public Task execute(GeneratorState state) {
// value in the table, so just increment the lo
// value and return the next id in the block
completedFuture( local ).whenComplete( this::acceptAsReturnValue );
return null;
}
else {
nextHiValue( connectionSupplier )
Expand All @@ -155,8 +154,8 @@ public Task execute(GeneratorState state) {
} );
}
} );
return null;
}
return null;
}

private void acceptAsReturnValue(final Long aLong, final Throwable throwable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import java.util.Properties;

import static org.hibernate.internal.util.config.ConfigurationHelper.getInt;
import static org.hibernate.internal.util.config.ConfigurationHelper.getString;

/**
Expand Down Expand Up @@ -71,16 +70,6 @@ protected String determineSegmentValue(Properties params) {
return null;
}

@Override
protected int determineInitialValue(Properties params) {
return getInt( SequenceStyleGenerator.INITIAL_PARAM, params, SequenceStyleGenerator.DEFAULT_INITIAL_VALUE );
}

@Override
protected int determineIncrement(Properties params) {
return getInt( SequenceStyleGenerator.INCREMENT_PARAM, params, SequenceStyleGenerator.DEFAULT_INCREMENT_SIZE );
}

@Override
protected Object[] updateParameters(long currentValue, long updatedValue) {
return new Object[] { updatedValue, currentValue };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.boot.model.relational.Database;
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
import org.hibernate.dialect.CockroachDialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.OracleDialect;
Expand Down Expand Up @@ -189,14 +187,6 @@ protected CompletionStage<Long> nextHiValue(ReactiveConnectionSupplier session)
} );
}

@Override
public void registerExportables(Database database) {
}

@Override
public void initialize(SqlStringGenerationContext context) {
}

@Override
public Object generate(SharedSessionContractImplementor session, Object object) throws HibernateException {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public ReactiveMultiIdEntityLoaderArrayParam(
EntityMappingType entityDescriptor,
SessionFactoryImplementor sessionFactory) {
super( entityDescriptor, sessionFactory );
final Class<?> arrayClass = createTypedArray( 0 ).getClass();
final Class<?> idClass = getIdentifierMapping().getJavaType().getJavaTypeClass();
arrayJdbcMapping = resolveArrayJdbcMapping(
getIdentifierMapping().getJdbcMapping(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public EntityMappingType getLoadable() {
public CompletionStage<T> load(Object pkValue, LockOptions lockOptions, Boolean readOnly, SharedSessionContractImplementor session) {
// noinspection unchecked
final QueryImplementor<T> query = namedQueryMemento
.toQuery( session, (Class<T>) entityDescriptor.getMappedJavaType().getJavaTypeClass() );
.toQuery( session, entityDescriptor.getMappedJavaType().getJavaTypeClass() );

//noinspection unchecked
query.setParameter( (Parameter<Object>) query.getParameters().iterator().next(), pkValue );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public CompletionStage<T> load(Object restrictedValue, Object entityInstance, Bo
} );
}

private <T> void invokeAfterLoadActions(Callback callback, SharedSessionContractImplementor session, T entity) {
private <G> void invokeAfterLoadActions(Callback callback, SharedSessionContractImplementor session, G entity) {
if ( entity != null && getLoadable() != null) {
callback.invokeAfterLoadActions( entity, (EntityMappingType) getLoadable(), session );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.hibernate.generator.values.GeneratedValues;
import org.hibernate.loader.ast.spi.MultiIdLoadOptions;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.reactive.persister.entity.mutation.ReactiveInsertCoordinator;

import jakarta.persistence.metamodel.Attribute;

Expand All @@ -33,7 +34,7 @@ public interface ReactiveEntityPersister extends EntityPersister {
* @see EntityPersister#insert(Object, Object[], Object, SharedSessionContractImplementor)
*/
default CompletionStage<GeneratedValues> insertReactive(Object id, Object[] fields, Object object, SharedSessionContractImplementor session) {
return insertReactive( id, fields, object, session );
return ( (ReactiveInsertCoordinator) getInsertCoordinator() ).reactiveInsert( object, id, fields, session );
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,12 @@ protected void breakDownJdbcValue(
final String tableName = tableDetails.getTableName();
tableDetails.getKeyMapping().breakDownKeyJdbcValues(
id,
(jdbcValue, columnMapping) -> {
jdbcValueBindings.bindValue(
jdbcValue,
tableName,
columnMapping.getColumnName(),
ParameterUsage.SET
);
},
(jdbcValue, columnMapping) -> jdbcValueBindings.bindValue(
jdbcValue,
tableName,
columnMapping.getColumnName(),
ParameterUsage.SET
),
session
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import io.vertx.sqlclient.spi.Driver;

import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.toList;

/**
* A pool of reactive connections backed by a Vert.x {@link Pool}.
Expand Down Expand Up @@ -128,7 +127,7 @@ public void injectServices(ServiceRegistryImplementor serviceRegistry) {
}

@Override
public void configure(Map configuration) {
public void configure(Map<String, Object> configuration) {
uri = jdbcUrl( configuration );
}

Expand Down Expand Up @@ -247,7 +246,7 @@ private Driver findDriver(URI uri, ServiceConfigurationError originalError) {
if ( selected.size() > 1 ) {
List<String> driverClasses = selected.stream()
.map( driver -> driver.getClass().getCanonicalName() )
.collect( toList() );
.toList();
throw new ConfigurationException( "Multiple drivers found matching for URI scheme \"" + scheme + "\". Please, pick one: " + driverClasses, originalError );
}
return selected.get( 0 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,15 @@
if ( s.indexOf( '/' ) != -1 ) {
// Example: 1234/
s = s.substring( 0, s.indexOf( '/' ) );
return Integer.valueOf( s );
return Integer.parseInt( s );

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
}
if ( s.indexOf( '?' ) != -1 ) {
// Example: 1234?param=value
s = s.substring( 0, s.indexOf( '?' ) );
return Integer.valueOf( s );
return Integer.parseInt( s );

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
}
// Example: 1234
return Integer.valueOf( s );
return Integer.parseInt( s );

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
}
return -1;
}
Expand Down Expand Up @@ -330,7 +330,7 @@
if ( startOfPort == -1 ) {
return -1;
}
return Integer.valueOf( hostPortString.substring( startOfPort + 1 ) );
return Integer.parseInt( hostPortString.substring( startOfPort + 1 ) );

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
}

private String findHost(URI uri, String scheme) {
Expand All @@ -348,7 +348,7 @@
}

private int findPort(URI uri, String scheme) {
int port = -1;
int port;
if ( "oracle".equals( scheme ) ) {
port = oraclePort( uri );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public final class ExternalSqlClientPool extends SqlClientPool {

private final Pool pool;
private final SqlStatementLogger sqlStatementLogger;
private SqlExceptionHelper sqlExceptionHelper;
private final SqlExceptionHelper sqlExceptionHelper;

public ExternalSqlClientPool(Pool pool, SqlStatementLogger sqlStatementLogger, SqlExceptionHelper sqlExceptionHelper) {
this.pool = pool;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.hibernate.reactive.logging.impl.Log;
import org.hibernate.reactive.logging.impl.LoggerFactory;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;

/**
* Integrates Hibernate Reactive with Hibernate ORM by
Expand All @@ -47,10 +46,6 @@ public void integrate(Metadata metadata, BootstrapContext bootstrapContext, Sess
attachEventContextManagingListenersIfRequired( sessionFactory.getServiceRegistry() );
}

@Override
public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
}

private void attachEventContextManagingListenersIfRequired(ServiceRegistry serviceRegistry) {
if ( ReactiveModeCheck.isReactiveRegistry( serviceRegistry ) ) {
LOG.startHibernateReactive();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ protected boolean appendClauseAndParameterIfNotNullOrEmpty(
StringBuilder sb,
List<Object> parameters) {

if ( parameter != null && ( ! String.class.isInstance( parameter ) || ! ( (String) parameter ).isEmpty() ) ) {
if ( parameter != null && ( !( parameter instanceof String string ) || !string.isEmpty() ) ) {
parameters.add( parameter );
sb.append( clause );
sb.append( parameterMarker( parameters.size() ) );
Expand Down Expand Up @@ -351,7 +351,7 @@ protected String getDatabaseCatalogColumnName(String catalogColumnName, String s
* used for storing the schema name, or <code null/>, if there
* is no valid column containing the schema name.
* <p/>
* MySQL, for example, does not have a valid column in
* MySQL, for example, does not have a valid column
* in the information_schema to store the schema name.
* (@see MySqlReactiveInformationExtractorImpl)
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ protected int dataTypeCode(String typeName) {
}
}

@Override
protected String getResultSetTableTypesPhysicalTableConstant() {
return "BASE TABLE";
}

protected String getDatabaseCatalogColumnName(String catalogColumnName, String schemaColumnName ) {
return schemaColumnName;
}
Expand All @@ -64,7 +59,7 @@ protected <T> T processPrimaryKeysResultSet(
String catalogFilter,
String schemaFilter,
Identifier tableName,
ExtractionContext.ResultSetProcessor<T> processor) throws SQLException {
ExtractionContext.ResultSetProcessor<T> processor) {
// This functionality is not used by ORM.
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,12 @@ public PostgreSqlReactiveInformationExtractorImpl(ExtractionContext extractionCo
super( extractionContext );
}

@Override
protected String getResultSetTableTypesPhysicalTableConstant() {
return "BASE TABLE";
}

@Override
protected <T> T processPrimaryKeysResultSet(
String catalogFilter,
String schemaFilter,
Identifier tableName,
ExtractionContext.ResultSetProcessor<T> processor) throws SQLException {
ExtractionContext.ResultSetProcessor<T> processor) {
// This functionality is not used by ORM.
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected <T> T processPrimaryKeysResultSet(
String catalogFilter,
String schemaFilter,
Identifier tableName,
ExtractionContext.ResultSetProcessor<T> processor) throws SQLException {
ExtractionContext.ResultSetProcessor<T> processor) {
throw new UnsupportedOperationException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,4 @@ public boolean isDropIdTables() {
public void setDropIdTables(boolean dropIdTables) {
this.dropIdTables = dropIdTables;
}

@Override
public CompletionStage<Void> getDropTableActionStage() {
return tableDroppedStage;
}

@Override
public CompletionStage<Void> getCreateTableActionStage() {
return tableCreatedStage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,6 @@ public CompletionStage<Integer> reactiveExecuteDelete(
).reactiveExecute( context ) );
}

@Override
public CompletionStage<Void> getDropTableActionStage() {
return tableDroppedStage;
}

@Override
public CompletionStage<Void> getCreateTableActionStage() {
return tableCreatedStage;
}

@Override
public boolean isPrepared() {
return prepared;
Expand Down
Loading
Loading