Skip to content

Commit

Permalink
Fix NullPointerException
Browse files Browse the repository at this point in the history
  • Loading branch information
unlimmitted committed Sep 21, 2024
1 parent 75a140f commit bfbe507
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/main/java/me/legrange/mikrotik/impl/ApiConnectionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,20 +255,24 @@ public void run() {
} catch (MikrotikApiException ex) {
continue;
}
ResultListener l = listeners.get(res.getTag());
if (l != null) {
if (res instanceof Result) {
l.receive((Result) res);
} else if (res instanceof Done) {
if (l instanceof SyncListener) {
((SyncListener) l).completed((Done) res);
} else {
l.completed();
if (res.getTag() != null) {
ResultListener l = listeners.get(res.getTag());
if (l != null) {
if (res instanceof Result) {
l.receive((Result) res);
} else if (res instanceof Done) {
if (l instanceof SyncListener) {
((SyncListener) l).completed((Done) res);
} else {
l.completed();
}
listeners.remove(res.getTag());
} else if (res instanceof Error) {
l.error(new ApiCommandException((Error) res));
}
listeners.remove(res.getTag());
} else if (res instanceof Error) {
l.error(new ApiCommandException((Error) res));
}
} else {
nextTag();
}
}
}
Expand Down

0 comments on commit bfbe507

Please sign in to comment.