Skip to content

Commit

Permalink
Fixed bugs SonarCloud complained about;
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasSchaub committed Dec 20, 2023
1 parent de8110a commit 95c5f3e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ private void expandFullEnvironments(List<IAtomContainer> fGroups) {
for(int i = 0; i < atomCount; i++) {
IAtom atom = fGroup.getAtom(i);

if(isDbg()) log.debug(String.format(" - Atom #%d:% - Expanding environment...", i));
if(isDbg()) log.debug(String.format(" - Atom #%d - Expanding environment...", i));
expandEnvironment(atom, fGroup);

int hCount = atom.getImplicitHydrogenCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ExecutorService;
Expand Down Expand Up @@ -138,6 +139,7 @@ public ErtlFunctionalGroupsFinderPerformanceSnapshotApp(String[] anArgs) throws
tmpExceptionsPrintWriter.println();
tmpExceptionsPrintWriter.flush();
tmpExceptionsPrintWriter.close();
ExecutorService executor = null;
try {
if (anArgs.length != 2) {
throw new IllegalArgumentException("Two arguments (a file name and the number of threads to use) are required.");
Expand Down Expand Up @@ -211,13 +213,14 @@ public ErtlFunctionalGroupsFinderPerformanceSnapshotApp(String[] anArgs) throws
IAtomContainer[] tmpMoleculesArrayForThread = Arrays.copyOfRange(this.moleculesArray, i, i + tmpNumberOfMoleculesPerThread);
tmpListOfThreads.add(new ExtractFunctionalGroupsTask(tmpMoleculesArrayForThread));
}
ExecutorService executor = Executors.newFixedThreadPool(this.numberOfThreadsToUse);
executor = Executors.newFixedThreadPool(this.numberOfThreadsToUse);
List<Future<Integer>> tmpFuturesList = new LinkedList<>();
long tmpStartTime = System.currentTimeMillis();
try {
tmpFuturesList = executor.invokeAll(tmpListOfThreads);
} catch (Exception ex) {
this.appendToLogfile(ex);
throw ex;
}
long tmpEndTime = System.currentTimeMillis();
tmpResultsPrintWriter.println("Divided molecules onto " + this.numberOfThreadsToUse
Expand All @@ -230,13 +233,17 @@ public ErtlFunctionalGroupsFinderPerformanceSnapshotApp(String[] anArgs) throws
}
tmpResultsPrintWriter.println(tmpExceptionsCounter + " molecules produced an exception.");
tmpResultsPrintWriter.flush();
executor.shutdown();
executor.close();
tmpResultsPrintWriter.println();
tmpResultsPrintWriter.flush();
tmpResultsPrintWriter.close();
} catch (Exception anException) {
this.appendToLogfile(anException);
anException.printStackTrace(System.err);
if (!Objects.isNull(executor)) {
executor.close();
}
Thread.currentThread().interrupt();
System.exit(1);
}
}
Expand Down Expand Up @@ -265,7 +272,9 @@ private IAtomContainer applyFiltersAndPreprocessing(IAtomContainer aMolecule) th
tmpBiggestFragment = tmpFragment;
}
}
aMolecule = tmpBiggestFragment;
if (!Objects.isNull(tmpBiggestFragment)) {
aMolecule = tmpBiggestFragment;
}
}
for (IAtom tmpAtom : aMolecule.atoms()) {
if (!this.nonMetallicAtomicNumbersSet.contains(tmpAtom.getAtomicNumber())) {
Expand Down

0 comments on commit 95c5f3e

Please sign in to comment.