You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by og...@apache.org on 2003/11/07 08:34:34 UTC

cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/protocol Protocol.java

oglueck     2003/11/06 23:34:34

  Modified:    httpclient API_CHANGES_2_1.txt
               httpclient/src/java/org/apache/commons/httpclient/protocol
                        Protocol.java
  Log:
  fixed design error: uniform Protocol constructor for all factories
  
  Revision  Changes    Path
  1.4       +2 -0      jakarta-commons/httpclient/API_CHANGES_2_1.txt
  
  Index: API_CHANGES_2_1.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/API_CHANGES_2_1.txt,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- API_CHANGES_2_1.txt	18 Sep 2003 13:56:21 -0000	1.3
  +++ API_CHANGES_2_1.txt	7 Nov 2003 07:34:34 -0000	1.4
  @@ -31,3 +31,5 @@
       state of DigestScheme:
       - createDigest(String, String)
       - createDigestHeader(String, String)
  +    
  +* There is only one Protocol constructor for both secure and insecure socket factories.
  
  
  
  1.6       +6 -32     jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/protocol/Protocol.java
  
  Index: Protocol.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/protocol/Protocol.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Protocol.java	31 Jan 2003 00:33:36 -0000	1.5
  +++ Protocol.java	7 Nov 2003 07:34:34 -0000	1.6
  @@ -194,7 +194,8 @@
       private boolean secure;
     
       /**
  -     * Constructs a new Protocol.  The created protcol is insecure.
  +     * Constructs a new Protocol. If the created protocol is secure depends on
  +     * the class of <code>factory</code>.
        * 
        * @param scheme the scheme (e.g. http, https)
        * @param factory the factory for creating sockets for communication using
  @@ -216,36 +217,9 @@
           this.scheme = scheme;
           this.socketFactory = factory;
           this.defaultPort = defaultPort;
  -        this.secure = false;
  +        this.secure = (factory instanceof SecureProtocolSocketFactory);
       }
       
  -    /**
  -     * Constructs a new Protocol.  The created protcol is secure.
  -     *
  -     * @param scheme the scheme (e.g. http, https)
  -     * @param factory the factory for creating sockets for communication using
  -     * this protocol
  -     * @param defaultPort the port this protocol defaults to
  -     */
  -    public Protocol(String scheme, 
  -        SecureProtocolSocketFactory factory, int defaultPort) {
  -        
  -        if (scheme == null) {
  -            throw new IllegalArgumentException("scheme is null");
  -        }
  -        if (factory == null) {
  -            throw new IllegalArgumentException("socketFactory is null");
  -        }
  -        if (defaultPort <= 0) {
  -            throw new IllegalArgumentException("port is invalid: " + defaultPort);
  -        }
  -
  -        this.scheme = scheme;
  -        this.socketFactory = factory;
  -        this.defaultPort = defaultPort;
  -        this.secure = true;        
  -    }
  -
       /**
        * Returns the defaultPort.
        * @return int
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/protocol Protocol.java

Posted by Ortwin Glück <or...@nose.ch>.
Michael Becke wrote:
> Yes, I think deprecation and calling the first constructor would be better.

Okay, I just changed it. Thanks for the hint, Mike.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/protocol Protocol.java

Posted by Michael Becke <be...@u.washington.edu>.
> That's why it is listed in API changes :-)
> 
> Of course we can replace the second constructor with a call to the first 
> one to be 2.0 API compatible:

Yes, I think deprecation and calling the first constructor would be better.

Mike


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/protocol Protocol.java

Posted by Ortwin Glück <or...@nose.ch>.
Michael Becke wrote:
> I think the addition of an instanceof test is good, but I think we  
> should deprecate here instead of removing the constructor.  This  
> removal causes a binary compatibility problem that I think we can  
> easily avoid.
> 
> Mike


That's why it is listed in API changes :-)

Of course we can replace the second constructor with a call to the first 
one to be 2.0 API compatible:

/**
  * @deprecated
  */
