Fix NullPointerException

This commit is contained in:
unlimmitted 2024-09-21 16:50:56 +03:00
parent 75a140f79f
commit bfbe50732d
1 changed files with 16 additions and 12 deletions

View File

@ -255,20 +255,24 @@ public final class ApiConnectionImpl extends ApiConnection {
} catch (MikrotikApiException ex) { } catch (MikrotikApiException ex) {
continue; continue;
} }
ResultListener l = listeners.get(res.getTag()); if (res.getTag() != null) {
if (l != null) { ResultListener l = listeners.get(res.getTag());
if (res instanceof Result) { if (l != null) {
l.receive((Result) res); if (res instanceof Result) {
} else if (res instanceof Done) { l.receive((Result) res);
if (l instanceof SyncListener) { } else if (res instanceof Done) {
((SyncListener) l).completed((Done) res); if (l instanceof SyncListener) {
} else { ((SyncListener) l).completed((Done) res);
l.completed(); } 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();
} }
} }
} }