Fix NPE if user is null
Commit a35f8a20ab
replaced the pattern
user instanceof IdentifiedUser
with
user.isIdentifiedUser()
.
This results in a NullPointerException in case the user is null
('user instanceof IdentifiedUser' was returning false in this case).
Add a check that the user is not null in all places where the user can
be null.
Change-Id: I71f5933d9a4eb2de6cd7acf616c347bf8a5bd9f2
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
parent
1f1e0cacaa
commit
6f1ece745f
@ -111,7 +111,7 @@ class HttpLog extends AbstractLifeCycle implements RequestLog {
|
||||
uri = uri + "?" + qs;
|
||||
}
|
||||
|
||||
if (user.isIdentifiedUser()) {
|
||||
if (user != null && user.isIdentifiedUser()) {
|
||||
IdentifiedUser who = (IdentifiedUser) user;
|
||||
if (who.getUserName() != null && !who.getUserName().isEmpty()) {
|
||||
event.setProperty(P_USER, who.getUserName());
|
||||
|
@ -233,7 +233,7 @@ class SshLog implements LifecycleListener {
|
||||
|
||||
String userName = "-", accountId = "-";
|
||||
|
||||
if (user.isIdentifiedUser()) {
|
||||
if (user != null && user.isIdentifiedUser()) {
|
||||
IdentifiedUser u = (IdentifiedUser) user;
|
||||
userName = u.getAccount().getUserName();
|
||||
accountId = "a/" + u.getAccountId().toString();
|
||||
|
@ -81,7 +81,7 @@ class SshScope {
|
||||
@Override
|
||||
public CurrentUser getCurrentUser() {
|
||||
final CurrentUser user = session.getCurrentUser();
|
||||
if (user.isIdentifiedUser()) {
|
||||
if (user != null && user.isIdentifiedUser()) {
|
||||
IdentifiedUser identifiedUser = userFactory.create(((IdentifiedUser) user).getAccountId());
|
||||
identifiedUser.setAccessPath(user.getAccessPath());
|
||||
return identifiedUser;
|
||||
|
@ -146,7 +146,7 @@ final class ShowConnections extends SshCommand {
|
||||
}
|
||||
|
||||
final CurrentUser user = sd.getCurrentUser();
|
||||
if (user.isIdentifiedUser()) {
|
||||
if (user != null && user.isIdentifiedUser()) {
|
||||
IdentifiedUser u = (IdentifiedUser) user;
|
||||
|
||||
if (!numeric) {
|
||||
|
Loading…
Reference in New Issue
Block a user