public Protocol(String scheme, SecureProtocolSocketFactory factory, int 
defaultPort) {
   this(scheme, (ProtocolSocketFactory) factory, defaultPort);
}


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/protocol Protocol.java

Posted by Michael Becke <be...@u.washington.edu>.
I think the addition of an instanceof test is good, but I think we  
should deprecate here instead of removing the constructor.  This  
removal causes a binary compatibility problem that I think we can  
easily avoid.

Mike

On Nov 7, 2003, at 2:34 AM, oglueck@apache.org wrote:

> oglueck     2003/11/06 23:34:34
>
>   Modified:    httpclient API_CHANGES_2_1.txt
>                 
> httpclient/src/java/org/apache/commons/httpclient/protocol
>                         Protocol.java
>   Log:
>   fixed design error: uniform Protocol constructor for all factories
>
>   Revision  Changes    Path
>   1.4       +2 -0      jakarta-commons/httpclient/API_CHANGES_2_1.txt
>
>   Index: API_CHANGES_2_1.txt
>   ===================================================================
>   RCS file: /home/cvs/jakarta-commons/httpclient/API_CHANGES_2_1.txt,v
>   retrieving revision 1.3
>   retrieving revision 1.4
>   diff -u -r1.3 -r1.4
>   --- API_CHANGES_2_1.txt	18 Sep 2003 13:56:21 -0000	1.3
>   +++ API_CHANGES_2_1.txt	7 Nov 2003 07:34:34 -0000	1.4
>   @@ -31,3 +31,5 @@
>        state of DigestScheme:
>        - createDigest(String, String)
>        - createDigestHeader(String, String)
>   +
>   +* There is only one Protocol constructor for both secure and  
> insecure socket factories.
>
>
>
>   1.6       +6 -32      
> jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ 
> protocol/Protocol.java
>
>   Index: Protocol.java
>   ===================================================================
>   RCS file:  
> /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/ 
> httpclient/protocol/Protocol.java,v
>   retrieving revision 1.5
>   retrieving revision 1.6
>   diff -u -r1.5 -r1.6
>   --- Protocol.java	31 Jan 2003 00:33:36 -0000	1.5
>   +++ Protocol.java	7 Nov 2003 07:34:34 -0000	1.6
>   @@ -194,7 +194,8 @@
>        private boolean secure;
>
>        /**
>   -     * Constructs a new Protocol.  The created protcol is insecure.
>   +     * Constructs a new Protocol. If the created protocol is secure  
> depends on
>   +     * the class of <code>factory</code>.
>         *
>         * @param scheme the scheme (e.g. http, https)
>         * @param factory the factory for creating sockets for  
> communication using
>   @@ -216,36 +217,9 @@
>            this.scheme = scheme;
>            this.socketFactory = factory;
>            this.defaultPort = defaultPort;
>   -        this.secure = false;
>   +        this.secure = (factory instanceof  
> SecureProtocolSocketFactory);
>        }
>
>   -    /**
>   -     * Constructs a new Protocol.  The created protcol is secure.
>   -     *
>   -     * @param scheme the scheme (e.g. http, https)
>   -     * @param factory the factory for creating sockets for  
> communication using
>   -     * this protocol
>   -     * @param defaultPort the port this protocol defaults to
>   -     */
>   -    public Protocol(String scheme,
>   -        SecureProtocolSocketFactory factory, int defaultPort) {
>   -
>   -        if (scheme == null) {
>   -            throw new IllegalArgumentException("scheme is null");
>   -        }
>   -        if (factory == null) {
>   -            throw new IllegalArgumentException("socketFactory is  
> null");
>   -        }
>   -        if (defaultPort <= 0) {
>   -            throw new IllegalArgumentException("port is invalid: "  
> + defaultPort);
>   -        }
>   -
>   -        this.scheme = scheme;
>   -        this.socketFactory = factory;
>   -        this.defaultPort = defaultPort;
>   -        this.secure = true;
>   -    }
>   -
>        /**
>         * Returns the defaultPort.
>         * @return int
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org