Skip to content

Commit

Permalink
ConcurrentReadFetchJoinWithUOWLocksTest fix to allow test threads to …
Browse files Browse the repository at this point in the history
…finish.

Signed-off-by: Radek Felcman <[email protected]>
  • Loading branch information
rfelcman committed Nov 20, 2024
1 parent 8bc344d commit 325f688
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -72,7 +72,7 @@ public void test(){
clonedPerson.setHobby(clonedProject);
uow.writeChanges();

Thread thread1 = new Thread(new ProjectReader(server.acquireClientSession(), project.getId()));
Thread thread1 = new Thread(new ProjectReader(server.acquireClientSession(), project.getId()), "Test Thread 1");
ConcurrentProject.RUNNING_TEST = ConcurrentProject.READ_WITH_UOW_LOCKS_TESTS;
//start reading Project, and have the thread wait while building DTF mappings
thread1.start();
Expand All @@ -84,7 +84,7 @@ public void test(){

//start uow commit, which will get locks on Person+Address, commit, then merge.
//merge should get a deferred lock on Project.
Thread thread2 = new Thread(new UOWCommit(uow));
Thread thread2 = new Thread(new UOWCommit(uow), "Test Thread 2");
thread2.start();

//while waiting, thread1 should wake and try to get a lock on Address. It will deadlock if it
Expand Down Expand Up @@ -112,7 +112,9 @@ public void verify(){
}

@Override
public void reset(){
public void reset() throws InterruptedException {
//To give threads from the test() chance to finish
Thread.sleep(1000);
ConcurrentProject.RUNNING_TEST = ConcurrentProject.NONE;
UnitOfWork uow = getSession().acquireUnitOfWork();

Expand Down

0 comments on commit 325f688

Please sign in to comment.