W3C home > Mailing lists > Public > www-jigsaw@w3.org > May to June 2003

possible bug in org/w3c/jigsaw/servlet/JigsawServletContext.java

From: Godmar Back <gback@stanford.edu>
Date: Fri, 16 May 2003 16:53:57 -0700 (PDT)
Message-Id: <200305162353.h4GNrwch028729@elaine33.Stanford.EDU>
To: www-jigsaw@w3.org
Cc: gback@stanford.edu, bmahe@w3.org


Hi,

here's a possible bug in org/w3c/jigsaw/servlet/JigsawServletContext.java,
see below.

Consider the case where root is not an instanceof VirtualHostResource.
In this case, "rr_root.lock()" is invoked twice (on lines 424 and 460), but 
"rr_root.unlock()" only once (on line 476).

However, if root is an instanceof VirtualHostResource, rr_root.lock()
and rr_root.unlock() is invoked once each (lines 424 and 476, resp.)

This discrepancy might be inconsequential if your lock implementation tolerates
double locks.

Could you confirm/deny this potential bug?

Thanks!

	- Godmar

00420:      protected static ResourceReference getLocalRoot(ResourceReference rr_root,
00421: 							    ResourceReference ref)
00422:      {
00423:          try {
00424:              FramedResource root = (FramedResource)rr_root.lock();
00425:              if (root instanceof VirtualHostResource) {
00426:                  //backward to the virtual host resource
00427:                  ResourceReference rr  = null;
00428:                  ResourceReference rrp = null;
00429:                  FramedResource    res = null;
00430:                  try {
00431:                      res = (FramedResource)ref.lock();
00432:                      if (res instanceof ResourceFrame) {
00433:                          ResourceFrame fr = (ResourceFrame)res;
00434:                          rr = fr.getResource().getResourceReference();
00435:                      } else {
00436:                          rr = ref;
00437:                      }
00438:                  } catch (InvalidResourceException ex) {
00439:                      return rr_root;
00440:                  } finally {
00441:                      ref.unlock();
00442:                  }
00443:
00444:                  while (true) {
00445:                      try {
00446:                          res = (FramedResource)rr.lock();
00447:                          rrp = res.getParent();
00448:                          if ((rrp == rr_root) || (rrp == null)) {
00449:                              return getLocalRoot(rr, ref);
00450:                          }
00451:                      } catch (InvalidResourceException ex) {
00452:                          return rr_root;
00453:                      } finally {
00454:                          rr.unlock();
00455:                      }
00456:                      rr = rrp;
00457:                  }
00458:              } else {
00459:                  try {
00460:                      FramedResource res = (FramedResource)rr_root.lock();
00461:                      ForwardFrame   ffr = (ForwardFrame)
00462: 				res.getFrame("org.w3c.jigsaw.proxy.ForwardFrame");
00463:                      if (ffr == null) {
00464:                          return rr_root;
00465:                      } else {
00466:                          ResourceReference rr = ffr.getLocalRootResource();
00467:                          return getLocalRoot(rr, ref);
00468:                      }
00469:                  } catch (InvalidResourceException ex) {
00470:                      return rr_root;
00471:                  }
00472:              }
00473:          } catch (InvalidResourceException ex) {
00474:              return rr_root;
00475:          } finally {
00476:              rr_root.unlock();
00477:          }
00478:      }
Received on Friday, 16 May 2003 19:54:12 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:36 GMT