I think the conditional would not be necessary here, since getFeatureSource().getWorkingTree() will anyway return the appropriate WorkingTree depending on whether there's a transaction active or not. So a single line would be just as good: WorkingTree wtree = getFeatureSource().getWorkingTree().