Attaching four patches that address various warnings. I'll keep them as separate patches so that it's easier to review the changes, or back out parts of them later if some of the changes cause problems. The regression tests passed.
Here's what the patches do:
Replace use of obsolete collection class Vector with ArrayList. No synchronization is needed, as far as I can see, since the vectors are private to a single server thread.
Also converted two of the original Vector fields (errorManagers and errorManagersLevel) to local variables, as they are never used outside of the method where they are created.
NetBeans warns about synchronization on some non-final fields: timeSliceSync, logConnectionsSync and closeSync, which protect the fields timeSlice, logConnections and close, respectively.
The easiest fix would be to make the *Sync fields final. However, the synchronization objects are only used in set/get methods to ensure that writes in one thread are seen by reads in other threads. For this purpose, using volatile fields would be sufficient, and the extra fields with synchronization objects could be removed. The patch therefore declares timeSlice, logConnections and close volatile, and it removes the timeSliceSync, logConnectionsSync and closeSync fields.
This patch fixes three warnings:
- An if statement had been disabled by prepending "false &&" to the condition, so it never evaluated to true. A warning was shown because the code in the body of the if statement was unreachable. The patch comments out the code, and also adds a comment about why the code was disabled in the first place.
- An unnecessary bit shift operation was removed (shift bits 0 positions to the left is a no-op).
- A local variable in setDatabase() hid a field and was renamed from rdbnam to dbname.
The warning that it addresses is about the constructor leaking a reference to "this". That is, the constructor calls a method and passes "this" as an argument. The problem is that the method to which "this" is passed sees a not yet fully initialized instance. This may or may not be a problem depending on which parts of the state the method needs to access, but it's best avoided.
The patch changes the name and signature of the method that receives the reference to "this", from NetworkServerControlImpl.setUniqueThreadName(Thread thrd, String newName) to NetworkServerControlImpl.getUniqueThreadName(String base). The new method returns a unique thread name instead of setting the name of thread. The constructor could therefore pass the returned value to the super constructor instead of passing a reference to itself to the setUniqueThreadName() method. In addition to silencing the warning, this approach has the advantages that it's less code and the thread name doesn't have to be set twice per thread.
A similar change had to be made to ClientThread's constructor, since NetworkServerControlImpl.setUniqueThreadName() was also used there.