Attaching a new patch, DERBY4786_patch2_diff.txt, which sends shutdown command with protocol level 2 whether there is username or password provided or not. If this command fails because of DRDA_InvalidReplyHead from server, then resend the shutdown command but this time with protocol level 1. The attempt with protocol level 1 will be made only if there was no username and password supplied with the shutdown command.
One issue I noticed this with change is if a client with the changes proposed by this patch sends a shutdown command to a 10.3 server(which does not have DERBY-2109 changes) without the username and password, it will get 2 exceptions back from the server. 1st exception will be for sending the shutdown command at protocol level 2 and the 2nd will be for shutting down the server succesfully. Server will also have 2 messages, first indicating that an invalid protocol level command was received and 2nd message saying that the server is shutdown. Let me show that by example
Client with the patch applied will show following when it is trying to shutdown a 10.3 server
$ java org.apache.derby.drda.NetworkServerControl -noSecurityManager shutdown
Tue Sep 07 21:57:10 PDT 2010 : Invalid reply header from network server: Invalid string ←. Plaintext connection attempt to an SSL enabled server?
Tue Sep 07 21:57:11 PDT 2010 : Apache Derby Network Server - 10.7.0.0 alpha - (1) shutdown
The 10.3 server would show following for a shutdown command from a trunk client(with the patch applied)
java.lang.Throwable: DRDA_UnknownProtocol.S, <2>
at org.apache.derby.impl.drda.NetworkServerControlImpl.processCommands(NetworkServerControlImpl.java:1509)
at org.apache.derby.impl.drda.DRDAConnThread.sessionInitialState(DRDAConnThread.java:602)
at org.apache.derby.impl.drda.DRDAConnThread.run(DRDAConnThread.java:266)
Execution failed because of a Distributed Protocol Error: DRDA_Proto_SYNTAXRM;CODPNT arg = 0; Error Code Value = 1. Plaintext connection attempt from an SSL enabled client?
org.apache.derby.impl.drda.DRDAProtocolException: Execution failed because of a Distributed Protocol Error: DRDA_Proto_SYNTAXRM; CODPNT arg = 0; Error Code Value = 1. Plaintext connection attempt from an SSL enabled client?
at org.apache.derby.impl.drda.DRDAConnThread.throwSyntaxrm(DRDAConnThread.java:470)
at org.apache.derby.impl.drda.DDMReader.readDssHeader(DDMReader.java:340)
at org.apache.derby.impl.drda.DRDAConnThread.processCommands(DRDAConnThread.java:673)
at org.apache.derby.impl.drda.DRDAConnThread.run(DRDAConnThread.java:277)
Execution failed because of a Distributed Protocol Error: DRDA_Proto_SYNTAXRM;CODPNT arg = 0; Error Code Value = 1. Plaintext connection attempt from an SSL enabled client?
org.apache.derby.impl.drda.DRDAProtocolException: Execution failed because of a Distributed Protocol Error: DRDA_Proto_SYNTAXRM; CODPNT arg = 0; Error Code Value = 1. Plaintext connection attempt from an SSL enabled client?
at org.apache.derby.impl.drda.DRDAConnThread.throwSyntaxrm(DRDAConnThread.java:470)
at org.apache.derby.impl.drda.DDMReader.readDssHeader(DDMReader.java:340)
at org.apache.derby.impl.drda.DRDAConnThread.processCommands(DRDAConnThread.java:673)
at org.apache.derby.impl.drda.DRDAConnThread.run(DRDAConnThread.java:277)
Apache Derby Network Server - 10.3.3.1 - (1) shutdown at
{2}
I am not sure if we should try to mask this exception for the shutdown attempt with protocol level 2. Is it an ususal case any ways that a 10.3 server is being shutdown with a higher release client? Should we just document this behavior?
Attaching a patch to fix the jira. What the patch does is it checks if the optional username and password have specified for the shutdown command and if yes, then it uses protocol level 2 and then sends the username and password info to the server when sending the shutdown command. If user has not specified username and password then it uses protocol level 1 and sends just the shutdown command the way it used to work prior to DERBY-2109. In other words, protocol level 1 for shutdown with no username and password and protocol level 2 for shutdown with username and password.
Server on its side checks if it is dealing with protocol level 1 for shutdown and if yes, then it does not need to look for username and password. But if the the protocol level is 2, then the server will expect username and password for the shutdown command,
This way, a trunk client with this patch will be able to shutdown a 10.3 server with DERBY-2109 changes with no username and password. If it sends the username and password then there be following error on the server and client side
10.3 server side error
DRDA_UnknownProtocol.S, <2>
Execution failed because of a Distributed Protocol Error: DRDA_Proto_SYNTAXRM;CODPNT arg = 0; Error Code Value = 1. Plaintext connection attempt from an SSL enabled client?
trunk client side error
Tue Aug 31 11:48:20 PDT 2010 : Invalid reply header from network server: Invalid string. Plaintext connection attempt to an SSL enabled server?
Please let me know if anyone has any feedback on this patch. I will plan on committing this in a day or two.