cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jorg Heymans <jheym...@apache.org>
Subject Re: Trunk currently broken: UnknownHostException
Date Thu, 03 May 2007 18:26:44 GMT
Carsten Ziegeler wrote:

> That's strange, I don't have problems with the new version. Anyway, 
> afaik there is only one new feature in the latest version which should 
> fix a bug on macosx, so it should be very easy to fix this. What urls do 
> not work? Can you (or someone else) file a bug?

I can reproduce the bug by doing

mvn clean install -Dmaven.test.skip=true
cd core/cocoon-webapp
mvn jetty:run

then access localhost:8888 in browser

=======================

In case it helps, below is a diff of 2.2.1 and 2.2.2 sourcejars :


Only in 2.2.2/org/apache/excalibur/source: AvalonSourceUtil.java
diff -r -u 
2.2.1/org/apache/excalibur/source/ModifiableTraversableSource.java 
2.2.2/org/apache/excalibur/source/ModifiableTraversableSource.java
--- 2.2.1/org/apache/excalibur/source/ModifiableTraversableSource.java 
2007-05-03 20:08:08.000000000 +0200
+++ 2.2.2/org/apache/excalibur/source/ModifiableTraversableSource.java 
2007-05-03 20:08:22.000000000 +0200
@@ -19,7 +19,7 @@
  /**
   * A modifiable traversable source. This adds to {@link 
ModifiableSource} the
   * ability to create a directory.
- *
+ *
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development 
Team</a>
   * @version CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:26 $
   */
@@ -32,7 +32,7 @@
       * If the source already exists, this method does nothing if it's 
already
       * traversable, and fails otherwise.
       */
-    public void makeCollection() throws SourceException;
+    void makeCollection() throws SourceException;

  }

diff -r -u 2.2.1/org/apache/excalibur/source/SourceParameters.java 
2.2.2/org/apache/excalibur/source/SourceParameters.java
--- 2.2.1/org/apache/excalibur/source/SourceParameters.java	2007-05-03 
20:08:08.000000000 +0200
+++ 2.2.2/org/apache/excalibur/source/SourceParameters.java	2007-05-03 
20:08:22.000000000 +0200
@@ -95,6 +95,7 @@
       * children of the configuration.
       * If no children are available <code>null</code>
       * is returned.
+     * @deprecated Use {@link 
AvalonSourceUtil#createSourceParameters(Configuration)} instead.
       */
      public static SourceParameters create( Configuration conf )
      {
@@ -292,6 +293,8 @@
      /**
       * Create a Parameters object.
       * The first value of each parameter is added to the Parameters 
object.
+     * @deprecated Use {@link 
AvalonSourceUtil#getFirstParameters(SourceParameters)} or
+     *             {@link #getFirstParametersMap}.
       * @return An Parameters object - if no parameters are defined 
this is an
       *         empty object.
       */
@@ -309,6 +312,25 @@
      }

      /**
+     * Create a map object.
+     * The first value of each parameter is added to the map.
+     * @return A new map - if no parameters are defined this is an
+     *         empty map.
+     */
+    public Map getFirstParametersMap()
+    {
+        final Map result = new HashMap();
+        Iterator iter = this.getParameterNames();
+        String parName;
+        while( iter.hasNext() )
+        {
+            parName = (String)iter.next();
+            result.put( parName, this.getParameter( parName ) );
+        }
+        return result;
+    }
+
+    /**
       * Build a query string.
       * The query string can e.g. be used for http connections.
       * @return A query string which contains for each parameter/value pair
@@ -487,17 +509,17 @@
              this.names.remove( name );
          }
      }
-
+
      /**
-     * Returns an immutable java.util.Map containing parameter names as 
keys and
-     * parameter values as map values. The keys in the parameter map 
are of type String.
+     * Returns an immutable java.util.Map containing parameter names as 
keys and
+     * parameter values as map values. The keys in the parameter map 
are of type String.
       * The values in the parameter map are of type String array.
       */
-    public Map getParameterMap()
+    public Map getParameterMap()
      {
          final Map m = new HashMap(this.names);
          Iterator entries = m.entrySet().iterator();
-        while (entries.hasNext())
+        while (entries.hasNext())
          {
              Map.Entry entry = (Map.Entry)entries.next();
              ArrayList list = (ArrayList)entry.getValue();
diff -r -u 2.2.1/org/apache/excalibur/source/SourceUtil.java 
2.2.2/org/apache/excalibur/source/SourceUtil.java
--- 2.2.1/org/apache/excalibur/source/SourceUtil.java	2007-05-03 
20:08:08.000000000 +0200
+++ 2.2.2/org/apache/excalibur/source/SourceUtil.java	2007-05-03 
20:08:22.000000000 +0200
@@ -52,6 +52,7 @@
       * Append parameters to the uri.
       * Each parameter is appended to the uri with "parameter=value",
       * the parameters are separated by "&".
+     * @deprecated Use {@link AvalonSourceUtil#appendParameters(String, 
Parameters)} instead.
       */
      public static String appendParameters( String uri,
                                             Parameters parameters )
@@ -499,7 +500,7 @@
                                            destination.getURI()+
                                            "' is not writeable");
              }
