Skip to content

Commit

Permalink
server: improve initialization function, #TASK-5340
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Dec 5, 2023
1 parent 826b85c commit e7629e8
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,18 @@ public GenericRestWSServer(@PathParam("version") String version, @PathParam("spe
this.species = species;

try {
init();
if (!INITIALIZED.get()) {
init();
}
initQuery();
} catch (Exception e) {
throw new CellBaseServerException(e.getMessage());
}
}

private void init() throws IOException, CellBaseException {
private synchronized void init() throws IOException, CellBaseException {
// we need to make sure we only init one single time
if (INITIALIZED.compareAndSet(false, true)) {
if (!INITIALIZED.get()) {
SERVICE_START_DATE = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());
WATCH = new StopWatch();
WATCH.start();
Expand Down Expand Up @@ -168,6 +170,8 @@ private void init() throws IOException, CellBaseException {

// Initialize Monitor
monitor = new Monitor(cellBaseManagerFactory.getMetaManager());

INITIALIZED.set(true);
}
}

Expand Down

0 comments on commit e7629e8

Please sign in to comment.