You bring up a good point. Having the one constructor deprecated might be a little annoying for users. Fortunately, creating protocols is a fairly rare event. Given that, I think the annoyance is worth it for the backwards compatibility. My other intention is to try to keep the API breaks to a minimum. Though this one is pretty minor I think it's worth keeping compatibility wherever possible.
Mike
On Nov 10, 2003, at 10:18 AM, Roland Weber wrote:
Hello Mike,
I have considered deprecation as well. But the problem is that folks will
get deprecation warnings although their code is perfectly ok. They don't
have to change a bit, as soon as the deprecated constructor is removed,
the very same code will compile without a warning. Consider this:
SecureProtocolSocketFactory spsf = ...; ... = new Protocol("myscheme", spsf, 666);
When the constructor is deprecated, you will get a warning. To get rid of that warning, you have to use the other constructor explicitly:
... = new Protocol("myscheme", (ProtocolSocketFactory)spsf, 666);
Once the deprecated constructor is removed, nobody is going to understand why the argument was ever casted...
Breaking binary compatibility isn't nice, but I don't think people should have to screw up their code like this to get rid of deprecation warnings.
regards, Roland
Michael Becke <[EMAIL PROTECTED]> 10.11.2003 14:26 Please respond to "Commons HttpClient Project"
To: Commons HttpClient Project
<[EMAIL PROTECTED]>
cc:
Subject: Re: cvs commit:
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ protocol
Protocol.java
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, [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]