remm        01/10/11 17:28:53

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        LockMethod.java
  Log:
  - Fix NumberFormatException which can occur when parsing a timeout header
    like:
    Timeout: Second-300, Infinite
    Now, the portion after the first comma is ignored.
  
  Revision  Changes    Path
  1.22      +13 -5     
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java
  
  Index: LockMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- LockMethod.java   2001/09/13 08:14:07     1.21
  +++ LockMethod.java   2001/10/12 00:28:53     1.22
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v
 1.21 2001/09/13 08:14:07 juergen Exp $
  - * $Revision: 1.21 $
  - * $Date: 2001/09/13 08:14:07 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v
 1.22 2001/10/12 00:28:53 remm Exp $
  + * $Revision: 1.22 $
  + * $Date: 2001/10/12 00:28:53 $
    *
    * ====================================================================
    *
  @@ -226,9 +226,17 @@
           
           String lockDurationStr = req.getHeader("Timeout");
           if (lockDurationStr != null) {
  +            int firstCommaPos = lockDurationStr.indexOf(',');
  +            if (firstCommaPos != -1) {
  +                lockDurationStr = lockDurationStr.substring(0, firstCommaPos);
  +            }
               if (lockDurationStr.startsWith("Second-")) {
  -                lockDuration =
  -                    (new Integer(lockDurationStr.substring(7))).intValue();
  +                try {
  +                    lockDuration =
  +                        (new Integer(lockDurationStr.substring(7))).intValue();
  +                } catch (NumberFormatException e) {
  +                    lockDuration = MAX_TIMEOUT;
  +                }
               } else {
                   if (lockDurationStr.equalsIgnoreCase("infinity")) {
                       lockDuration = MAX_TIMEOUT;
  
  
  


Reply via email to