vgritsenko    2003/09/23 05:35:43

  Modified:    src/java/org/apache/cocoon/components/modules/input
                        XMLFileModule.java
  Log:
  Release source in finally.
  
  Revision  Changes    Path
  1.10      +33 -28    
cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java
  
  Index: XMLFileModule.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XMLFileModule.java        20 May 2003 09:17:57 -0000      1.9
  +++ XMLFileModule.java        23 Sep 2003 12:35:43 -0000      1.10
  @@ -147,43 +147,48 @@
           public synchronized Document getDocument(ComponentManager manager, 
                                                    SourceResolver resolver, 
                                                    Logger logger) throws 
Exception {
  -
               Source src = null;
  -            SourceValidity valid = null;
               Document dom = null;
  -
  -            if (this.document == null) {
  -                if (logger.isDebugEnabled())
  -                    logger.debug("document not cached... reloading uri 
"+this.uri);
  -                src = resolver.resolveURI(this.uri);
  -                this.srcVal = src.getValidity();
  -                this.document = SourceUtil.toDOM(src);
  -                dom = this.document;
  -                resolver.release(src);
  -            } else {
  -                if (this.reloadable) {
  -                    if (logger.isDebugEnabled())
  -                        logger.debug("document cached... checking validity 
of uri "+this.uri);
  +            try {
  +                if (this.document == null) {
  +                    if (logger.isDebugEnabled()) {
  +                        logger.debug("Document not cached... reloading uri " 
+ this.uri);
  +                    }
                       src = resolver.resolveURI(this.uri);
  -                    valid = src.getValidity();
  -                    if (srcVal != null && this.srcVal.isValid(valid) != 1) {
  -                        if (logger.isDebugEnabled())
  -                            logger.debug("reloading document... uri 
"+this.uri);
  -                        this.srcVal = valid;
  -                        this.document = SourceUtil.toDOM(src);
  +                    this.srcVal = src.getValidity();
  +                    this.document = SourceUtil.toDOM(src);
  +                    dom = this.document;
  +                } else {
  +                    if (this.reloadable) {
  +                        if (logger.isDebugEnabled()) {
  +                            logger.debug("Document cached... checking 
validity of uri " + this.uri);
  +                        }
  +                        src = resolver.resolveURI(this.uri);
  +                        SourceValidity valid = src.getValidity();
  +                        if (srcVal != null && this.srcVal.isValid(valid) != 
1) {
  +                            if (logger.isDebugEnabled())
  +                                logger.debug("reloading document... uri 
"+this.uri);
  +                            this.srcVal = valid;
  +                            this.document = SourceUtil.toDOM(src);
  +                        }
                       }
  -                    resolver.release(src);
  +                    dom = this.document;
                   }
  -                dom = this.document;
  +            } finally {
  +                resolver.release(src);
               }
  +
               if (!this.cacheable) {
  -                if (logger.isDebugEnabled())
  -                    logger.debug("not caching document cached... uri 
"+this.uri);
  +                if (logger.isDebugEnabled()) {
  +                    logger.debug("Not caching document cached... uri " + 
this.uri);
  +                }
                   this.srcVal = null;
                   this.document = null;
               }
  -            if (logger.isDebugEnabled())
  -                logger.debug("done with document... uri "+this.uri);
  +
  +            if (logger.isDebugEnabled()) {
  +                logger.debug("Done with document... uri " + this.uri);
  +            }
               return dom;
           }
       }
  
  
  

Reply via email to