Skip to content
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

Do not assume the vert.x context will never switch threads legally #1586

Closed
wants to merge 1 commit into from
Closed
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 @@ -41,15 +41,4 @@ public static void assertUseOnEventLoop() {
}
}

public static void assertCurrentThreadMatches(Thread expectedThread) {
if ( ENFORCE && ( Thread.currentThread() != expectedThread ) ) {
throw LOG.detectedUsedOfTheSessionOnTheWrongThread(
expectedThread.getId(),
expectedThread.getName(),
Thread.currentThread().getId(),
Thread.currentThread().getName()
);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ public class ReactiveSessionImpl extends SessionImpl implements ReactiveSession,

private transient final ReactiveActionQueue reactiveActionQueue = new ReactiveActionQueue( this );
private ReactiveConnection reactiveConnection;
private final Thread associatedWorkThread;

//Lazily initialized
private transient ExceptionConverter exceptionConverter;
Expand All @@ -167,7 +166,6 @@ public ReactiveSessionImpl(
ReactiveConnection connection) {
super( delegate, options );
InternalStateAssertions.assertUseOnEventLoop();
this.associatedWorkThread = Thread.currentThread();
//matches configuration property "hibernate.jdbc.batch_size" :
Integer batchSize = getConfiguredJdbcBatchSize();
reactiveConnection = batchSize == null || batchSize < 2
Expand All @@ -182,22 +180,16 @@ public SessionImplementor getSharedContract() {

@Override
public Dialect getDialect() {
threadCheck();
return getJdbcServices().getDialect();
}

private void threadCheck() {
InternalStateAssertions.assertCurrentThreadMatches( associatedWorkThread );
}

@Override
protected StatefulPersistenceContext createPersistenceContext() {
return new ReactivePersistenceContextAdapter( this );
}

@Override
public ReactiveActionQueue getReactiveActionQueue() {
threadCheck();
return reactiveActionQueue;
}

Expand All @@ -217,7 +209,6 @@ public CompletionStage<Object> reactiveImmediateLoad(String entityName, Object i
// EntityPersister persister = getFactory().getMetamodel().entityPersister( entityName );
// log.debugf( "Initializing proxy: %s", MessageHelper.infoString( persister, id, getFactory() ) );
// }
threadCheck();
LoadEvent event = new LoadEvent(
id, entityName, true, this,
getReadOnlyFromLoadQueryInfluencers()
Expand Down Expand Up @@ -251,7 +242,6 @@ public CompletionStage<Object> reactiveInternalLoad(String entityName, Object id
: LoadEventListener.INTERNAL_LOAD_LAZY;
}

threadCheck();
LoadEvent event = new LoadEvent( id, entityName, true, this, getReadOnlyFromLoadQueryInfluencers() );
return fireLoadNoChecks( event, type )
.thenApply( v -> {
Expand Down Expand Up @@ -1778,15 +1768,6 @@ public Object getEntityId(Object entity) {
}
}

@Override
public void checkOpen() {
//The checkOpen check is invoked on all most used public API, making it an
//excellent hook to also check for the right thread to be used
//(which is an assertion so costs us nothing in terms of performance, after inlining).
threadCheck();
super.checkOpen();
}

@Override
public void removeOrphanBeforeUpdates(String entityName, Object child) {
throw new UnsupportedOperationException();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package org.hibernate.reactive.testing;

import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.CompletionException;
import java.util.concurrent.CompletionStage;

Expand Down