Permalink
Browse files

Tidied up implementation and added logging statement when an exceptio…

…n is thrown.
  • Loading branch information...
1 parent 15735a4 commit 24a981006f799060ec5b361f93899fc8b056272c @johnmay committed Nov 9, 2012
Showing with 13 additions and 8 deletions.
  1. +13 −8 src/main/org/openscience/cdk/graph/AtomContainerAtomPermutor.java
@@ -28,6 +28,7 @@
import org.openscience.cdk.Atom;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.tools.LoggingTool;
/**
@@ -79,21 +80,25 @@ public void initObjectArray()
IAtomContainer makeResult()
{
- IAtom[] atoms = new IAtom[objects.length];
+
+ IChemObjectBuilder builder = this.atomContainer.getBuilder();
+ IAtomContainer container = builder.newInstance(IAtomContainer.class,
+ this.atomContainer);
+
+
+ IAtom[] atoms = new IAtom[objects.length];
for (int f = 0; f < objects.length; f++)
{
atoms[f] = (IAtom) objects[f];
}
- IAtomContainer ac = atomContainer.getBuilder().newInstance(IAtomContainer.class,atomContainer);
- ac.setAtoms(atoms);
- IAtomContainer clone = null;
+ container.setAtoms(atoms);
+
try {
- clone = (IAtomContainer)ac.clone();
+ return container.clone();
} catch (CloneNotSupportedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ LoggingTool.create(getClass()).error("unable to clone container", e);
+ return null;
}
- return clone;
}
}

2 comments on commit 24a9810

I am tempting to decline this patch for now (for cdk-1.4.x anyway)... and since the documentation patch can need an update too...

Owner

johnmay replied Mar 23, 2013

LoggingTool++

Please sign in to comment.