1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 06:12:05 +01:00

Merge pull request #453 from Flowdalic/fix-caps-npe

[caps] Check for null in EntityCapsManager.addCapsExtension()
This commit is contained in:
Florian Schmaus 2021-01-12 09:12:16 +01:00 committed by GitHub
commit 3a661d71b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -312,7 +312,10 @@ public final class EntityCapsManager extends Manager {
// XEP-0115 specifies that a client SHOULD include entity capabilities // XEP-0115 specifies that a client SHOULD include entity capabilities
// with every presence notification it sends. // with every presence notification it sends.
private void addCapsExtension(PresenceBuilder presenceBuilder) { private void addCapsExtension(PresenceBuilder presenceBuilder) {
CapsVersionAndHash capsVersionAndHash = getCapsVersionAndHash(); final CapsVersionAndHash capsVersionAndHash = getCapsVersionAndHash();
if (capsVersionAndHash == null) {
return;
}
CapsExtension caps = new CapsExtension(entityNode, capsVersionAndHash.version, capsVersionAndHash.hash); CapsExtension caps = new CapsExtension(entityNode, capsVersionAndHash.version, capsVersionAndHash.hash);
presenceBuilder.overrideExtension(caps); presenceBuilder.overrideExtension(caps);
} }
@ -434,10 +437,10 @@ public final class EntityCapsManager extends Manager {
} }
/** /**
* Get our own caps version. The version depends on the enabled features. * Get our own caps version or {@code null} if none is yet set. The version depends on the enabled features.
* A caps version looks like '66/0NaeaBKkwk85efJTGmU47vXI=' * A caps version looks like '66/0NaeaBKkwk85efJTGmU47vXI='
* *
* @return our own caps version * @return our own caps version or {@code null}.
*/ */
public CapsVersionAndHash getCapsVersionAndHash() { public CapsVersionAndHash getCapsVersionAndHash() {
return currentCapsVersion; return currentCapsVersion;