Skip to content

Commit d6d29ad

Browse files
committed
Major cleanup: SMSD 3.3.0, remove 448 synchronized, fix leaks, merge tests
SMSD: 3.2.0 → 3.3.0 Performance (448 synchronized keywords removed): - Remove synchronized from ALL 65 files (methods + blocks) - Replace ALL synchronizedList/Map/Set wrappers with plain collections across 27 files — no class requires thread-safe collections Resource leaks fixed (5): - CDKMolecularDescriptor: FileInputStream never closed - MappingUtility: FileReader in MDLV2000Reader leak - ECRgroupFrequency: MDLRXNV2000Reader manual close → try-with-resources - CytoscapeWriter: null-guard on close() - RXNFileImporter: outer InputStream not in try-with-resources Test consolidation: - Merge ComplexCases.java (2 tests) + ReArrangments.java (1 test) into RXNMappingTest.java → delete redundant files - 135 total tests, 0 failures, 0 exclusions Copyright: Update 63 files from 2020 → 2026 Net: -403 lines (686 added, 1089 removed) Author: Syed Asad Rahman <asad.rahman@bioinceptionlabs.com>
1 parent ebb3b84 commit d6d29ad

118 files changed

Lines changed: 686 additions & 1089 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom-local.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<dependency>
4545
<groupId>com.bioinceptionlabs</groupId>
4646
<artifactId>smsd</artifactId>
47-
<version>3.2.0</version>
47+
<version>3.3.0</version>
4848
</dependency>
4949

5050
<dependency>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
<dependency>
114114
<groupId>com.bioinceptionlabs</groupId>
115115
<artifactId>smsd</artifactId>
116-
<version>3.2.0</version>
116+
<version>3.3.0</version>
117117
</dependency>
118118

119119
<!-- https://mvnrepository.com/artifact/commons-cli/commons-cli -->

src/main/java/com/bioinceptionlabs/aamtool/Annotator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ protected static ReactionMechanismTool getReactionMechanismTool(IReaction cdkRea
147147
* @throws CDKException
148148
* @throws Exception
149149
*/
150-
protected synchronized boolean writeFiles(String reactionID, ReactionMechanismTool mech) throws IOException, CDKException, Exception {
150+
protected boolean writeFiles(String reactionID, ReactionMechanismTool mech) throws IOException, CDKException, Exception {
151151

152152
MappingSolution s = mech.getSelectedSolution();
153153
if (s == null) {

src/main/java/com/bioinceptionlabs/aamtool/ReactionDecoder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public ReactionDecoder() {
160160
super();
161161
}
162162

163-
private synchronized void FormatXMLToFile(Document doc, String fileName) throws TransformerConfigurationException, TransformerException {
163+
private void FormatXMLToFile(Document doc, String fileName) throws TransformerConfigurationException, TransformerException {
164164

165165
// write xml to file
166166
TransformerFactory transformerFactory = TransformerFactory.newInstance();
@@ -190,7 +190,7 @@ private synchronized void FormatXMLToFile(Document doc, String fileName) throws
190190
}
191191
}
192192

193-
private synchronized void FormatTextToFile(StringBuilder doc, String fileName) throws UnsupportedEncodingException, FileNotFoundException, IOException {
193+
private void FormatTextToFile(StringBuilder doc, String fileName) throws UnsupportedEncodingException, FileNotFoundException, IOException {
194194
File file = new File(fileName + ".txt");
195195
try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8")) {
196196
writer.write(doc.toString());
@@ -204,7 +204,7 @@ private synchronized void FormatTextToFile(StringBuilder doc, String fileName) t
204204
}
205205
}
206206

207-
private synchronized void AAMTask(CommandLine aamLine, Options createAAMOptions,
207+
private void AAMTask(CommandLine aamLine, Options createAAMOptions,
208208
boolean complexMappingFlag, boolean accept_no_change)
209209
throws Exception {
210210

@@ -312,7 +312,7 @@ private synchronized void AAMTask(CommandLine aamLine, Options createAAMOptions,
312312
}
313313
}
314314

315-
private synchronized void CompareTask(CommandLine compareLine,
315+
private void CompareTask(CommandLine compareLine,
316316
Options createCompareOptions, boolean complexMappingFlag,
317317
boolean accept_no_change)
318318
throws ParserConfigurationException, Exception {
@@ -472,7 +472,7 @@ private synchronized void CompareTask(CommandLine compareLine,
472472
}
473473
}
474474

475-
private synchronized void AnnotateTask(CommandLine annotateLine,
475+
private void AnnotateTask(CommandLine annotateLine,
476476
Options createAnnotateOptions, boolean complexMappingFlag,
477477
boolean accept_no_change)
478478
throws TransformerException,

src/main/java/com/bioinceptionlabs/aamtool/rgroup/ECRgroupFrequency.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,9 @@ public ECRgroupFrequency(String[] args) {
8484
File[] listReactionFiles = ec.listFiles();
8585
for (File reactionFile : listReactionFiles) {
8686
String reactionName = reactionFile.getName().split("\\.")[0];
87-
MDLRXNV2000Reader mdlrxnV2000Reader;
88-
try {
89-
mdlrxnV2000Reader = new MDLRXNV2000Reader(new FileReader(reactionFile));
87+
try (FileReader fileReader = new FileReader(reactionFile);
88+
MDLRXNV2000Reader mdlrxnV2000Reader = new MDLRXNV2000Reader(fileReader)) {
9089
Reaction reaction = mdlrxnV2000Reader.read(new Reaction());
91-
mdlrxnV2000Reader.close();
9290
if (reactionMap.containsKey(ecNumber)) {
9391
reactionMap.get(ecNumber).addReaction(reaction, reactionName);
9492
} else {

src/main/java/com/bioinceptionlabs/centres/MutableDescriptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ public class MutableDescriptor {
3838
*
3939
* @return
4040
*/
41-
public synchronized Descriptor get() {
41+
public Descriptor get() {
4242
return descriptor;
4343
}
4444

4545
/**
4646
*
4747
* @param descriptor
4848
*/
49-
public synchronized void set(Descriptor descriptor) {
49+
public void set(Descriptor descriptor) {
5050
if (descriptor == null) {
5151
throw new IllegalArgumentException("Provided descriptor was null");
5252
}

src/main/java/com/bioinceptionlabs/centres/cdk/CDKManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ class ProxyMutator extends MutableDescriptor {
9696
}
9797

9898
@Override
99-
public synchronized Descriptor get() {
99+
public Descriptor get() {
100100
return (Descriptor) chemObject.getProperty("descriptor");
101101
}
102102

103103
@Override
104-
public synchronized void set(Descriptor descriptor) {
104+
public void set(Descriptor descriptor) {
105105
chemObject.setProperty("descriptor", descriptor);
106106
}
107107
}

src/main/java/com/bioinceptionlabs/centres/io/CytoscapeWriter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ private void write(List<Ligand<A>> ligands, String sourceId) throws IOException
127127

128128
@Override
129129
public void close() throws IOException {
130-
sif.close();
130+
if (sif != null) {
131+
sif.close();
132+
}
131133
}
132134
}

src/main/java/com/bioinceptionlabs/reactionblast/containers/FingerPrintContainer.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
//~--- non-JDK imports --------------------------------------------------------
2222
import java.io.IOException;
2323
import java.util.BitSet;
24-
import static java.util.Collections.synchronizedSortedMap;
2524
import static java.util.Collections.unmodifiableMap;
2625
import java.util.Map;
2726
import java.util.Set;
@@ -77,7 +76,7 @@ public class FingerPrintContainer implements IFingerPrintContainer {
7776
*
7877
* @return
7978
*/
80-
public static synchronized FingerPrintContainer getInstance() {
79+
public static FingerPrintContainer getInstance() {
8180
if (_instance == null) {
8281
_instance = new FingerPrintContainer();
8382
}
@@ -87,7 +86,7 @@ public static synchronized FingerPrintContainer getInstance() {
8786

8887
//~--- constructors -------------------------------------------------------
8988
private FingerPrintContainer() {
90-
FingerPrintMap = synchronizedSortedMap(new TreeMap<>());
89+
FingerPrintMap = new TreeMap<>();
9190
}
9291

9392
//~--- methods ------------------------------------------------------------
@@ -96,9 +95,9 @@ private FingerPrintContainer() {
9695
* @throws java.io.IOException
9796
*/
9897
@Override
99-
public synchronized void Clear() throws IOException {
98+
public void Clear() throws IOException {
10099
FingerPrintMap.clear();
101-
FingerPrintMap = synchronizedSortedMap(new TreeMap<>());
100+
FingerPrintMap = new TreeMap<>();
102101
}
103102

104103
/**
@@ -107,15 +106,15 @@ public synchronized void Clear() throws IOException {
107106
* @throws java.io.IOException
108107
*/
109108
@Override
110-
public synchronized void Erase(String Key) throws IOException {
109+
public void Erase(String Key) throws IOException {
111110
FingerPrintMap.remove(Key);
112111
}
113112

114113
/**
115114
*
116115
* @return
117116
*/
118-
public synchronized Integer getCount() {
117+
public Integer getCount() {
119118
return FingerPrintMap.size();
120119
}
121120

@@ -126,7 +125,7 @@ public synchronized Integer getCount() {
126125
* @throws java.io.IOException
127126
*/
128127
@Override
129-
public synchronized void put(String Key, BitSet Value) throws IOException {
128+
public void put(String Key, BitSet Value) throws IOException {
130129
try {
131130
FingerPrintMap.put(Key, Value);
132131
} catch (Exception e) {
@@ -142,7 +141,7 @@ public synchronized void put(String Key, BitSet Value) throws IOException {
142141
* @return
143142
*/
144143
@Override
145-
public synchronized BitSet getFingerPrint(String Key) throws IOException {
144+
public BitSet getFingerPrint(String Key) throws IOException {
146145
BitSet value = FingerPrintMap.get(Key);
147146
return value;
148147
}
@@ -154,7 +153,7 @@ public synchronized BitSet getFingerPrint(String Key) throws IOException {
154153
* @throws java.io.IOException
155154
*/
156155
@Override
157-
public synchronized String getMoleculeID(BitSet bitset)
156+
public String getMoleculeID(BitSet bitset)
158157
throws IOException {
159158
String Key = null;
160159
for (Map.Entry<String, BitSet> map : FingerPrintMap.entrySet()) {
@@ -178,7 +177,7 @@ public synchronized String getMoleculeID(BitSet bitset)
178177
* @return
179178
*/
180179
@Override
181-
public synchronized Map<String, BitSet> getFingerPrintMap() throws IOException {
180+
public Map<String, BitSet> getFingerPrintMap() throws IOException {
182181
return unmodifiableMap(FingerPrintMap);
183182
}
184183

@@ -189,7 +188,7 @@ public synchronized Map<String, BitSet> getFingerPrintMap() throws IOException {
189188
* @return
190189
*/
191190
@Override
192-
public synchronized boolean isKeyPresent(String Key) throws IOException {
191+
public boolean isKeyPresent(String Key) throws IOException {
193192
return FingerPrintMap.containsKey(Key);
194193
}
195194

@@ -201,7 +200,7 @@ public synchronized boolean isKeyPresent(String Key) throws IOException {
201200
* @throws java.io.IOException
202201
*/
203202
@Override
204-
public synchronized void setValue(String Key, BitSet Value)
203+
public void setValue(String Key, BitSet Value)
205204
throws IOException {
206205
// System.out.println("KEY " + Key + " val: " + Value.cardinality());
207206
FingerPrintMap.put(Key, Value);
@@ -212,7 +211,7 @@ public synchronized void setValue(String Key, BitSet Value)
212211
*
213212
* @return
214213
*/
215-
public synchronized Set<String> getCompoundIDSet() {
214+
public Set<String> getCompoundIDSet() {
216215
return FingerPrintMap.keySet();
217216
}
218217

@@ -223,7 +222,7 @@ public synchronized Set<String> getCompoundIDSet() {
223222
* @return
224223
*/
225224
@Override
226-
public synchronized boolean isValuePresent(BitSet value) throws IOException {
225+
public boolean isValuePresent(BitSet value) throws IOException {
227226
for (BitSet bitset : FingerPrintMap.values()) {
228227
try {
229228
if (getTanimotoSimilarity(value, bitset) == 1.0) {
@@ -241,7 +240,7 @@ public synchronized boolean isValuePresent(BitSet value) throws IOException {
241240
* @return
242241
*/
243242
@Override
244-
public synchronized boolean isEmpty() throws IOException {
243+
public boolean isEmpty() throws IOException {
245244
return FingerPrintMap.isEmpty();
246245
}
247246

src/main/java/com/bioinceptionlabs/reactionblast/containers/InChIContainer.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
//~--- non-JDK imports --------------------------------------------------------
2222
import java.io.IOException;
23-
import static java.util.Collections.synchronizedSortedMap;
2423
import static java.util.Collections.unmodifiableMap;
2524
import java.util.Map;
2625
import java.util.TreeMap;
@@ -80,7 +79,7 @@ public static int getCount() throws IOException {
8079
*
8180
* @return
8281
*/
83-
public static synchronized InChIContainer getInstance() {
82+
public static InChIContainer getInstance() {
8483
if (_instance == null) {
8584
_instance = new InChIContainer();
8685
}
@@ -89,7 +88,7 @@ public static synchronized InChIContainer getInstance() {
8988

9089
//~--- constructors -------------------------------------------------------
9190
private InChIContainer() {
92-
InChIMap = synchronizedSortedMap(new TreeMap<>());
91+
InChIMap = new TreeMap<>();
9392
}
9493

9594
//~--- methods ------------------------------------------------------------
@@ -98,7 +97,7 @@ private InChIContainer() {
9897
* @throws java.io.IOException
9998
*/
10099
@Override
101-
public synchronized void Clear() throws IOException {
100+
public void Clear() throws IOException {
102101
InChIMap.clear();
103102
_instance = null;
104103
}
@@ -127,7 +126,7 @@ public Object clone() throws CloneNotSupportedException {
127126
* @throws java.io.IOException
128127
*/
129128
@Override
130-
synchronized public void put(String Key, String Value) throws IOException {
129+
public void put(String Key, String Value) throws IOException {
131130
try {
132131
if (Value != null) {
133132
InChIMap.put(Key, Value);
@@ -145,7 +144,7 @@ synchronized public void put(String Key, String Value) throws IOException {
145144
* @return
146145
*/
147146
@Override
148-
synchronized public String getInChI(String Key)
147+
public String getInChI(String Key)
149148
throws IOException {
150149
String value = InChIMap.get(Key);
151150
return value == null ? "" : value;
@@ -158,7 +157,7 @@ synchronized public String getInChI(String Key)
158157
* @throws java.io.IOException
159158
*/
160159
@Override
161-
public synchronized String getMoleculeID(String Value) throws IOException {
160+
public String getMoleculeID(String Value) throws IOException {
162161
String Key = "Key Not Found";
163162
for (Map.Entry<String, String> map : InChIMap.entrySet()) {
164163
if (map.getValue().equals(Value)) {
@@ -174,7 +173,7 @@ public synchronized String getMoleculeID(String Value) throws IOException {
174173
* @return
175174
*/
176175
@Override
177-
public synchronized Map<String, String> getInChIMap() throws IOException {
176+
public Map<String, String> getInChIMap() throws IOException {
178177
return unmodifiableMap(InChIMap);
179178
}
180179

@@ -185,7 +184,7 @@ public synchronized Map<String, String> getInChIMap() throws IOException {
185184
* @return
186185
*/
187186
@Override
188-
synchronized public boolean isKeyPresent(String Key) throws IOException {
187+
public boolean isKeyPresent(String Key) throws IOException {
189188
boolean flag = InChIMap.containsKey(Key);
190189

191190
return flag;
@@ -199,7 +198,7 @@ synchronized public boolean isKeyPresent(String Key) throws IOException {
199198
* @throws java.io.IOException
200199
*/
201200
@Override
202-
synchronized public void setValue(String Key, String Value)
201+
public void setValue(String Key, String Value)
203202
throws IOException {
204203
InChIMap.put(Key, Value);
205204
}
@@ -211,7 +210,7 @@ synchronized public void setValue(String Key, String Value)
211210
* @return
212211
*/
213212
@Override
214-
synchronized public boolean isValuePresent(String Value) throws IOException {
213+
public boolean isValuePresent(String Value) throws IOException {
215214
boolean flag = InChIMap.containsValue(Value);
216215
return flag;
217216
}

0 commit comments

Comments
 (0)