[spotbugs] Fix potential NPE in OpenSshServerKeyDatabase
If oldLine is null #updateModifiedServerKey shouldn't be called since it would derefence it. Spotbugs raised this as problem RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE. Fix it by checking if oldLine is null before calling #updateModifiedServerKey. Change-Id: I8a2000492986e52ce7dbe25f48b321c05fd371e4 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
bceb202319
commit
50f0347ea3
|
@ -346,11 +346,14 @@ private void updateModifiedServerKey(PublicKey serverKey,
|
|||
throws IOException {
|
||||
KnownHostEntry hostEntry = entry.getHostEntry();
|
||||
String oldLine = hostEntry.getConfigLine();
|
||||
if (oldLine == null) {
|
||||
return;
|
||||
}
|
||||
String newLine = updateHostKeyLine(oldLine, serverKey);
|
||||
if (newLine == null || newLine.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (oldLine == null || oldLine.isEmpty() || newLine.equals(oldLine)) {
|
||||
if (oldLine.isEmpty() || newLine.equals(oldLine)) {
|
||||
// Shouldn't happen.
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue