Program: 70051
Project: 70051
Buggy source:
/** 
 * Binds a name to an object, along with associated attributes. If attrs is null, the resulting binding will have the attributes associated with obj if obj is a DirContext, and no attributes otherwise. If attrs is non-null, the resulting binding will have attrs as its attributes; any attributes associated with obj are ignored.
 * @param name the name to bind; may not be empty
 * @param obj the object to bind; possibly null
 * @param attrs the attributes to associate with the binding
 * @exception NameAlreadyBoundException if name is already bound
 * @exception InvalidAttributesException if some "mandatory" attributes of thebinding are not supplied
 * @exception NamingException if a naming exception is encountered
 */
public void bind(String name,Object obj,Attributes attrs) throws NamingException {
  VFSItem file=resolveFile(name);
  if (file != null)   throw new NameAlreadyBoundException(smgr.getString("String_Node_Str",name));
  int lastSlash=name.lastIndexOf('/');
  if (lastSlash == -1)   throw new NamingException();
  String parent=name.substring(0,lastSlash);
  VFSItem folder=resolveFile(parent);
  if (folder == null || (!(folder instanceof VFSContainer)))   throw new NamingException(smgr.getString("String_Node_Str",name));
  String newName=name.substring(lastSlash + 1);
  VFSLeaf childLeaf=((VFSContainer)folder).createChildLeaf(newName);
  if (childLeaf == null)   throw new NamingException(smgr.getString("String_Node_Str",name));
  copyVFS(childLeaf,name,obj,attrs);
  VFSSecurityCallback callback=folder.getLocalSecurityCallback();
  if (callback != null && callback.getSubscriptionContext() != null) {
    SubscriptionContext subContext=callback.getSubscriptionContext();
    NotificationsManager.getInstance().markPublisherNews(subContext,null);
  }
  if (childLeaf instanceof MetaTagged) {
    MetaInfo infos=((MetaTagged)childLeaf).getMetaInfo();
    if (infos != null && infos.getAuthorIdentity() == null) {
      infos.setAuthor(userSession.getIdentity().getName());
      infos.clearThumbnails();
      infos.write();
    }
  }
  if (obj instanceof VFSResource) {
    VFSResource vfsResource=(VFSResource)obj;
    if (vfsResource.vfsItem instanceof Versionable && ((Versionable)vfsResource.vfsItem).getVersions().isVersioned()) {
      Versionable currentVersion=(Versionable)vfsResource.vfsItem;
      VersionsManager.getInstance().move(currentVersion,childLeaf.getParentContainer());
    }
  }
}

Fixed version (ground truth):
/** 
 * Binds a name to an object, along with associated attributes. If attrs is null, the resulting binding will have the attributes associated with obj if obj is a DirContext, and no attributes otherwise. If attrs is non-null, the resulting binding will have attrs as its attributes; any attributes associated with obj are ignored.
 * @param name the name to bind; may not be empty
 * @param obj the object to bind; possibly null
 * @param attrs the attributes to associate with the binding
 * @exception NameAlreadyBoundException if name is already bound
 * @exception InvalidAttributesException if some "mandatory" attributes of thebinding are not supplied
 * @exception NamingException if a naming exception is encountered
 */
public void bind(String name,Object obj,Attributes attrs) throws NamingException {
  VFSItem file=resolveFile(name);
  if (file != null)   throw new NameAlreadyBoundException(smgr.getString("String_Node_Str",name));
  int lastSlash=name.lastIndexOf('/');
  if (lastSlash == -1)   throw new NamingException();
  String parent=name.substring(0,lastSlash);
  VFSItem folder=resolveFile(parent);
  if (folder == null || (!(folder instanceof VFSContainer)))   throw new NamingException(smgr.getString("String_Node_Str",name));
  String newName=name.substring(lastSlash + 1);
  VFSLeaf childLeaf=((VFSContainer)folder).createChildLeaf(newName);
  if (childLeaf == null)   throw new NamingException(smgr.getString("String_Node_Str",name));
  copyVFS(childLeaf,name,obj,attrs);
  VFSSecurityCallback callback=folder.getLocalSecurityCallback();
  if (callback != null && callback.getSubscriptionContext() != null) {
    SubscriptionContext subContext=callback.getSubscriptionContext();
    NotificationsManager.getInstance().markPublisherNews(subContext,null);
  }
  if (childLeaf instanceof MetaTagged) {
    MetaInfo infos=((MetaTagged)childLeaf).getMetaInfo();
    if (infos != null && infos.getAuthorIdentity() == null) {
      infos.setAuthor(userSession.getIdentity().getName());
      infos.clearThumbnails();
      infos.write();
    }
  }
  if (obj instanceof VFSResource) {
    VFSResource vfsResource=(VFSResource)obj;
    if (vfsResource.vfsItem instanceof Versionable && ((Versionable)vfsResource.vfsItem).getVersions().isVersioned()) {
      VFSLeaf currentVersion=(VFSLeaf)vfsResource.vfsItem;
      VersionsManager.getInstance().move(currentVersion,childLeaf,identity);
    }
  }
}