-
+
              IOException firstE = null;
              ModifiableSource modDestination = 
(ModifiableSource)destination;
              try
@@ -519,7 +520,7 @@
                              // Remebver the original exception in case 
there are problems closing
                              //  any streams.
                              firstE = e;
-
+
                              // If possible, cancel the destination.
                              if ( modDestination.canCancel( out ) )
                              {
@@ -547,7 +548,7 @@
                      firstE = ioe;
                  }
              }
-
+
              // If there were any problems then wrap the original 
exception in a SourceException.
              if ( firstE != null )
              {
diff -r -u 2.2.1/org/apache/excalibur/source/SourceValidity.java 
2.2.2/org/apache/excalibur/source/SourceValidity.java
--- 2.2.1/org/apache/excalibur/source/SourceValidity.java	2007-05-03 
20:08:08.000000000 +0200
+++ 2.2.2/org/apache/excalibur/source/SourceValidity.java	2007-05-03 
20:08:22.000000000 +0200
@@ -44,10 +44,8 @@
  {
      final int VALID   = +1;
      final int INVALID = -1;
-    /** @deprecated because it has been misspelled, use UNKNOWN of 
course */
-    final int UNKNWON = 0;
      final int UNKNOWN = 0;
-
+
      /**
       * Check if the component is still valid. The possible results are :
       * <ul>
Only in 2.2.2/org/apache/excalibur/source/impl: AbstractSourceResolver.java
Only in 2.2.2/org/apache/excalibur/source/impl: DefaultSourceResolver.java
diff -r -u 2.2.1/org/apache/excalibur/source/impl/FileSource.java 
2.2.2/org/apache/excalibur/source/impl/FileSource.java
--- 2.2.1/org/apache/excalibur/source/impl/FileSource.java	2007-05-03 
20:08:08.000000000 +0200
+++ 2.2.2/org/apache/excalibur/source/impl/FileSource.java	2007-05-03 
20:08:22.000000000 +0200
@@ -80,7 +80,7 @@

      /**
       * Builds a FileSource, given an URI scheme and a File.
-     *
+     *
       * @param scheme
       * @param file
       * @throws SourceException
@@ -98,6 +98,13 @@
          try
          {
              uri = file.toURL().toExternalForm();
+            // toExternalForm() is buggy, see e.g. 
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4924415
+            // therefore we check if file: is followed by just one slash
+            // TODO when we move to JDK 1.4+, we should use 
file.toURI().toASCIIString() instead.
+            if ( uri.length() > 6 && uri.startsWith("file:/") && 
uri.charAt(6) != '/' )
+            {
+                uri = "file://" + uri.substring(6);
+            }
          }
          catch (MalformedURLException mue)
          {
@@ -186,7 +193,7 @@

      /**
       * Return a validity object based on the file's modification date.
-     *
+     *
       * @see org.apache.excalibur.source.Source#getValidity()
       */
      public SourceValidity getValidity()
@@ -390,11 +397,11 @@
          {
              throw new SourceNotFoundException("Cannot delete 
non-existing file " + m_file.toString());
          }
-
+
          if (!m_file.delete())
          {
              throw new SourceException("Could not delete " + 
m_file.toString() + " (unknown reason)");
-        }
+        }
      }

 
//----------------------------------------------------------------------------------
@@ -490,10 +497,10 @@
                          m_source.getFile().delete();
                      }
                      // Rename temp file to destination file
