You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by un...@apache.org on 2003/12/08 11:00:02 UTC

cvs commit: cocoon-2.1/src/blocks/repository/java/org/apache/cocoon/generation TraversableGenerator.java

unico       2003/12/08 02:00:02

  Modified:    src/blocks/repository/java/org/apache/cocoon/generation
                        TraversableGenerator.java
  Log:
  avoid hard to-find class cast exceptions
  
  Revision  Changes    Path
  1.7       +6 -4      cocoon-2.1/src/blocks/repository/java/org/apache/cocoon/generation/TraversableGenerator.java
  
  Index: TraversableGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/repository/java/org/apache/cocoon/generation/TraversableGenerator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TraversableGenerator.java	24 Nov 2003 22:05:22 -0000	1.6
  +++ TraversableGenerator.java	8 Dec 2003 10:00:02 -0000	1.7
  @@ -57,6 +57,7 @@
   import org.apache.cocoon.components.source.SourceUtil;
   import org.apache.cocoon.components.source.impl.MultiSourceValidity;
   import org.apache.cocoon.environment.SourceResolver;
  +import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceException;
   import org.apache.excalibur.source.SourceValidity;
   import org.apache.excalibur.source.TraversableSource;
  @@ -318,6 +319,10 @@
       public void generate() throws SAXException, ProcessingException {
           TraversableSource inputSource = null;
           try {
  +            Source src = this.resolver.resolveURI(this.source);
  +            if (!(src instanceof TraversableSource)) {
  +                throw new SourceException(this.source + " is not a traversable source");
  +            }
               inputSource = (TraversableSource) this.resolver.resolveURI(this.source);
   
               if (!inputSource.exists()) {
  @@ -340,9 +345,6 @@
           } catch (IOException ioe) {
               throw new ResourceNotFoundException("Could not read collection "
                                                   + this.source, ioe);
  -        } catch (ClassCastException ce) {
  -            throw new ResourceNotFoundException(this.source
  -                                                + " is not a traversable source");
           } finally {
               this.resolver.release(inputSource);
           }