void () { BuildDataCorruptedException error = null; synchronized (myLock) { for (CloseableMaplet maplet : Arrays.asList(myClassToSubclasses, myClassToClassDependency, myRelativeSourceFilePathToClasses, myClassToRelativeSourceFilePath, myShortClassNameIndex)) { if (maplet != null) { try { maplet.close(); } catch (BuildDataCorruptedException ex) { if (error == null) { error = ex; } } } } if (!myIsDelta) { // only close if you own the context final DependencyContext context = myContext; if (context != null) { try { context.close(); } catch (BuildDataCorruptedException ex) { if (error == null) { error = ex; } } myContext = null; } } } if (error != null) { throw error; } }