-                    if (!m_tmpFile.renameTo(m_source.getFile()))
+                    if (!m_tmpFile.renameTo(m_source.getFile()))
                      {
-                       throw new IOException("Could not rename " +
-                         m_tmpFile.getAbsolutePath() +
+                       throw new IOException("Could not rename " +
+                         m_tmpFile.getAbsolutePath() +
                           " to " + m_source.getFile().getAbsolutePath());
                      }

diff -r -u 
2.2.1/org/apache/excalibur/source/impl/SourceResolverImpl.java 
2.2.2/org/apache/excalibur/source/impl/SourceResolverImpl.java
--- 2.2.1/org/apache/excalibur/source/impl/SourceResolverImpl.java 
2007-05-03 20:08:08.000000000 +0200
+++ 2.2.2/org/apache/excalibur/source/impl/SourceResolverImpl.java 
2007-05-03 20:08:22.000000000 +0200
@@ -17,23 +17,22 @@
  package org.apache.excalibur.source.impl;

  import java.io.File;
-import java.io.IOException;
  import java.net.MalformedURLException;
  import java.net.URL;
-import java.util.Map;

-import org.apache.avalon.framework.CascadingRuntimeException;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.context.Context;
  import org.apache.avalon.framework.context.ContextException;
  import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.ServiceSelector;
  import org.apache.avalon.framework.service.Serviceable;
  import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.excalibur.source.*;
+import org.apache.excalibur.source.SourceFactory;
+import org.apache.excalibur.source.SourceResolver;

  /**
   * This is the default implemenation of a {@link SourceResolver}.
@@ -57,23 +56,75 @@
   * @version $Id: SourceResolverImpl.java,v 1.4 2004/02/28 11:47:24 
cziegeler Exp $
   */
  public class SourceResolverImpl
-    extends AbstractLogEnabled
+    extends AbstractSourceResolver
      implements Serviceable,
      Contextualizable,
      Disposable,
-    SourceResolver,
+    LogEnabled,
      ThreadSafe
  {
+
      /** The component m_manager */
      protected ServiceManager m_manager;

      /** The special Source factories */
      protected ServiceSelector m_factorySelector;

+    /** Our logger. */
+    private Logger m_logger;
+
+    /**
+     * @see 
org.apache.excalibur.source.impl.AbstractSourceResolver#getSourceFactory(java.lang.String)
+     */
+    protected SourceFactory getSourceFactory(String protocol)
+    {
+        try
+        {
+            return (SourceFactory) m_factorySelector.select(protocol);
+        }
+        catch (ServiceException e)
+        {
+            // we go back to the default factory selector
+            return null;
+        }
+    }
+
+    /**
+     * @see 
org.apache.excalibur.source.impl.AbstractSourceResolver#releaseSourceFactory(org.apache.excalibur.source.SourceFactory)
+     */
+    protected void releaseSourceFactory(SourceFactory factory)
+    {
+        m_factorySelector.release(factory);
+    }
+
      /**
-     * The base URL
+     * @see 
org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
       */
-    protected URL m_baseURL;
+    public void enableLogging(Logger logger)
+    {
+        m_logger = logger;
+    }
+
+    protected final Logger getLogger()
+    {
+        return m_logger;
+    }
+
+    /**
+     * @see 
org.apache.excalibur.source.impl.AbstractSourceResolver#debug(java.lang.String)
+     */
+    protected final void debug(String text)
+    {
+        m_logger.debug(text);
+    }
+
+    /**
+     * @see 
org.apache.excalibur.source.impl.AbstractSourceResolver#isDebugEnabled()
+     */
+    protected final boolean isDebugEnabled()
+    {
+        return m_logger.isDebugEnabled();
+    }

      /**
       * Get the context
@@ -117,8 +168,8 @@
      }

      /**
-     * Set the current <code>ComponentLocator</code> instance used by this
-     * <code>Composable</code>.
+     * Set the current <code>ServiceManager</code> instance used by this
+     * <code>Serviceable</code>.
       *
       * @avalon.dependency type="org.apache.excalibur.source.SourceFactory"
       */
@@ -126,13 +177,12 @@
          throws ServiceException
      {
          m_manager = manager;
-
-        if ( m_manager.hasService( SourceFactory.ROLE + "Selector" ) )
-        {
-            m_factorySelector = (ServiceSelector) m_manager.lookup( 
SourceFactory.ROLE + "Selector" );
-        }
+        m_factorySelector = (ServiceSelector) m_manager.lookup( 
SourceFactory.ROLE + "Selector" );
      }

+    /**
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
      public void dispose()
      {
          if( null != m_manager )
@@ -141,148 +191,4 @@
              m_factorySelector = null;
          }
      }
-
-    /**
-     * Get a <code>Source</code> object.
-     * @throws org.apache.excalibur.source.SourceNotFoundException if 
the source cannot be found
-     */
-    public Source resolveURI( String location )
-        throws MalformedURLException, IOException, SourceException
-    {
-        return this.resolveURI( location, null, null );
-    }
-
-    /**
-     * Get a <code>Source</code> object.
-     * @throws org.apache.excalibur.source.SourceNotFoundException if 
the source cannot be found
-     */
-    public Source resolveURI( String location,
-                              String baseURI,
-                              Map parameters )
-        throws MalformedURLException, IOException, SourceException
-    {
-        if( getLogger().isDebugEnabled() )
-        {
-            getLogger().debug( "Resolving '" + location + "' with base 
'" + baseURI + "' in context '" + m_baseURL + "'" );
-        }
-        if( location == null ) throw new MalformedURLException( 
"Invalid System ID" );
-        if( null != baseURI && SourceUtil.indexOfSchemeColon(baseURI) 
== -1 )
-        {
-            throw new MalformedURLException( "BaseURI is not valid, it 
must contain a protocol: " + baseURI );
-        }
-
-        if( baseURI == null ) baseURI = m_baseURL.toExternalForm();
-
-        String systemID = location;
-        // special handling for windows file paths
-        if( location.length() > 1 && location.charAt( 1 ) == ':' )
-            systemID = "file:/" + location;
-        else if( location.length() > 2 && location.charAt(0) == '/' &&

location.charAt(2) == ':' )
-            systemID = "file:" + location;
-
-        // determine protocol (scheme): first try to get the one of the 
systemID, if that fails, take the one of the baseURI
-        String protocol;
-        int protocolPos = SourceUtil.indexOfSchemeColon(systemID);
-        if( protocolPos != -1 )
-        {
-            protocol = systemID.substring( 0, protocolPos );
-        }
-        else
-        {
-            protocolPos = SourceUtil.indexOfSchemeColon(baseURI);
-            if( protocolPos != -1 )
-                protocol = baseURI.substring( 0, protocolPos );
-            else
-                protocol = "*";
-        }
-
-        Source source = null;
-        // search for a SourceFactory implementing the protocol
-        SourceFactory factory = null;
-        try
-        {
-            factory = (SourceFactory)m_factorySelector.select( protocol );
-            systemID = absolutize( factory, baseURI, systemID );
-            if( getLogger().isDebugEnabled() )
-                getLogger().debug( "Resolved to systemID : " + systemID );
-            source = factory.getSource( systemID, parameters );
-        }
-        catch( final ServiceException ce )
-        {
-            // no selector available, use fallback
-        }
-        finally
-        {
-            m_factorySelector.release( factory );
-        }
-
-        if( null == source )
-        {
-            try
-            {
-                factory = (SourceFactory) m_factorySelector.select("*");
-                systemID = absolutize( factory, baseURI, systemID );
-                if( getLogger().isDebugEnabled() )
-                    getLogger().debug( "Resolved to systemID : " + 
systemID );
-                source = factory.getSource( systemID, parameters );
-            }
-            catch (ServiceException se )
-            {
-                throw new SourceException( "Unable to select source 
factory for " + systemID, se );
-            }
-            finally
-            {
-                m_factorySelector.release(factory);
-            }
-        }
-
-        return source;
-    }
-
-    /**
-     * Makes an absolute URI based on a baseURI and a relative URI.
-     */
-    private String absolutize( SourceFactory factory, String baseURI, 
String systemID )
-    {
-        if( factory instanceof URIAbsolutizer )
-            systemID = ((URIAbsolutizer)factory).absolutize(baseURI, 
systemID);
-        else
-            systemID = SourceUtil.absolutize(baseURI, systemID);
-        return systemID;
-    }
-
-    /**
-     * Releases a resolved resource
-     * @param source the source to release
-     */
-    public void release( final Source source )
-    {
-        if( source == null ) return;
-
-        // search for a SourceFactory implementing the protocol
-        final String scheme = source.getScheme();
-        SourceFactory factory = null;
-
-        try
-        {
-            factory = (SourceFactory) m_factorySelector.select(scheme);
-            factory.release(source);
-        }
-        catch (ServiceException se )
-        {
-            try
-            {
-                factory = (SourceFactory) m_factorySelector.select("*");
-                factory.release(source);
-            }
-            catch (ServiceException sse )
-            {
-                throw new CascadingRuntimeException( "Unable to select 
source factory for " + source.getURI(), se );
-            }
-        }
-        finally
-        {
-            m_factorySelector.release( factory );
-        }
-    }
  }


Mime
View raw message