Skip to content

Commit 1e1269b

Browse files
committed
Remove IDEA warnings
A mischellaneous collection of fixes for warnings that I've noticed working on this issue.
1 parent 306da48 commit 1e1269b

23 files changed

+38
-83
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ subprojects {
7373

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

76-
tasks.withType( JavaCompile ) {
76+
tasks.withType( JavaCompile ).configureEach {
7777
options.encoding = 'UTF-8'
7878
}
7979

hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/Cascade.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,7 @@ else if ( action.performOnLazyProperty() && type.isEntityType() ) {
235235
false
236236
) );
237237
}
238-
else {
239-
// Nothing to do, so just skip cascading to this lazy attribute.
240-
continue;
241-
}
238+
// Nothing to do, so just skip cascading to this lazy attribute.
242239
}
243240
else {
244241
Object child = persister.getValue( parent, i );

hibernate-reactive-core/src/main/java/org/hibernate/reactive/id/impl/BlockingIdentifierGenerator.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
*/
66
package org.hibernate.reactive.id.impl;
77

8+
import java.util.Objects;
9+
import java.util.concurrent.CompletableFuture;
10+
import java.util.concurrent.CompletionStage;
11+
12+
import org.hibernate.reactive.id.ReactiveIdentifierGenerator;
13+
import org.hibernate.reactive.session.ReactiveConnectionSupplier;
14+
815
import io.vertx.core.Context;
916
import io.vertx.core.Vertx;
1017
import io.vertx.core.net.impl.pool.CombinerExecutor;
1118
import io.vertx.core.net.impl.pool.Executor;
1219
import io.vertx.core.net.impl.pool.Task;
1320

14-
import org.hibernate.reactive.id.ReactiveIdentifierGenerator;
15-
import org.hibernate.reactive.session.ReactiveConnectionSupplier;
16-
17-
import java.util.Objects;
18-
import java.util.concurrent.CompletableFuture;
19-
import java.util.concurrent.CompletionStage;
20-
2121
import static org.hibernate.reactive.util.impl.CompletionStages.completedFuture;
2222

2323
/**
@@ -138,7 +138,6 @@ public Task execute(GeneratorState state) {
138138
// value in the table, so just increment the lo
139139
// value and return the next id in the block
140140
completedFuture( local ).whenComplete( this::acceptAsReturnValue );
141-
return null;
142141
}
143142
else {
144143
nextHiValue( connectionSupplier )
@@ -155,8 +154,8 @@ public Task execute(GeneratorState state) {
155154
} );
156155
}
157156
} );
158-
return null;
159157
}
158+
return null;
160159
}
161160

162161
private void acceptAsReturnValue(final Long aLong, final Throwable throwable) {

hibernate-reactive-core/src/main/java/org/hibernate/reactive/id/impl/EmulatedSequenceReactiveIdentifierGenerator.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import java.util.Properties;
2121

22-
import static org.hibernate.internal.util.config.ConfigurationHelper.getInt;
2322
import static org.hibernate.internal.util.config.ConfigurationHelper.getString;
2423

2524
/**
@@ -71,16 +70,6 @@ protected String determineSegmentValue(Properties params) {
7170
return null;
7271
}
7372

74-
@Override
75-
protected int determineInitialValue(Properties params) {
76-
return getInt( SequenceStyleGenerator.INITIAL_PARAM, params, SequenceStyleGenerator.DEFAULT_INITIAL_VALUE );
77-
}
78-
79-
@Override
80-
protected int determineIncrement(Properties params) {
81-
return getInt( SequenceStyleGenerator.INCREMENT_PARAM, params, SequenceStyleGenerator.DEFAULT_INCREMENT_SIZE );
82-
}
83-
8473
@Override
8574
protected Object[] updateParameters(long currentValue, long updatedValue) {
8675
return new Object[] { updatedValue, currentValue };

hibernate-reactive-core/src/main/java/org/hibernate/reactive/id/impl/TableReactiveIdentifierGenerator.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
import org.hibernate.HibernateException;
1313
import org.hibernate.LockMode;
1414
import org.hibernate.LockOptions;
15-
import org.hibernate.boot.model.relational.Database;
16-
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
1715
import org.hibernate.dialect.CockroachDialect;
1816
import org.hibernate.dialect.Dialect;
1917
import org.hibernate.dialect.OracleDialect;
@@ -189,14 +187,6 @@ protected CompletionStage<Long> nextHiValue(ReactiveConnectionSupplier session)
189187
} );
190188
}
191189

192-
@Override
193-
public void registerExportables(Database database) {
194-
}
195-
196-
@Override
197-
public void initialize(SqlStringGenerationContext context) {
198-
}
199-
200190
@Override
201191
public Object generate(SharedSessionContractImplementor session, Object object) throws HibernateException {
202192
throw new UnsupportedOperationException();

hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveMultiIdEntityLoaderArrayParam.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public ReactiveMultiIdEntityLoaderArrayParam(
6565
EntityMappingType entityDescriptor,
6666
SessionFactoryImplementor sessionFactory) {
6767
super( entityDescriptor, sessionFactory );
68-
final Class<?> arrayClass = createTypedArray( 0 ).getClass();
6968
final Class<?> idClass = getIdentifierMapping().getJavaType().getJavaTypeClass();
7069
arrayJdbcMapping = resolveArrayJdbcMapping(
7170
getIdentifierMapping().getJdbcMapping(),

hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdEntityLoaderProvidedQueryImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public EntityMappingType getLoadable() {
4646
public CompletionStage<T> load(Object pkValue, LockOptions lockOptions, Boolean readOnly, SharedSessionContractImplementor session) {
4747
// noinspection unchecked
4848
final QueryImplementor<T> query = namedQueryMemento
49-
.toQuery( session, (Class<T>) entityDescriptor.getMappedJavaType().getJavaTypeClass() );
49+
.toQuery( session, entityDescriptor.getMappedJavaType().getJavaTypeClass() );
5050

5151
//noinspection unchecked
5252
query.setParameter( (Parameter<Object>) query.getParameters().iterator().next(), pkValue );

hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdLoadPlan.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public CompletionStage<T> load(Object restrictedValue, Object entityInstance, Bo
8181
} );
8282
}
8383

84-
private <T> void invokeAfterLoadActions(Callback callback, SharedSessionContractImplementor session, T entity) {
84+
private <G> void invokeAfterLoadActions(Callback callback, SharedSessionContractImplementor session, G entity) {
8585
if ( entity != null && getLoadable() != null) {
8686
callback.invokeAfterLoadActions( entity, (EntityMappingType) getLoadable(), session );
8787
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/impl/ReactiveEntityPersister.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.hibernate.generator.values.GeneratedValues;
1717
import org.hibernate.loader.ast.spi.MultiIdLoadOptions;
1818
import org.hibernate.persister.entity.EntityPersister;
19+
import org.hibernate.reactive.persister.entity.mutation.ReactiveInsertCoordinator;
1920

2021
import jakarta.persistence.metamodel.Attribute;
2122

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

3940
/**

hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/mutation/ReactiveInsertCoordinatorStandard.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,12 @@ protected void breakDownJdbcValue(
435435
final String tableName = tableDetails.getTableName();
436436
tableDetails.getKeyMapping().breakDownKeyJdbcValues(
437437
id,
438-
(jdbcValue, columnMapping) -> {
439-
jdbcValueBindings.bindValue(
440-
jdbcValue,
441-
tableName,
442-
columnMapping.getColumnName(),
443-
ParameterUsage.SET
444-
);
445-
},
438+
(jdbcValue, columnMapping) -> jdbcValueBindings.bindValue(
439+
jdbcValue,
440+
tableName,
441+
columnMapping.getColumnName(),
442+
ParameterUsage.SET
443+
),
446444
session
447445
);
448446
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/pool/impl/DefaultSqlClientPool.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import io.vertx.sqlclient.spi.Driver;
3838

3939
import static java.util.Collections.singletonList;
40-
import static java.util.stream.Collectors.toList;
4140

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

130129
@Override
131-
public void configure(Map configuration) {
130+
public void configure(Map<String, Object> configuration) {
132131
uri = jdbcUrl( configuration );
133132
}
134133

@@ -247,7 +246,7 @@ private Driver findDriver(URI uri, ServiceConfigurationError originalError) {
247246
if ( selected.size() > 1 ) {
248247
List<String> driverClasses = selected.stream()
249248
.map( driver -> driver.getClass().getCanonicalName() )
250-
.collect( toList() );
249+
.toList();
251250
throw new ConfigurationException( "Multiple drivers found matching for URI scheme \"" + scheme + "\". Please, pick one: " + driverClasses, originalError );
252251
}
253252
return selected.get( 0 );

hibernate-reactive-core/src/main/java/org/hibernate/reactive/pool/impl/DefaultSqlClientPoolConfiguration.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,15 @@ private int oraclePort(URI uri) {
232232
if ( s.indexOf( '/' ) != -1 ) {
233233
// Example: 1234/
234234
s = s.substring( 0, s.indexOf( '/' ) );
235-
return Integer.valueOf( s );
235+
return Integer.parseInt( s );
236236
}
237237
if ( s.indexOf( '?' ) != -1 ) {
238238
// Example: 1234?param=value
239239
s = s.substring( 0, s.indexOf( '?' ) );
240-
return Integer.valueOf( s );
240+
return Integer.parseInt( s );
241241
}
242242
// Example: 1234
243-
return Integer.valueOf( s );
243+
return Integer.parseInt( s );
244244
}
245245
return -1;
246246
}
@@ -330,7 +330,7 @@ private int extractPort(URI uri) {
330330
if ( startOfPort == -1 ) {
331331
return -1;
332332
}
333-
return Integer.valueOf( hostPortString.substring( startOfPort + 1 ) );
333+
return Integer.parseInt( hostPortString.substring( startOfPort + 1 ) );
334334
}
335335

336336
private String findHost(URI uri, String scheme) {
@@ -348,7 +348,7 @@ private String findHost(URI uri, String scheme) {
348348
}
349349

350350
private int findPort(URI uri, String scheme) {
351-
int port = -1;
351+
int port;
352352
if ( "oracle".equals( scheme ) ) {
353353
port = oraclePort( uri );
354354
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/pool/impl/ExternalSqlClientPool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public final class ExternalSqlClientPool extends SqlClientPool {
5959

6060
private final Pool pool;
6161
private final SqlStatementLogger sqlStatementLogger;
62-
private SqlExceptionHelper sqlExceptionHelper;
62+
private final SqlExceptionHelper sqlExceptionHelper;
6363

6464
public ExternalSqlClientPool(Pool pool, SqlStatementLogger sqlStatementLogger, SqlExceptionHelper sqlExceptionHelper) {
6565
this.pool = pool;

hibernate-reactive-core/src/main/java/org/hibernate/reactive/provider/impl/ReactiveIntegrator.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.hibernate.reactive.logging.impl.Log;
2929
import org.hibernate.reactive.logging.impl.LoggerFactory;
3030
import org.hibernate.service.ServiceRegistry;
31-
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
3231

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

50-
@Override
51-
public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
52-
}
53-
5449
private void attachEventContextManagingListenersIfRequired(ServiceRegistry serviceRegistry) {
5550
if ( ReactiveModeCheck.isReactiveRegistry( serviceRegistry ) ) {
5651
LOG.startHibernateReactive();

hibernate-reactive-core/src/main/java/org/hibernate/reactive/provider/service/AbstractReactiveInformationSchemaBasedExtractorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ protected boolean appendClauseAndParameterIfNotNullOrEmpty(
192192
StringBuilder sb,
193193
List<Object> parameters) {
194194

195-
if ( parameter != null && ( ! String.class.isInstance( parameter ) || ! ( (String) parameter ).isEmpty() ) ) {
195+
if ( parameter != null && ( !( parameter instanceof String ) || !( (String) parameter ).isEmpty() ) ) {
196196
parameters.add( parameter );
197197
sb.append( clause );
198198
sb.append( parameterMarker( parameters.size() ) );

hibernate-reactive-core/src/main/java/org/hibernate/reactive/provider/service/MySqlReactiveInformationExtractorImpl.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ protected int dataTypeCode(String typeName) {
4646
}
4747
}
4848

49-
@Override
50-
protected String getResultSetTableTypesPhysicalTableConstant() {
51-
return "BASE TABLE";
52-
}
53-
5449
protected String getDatabaseCatalogColumnName(String catalogColumnName, String schemaColumnName ) {
5550
return schemaColumnName;
5651
}
@@ -64,7 +59,7 @@ protected <T> T processPrimaryKeysResultSet(
6459
String catalogFilter,
6560
String schemaFilter,
6661
Identifier tableName,
67-
ExtractionContext.ResultSetProcessor<T> processor) throws SQLException {
62+
ExtractionContext.ResultSetProcessor<T> processor) {
6863
// This functionality is not used by ORM.
6964
throw new UnsupportedOperationException();
7065
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/provider/service/PostgreSqlReactiveInformationExtractorImpl.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,12 @@ public PostgreSqlReactiveInformationExtractorImpl(ExtractionContext extractionCo
3232
super( extractionContext );
3333
}
3434

35-
@Override
36-
protected String getResultSetTableTypesPhysicalTableConstant() {
37-
return "BASE TABLE";
38-
}
39-
4035
@Override
4136
protected <T> T processPrimaryKeysResultSet(
4237
String catalogFilter,
4338
String schemaFilter,
4439
Identifier tableName,
45-
ExtractionContext.ResultSetProcessor<T> processor) throws SQLException {
40+
ExtractionContext.ResultSetProcessor<T> processor) {
4641
// This functionality is not used by ORM.
4742
throw new UnsupportedOperationException();
4843
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/provider/service/SqlServerReactiveInformationExtractorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ protected <T> T processPrimaryKeysResultSet(
158158
String catalogFilter,
159159
String schemaFilter,
160160
Identifier tableName,
161-
ExtractionContext.ResultSetProcessor<T> processor) throws SQLException {
161+
ExtractionContext.ResultSetProcessor<T> processor) {
162162
throw new UnsupportedOperationException();
163163
}
164164

hibernate-reactive-core/src/main/java/org/hibernate/reactive/sql/exec/internal/ReactiveStandardMutationExecutorService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ public MutationExecutor createExecutor(
7272
}
7373

7474
private static GeneratedValuesMutationDelegate generatedValuesDelegate(MutationOperationGroup operationGroup) {
75-
GeneratedValuesMutationDelegate generatedValuesMutationDelegate = operationGroup.asEntityMutationOperationGroup() != null
75+
return operationGroup.asEntityMutationOperationGroup() != null
7676
? operationGroup.asEntityMutationOperationGroup().getMutationDelegate()
7777
: null;
78-
return generatedValuesMutationDelegate;
7978
}
8079
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/sql/results/internal/ReactiveInitializersList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ ReactiveInitializersList build(final Map<NavigablePath, Initializer<?>> initiali
8787
}
8888

8989
private Initializer<?>[] toArray(final ArrayList<Initializer<?>> initializers) {
90-
return initializers.toArray( new Initializer<?>[initializers.size()] );
90+
return initializers.toArray( new Initializer<?>[0] );
9191
}
9292
}
9393
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/sql/results/spi/ReactiveListResultsConsumer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,7 @@ public boolean addUnique(R result) {
284284
}
285285

286286
public boolean add(R result) {
287-
results.add( result );
288-
return true;
287+
return results.add( result );
289288
}
290289

291290
public List<R> getResults() {

hibernate-reactive-core/src/main/java/org/hibernate/reactive/util/impl/CompletionStages.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public R getResult() throws T {
301301
if ( throwable == null ) {
302302
return result;
303303
}
304-
throw (T) throwable;
304+
throw throwable;
305305
}
306306

307307
public CompletionStage<R> getResultAsCompletionStage() {
@@ -467,7 +467,7 @@ public static CompletionStage<Void> loop(int start, int end, IntPredicate filter
467467
}
468468

469469
public static CompletionStage<Void> whileLoop(Supplier<CompletionStage<Boolean>> loopSupplier) {
470-
return asyncWhile( loopSupplier::get );
470+
return asyncWhile( loopSupplier );
471471
}
472472

473473
public static CompletionStage<Void> whileLoop(Supplier<Boolean> whileCondition, Supplier<CompletionStage<?>> loopSupplier) {

hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/Json.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void nullSafeSet(PreparedStatement st, JsonObject value, int index, Share
6161

6262
@Override
6363
public JsonObject deepCopy(JsonObject value) {
64-
return value == null ? null : ( (JsonObject) value ).copy();
64+
return value == null ? null : value.copy();
6565
}
6666

6767
@Override

0 commit comments

Comments
 (0)