I have decompiled a fix provided by a 3rd party development team.
This is the original code:
if (this.getPassword() != null) {
this.uid = this.getUserName();
password = this.getPassword();
}
if (this.host != null) {
en.put("hostname", this.host);
if (password != null && password.toString().trim().length() != 0) {
en.put("password", password.toString());
}
if (this.uid != null && this.uid.trim().length() != 0) {
en.put("userID", this.uid);
}
}
and this is the fix:
if (this.getPassword() != null) {
this.uid = this.getUserName();
final char[] passwordTemp = this.getPassword();
password = new char[passwordTemp.length];
for (int i = 0; i < passwordTemp.length; ++i) {
password[i] = passwordTemp[i];
}
}
if (this.host != null) {
en.put("hostname", this.host);
if (password != null && password.toString().trim().length() != 0) {
en.put("password", new String(password));
}
if (this.uid != null && this.uid.trim().length() != 0) {
en.put("userID", this.uid);
}
}
This seems to have significantly degraded the performance of the code. Does anyone know why this would be done? and is there a better way to do this?