1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 12:02:05 +01:00

[disco/caps] Fix DiscoverInfo.asBuilder()

The method would not copy the extensions elements, which would lead to
a false calculation of the caps hash by EntityCapsManager.
This commit is contained in:
Florian Schmaus 2020-05-22 15:38:16 +02:00
parent 0db6406262
commit a137944e50
5 changed files with 16 additions and 8 deletions

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2019 Florian Schmaus
* Copyright 2019-2020 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,6 +23,10 @@ public abstract class AbstractIqBuilder<IB extends AbstractIqBuilder<IB>> extend
protected IQ.Type type = IQ.Type.get;
AbstractIqBuilder(IQ other, String stanzaId) {
super(other, stanzaId);
}
AbstractIqBuilder(AbstractIqBuilder<?> other) {
super(other);
type = other.type;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2019 Florian Schmaus
* Copyright 2019-2020 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,6 +22,10 @@ import org.jivesoftware.smack.util.Objects;
public abstract class IqBuilder<IB extends IqBuilder<IB, I>, I extends IQ>
extends AbstractIqBuilder<IB> {
protected IqBuilder(IQ other, String stanzaId) {
super(other, stanzaId);
}
protected IqBuilder(AbstractIqBuilder<?> other) {
super(other);
}

View file

@ -496,7 +496,7 @@ public final class EntityCapsManager extends Manager {
private void updateLocalEntityCaps(DiscoverInfo synthesizedDiscoveryInfo) {
XMPPConnection connection = connection();
DiscoverInfoBuilder discoverInfoBuilder = synthesizedDiscoveryInfo.asBuilder();
DiscoverInfoBuilder discoverInfoBuilder = synthesizedDiscoveryInfo.asBuilder("synthesized-disco-info-result");
// getLocalNodeVer() will return a result only after currentCapsVersion is set. Therefore
// set it first and then call getLocalNodeVer()
currentCapsVersion = generateVerificationString(discoverInfoBuilder);

View file

@ -299,8 +299,8 @@ public class DiscoverInfo extends IQ implements DiscoverInfoView, TypedCloneable
return containsDuplicateFeatures;
}
public DiscoverInfoBuilder asBuilder() {
return new DiscoverInfoBuilder(this);
public DiscoverInfoBuilder asBuilder(String stanzaId) {
return new DiscoverInfoBuilder(this, stanzaId);
}
// TODO: Deprecate in favor of asBuilder().

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2019 Florian Schmaus
* Copyright 2019-2020 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -48,8 +48,8 @@ public class DiscoverInfoBuilder extends IqBuilder<DiscoverInfoBuilder, Discover
super(stanzaId);
}
public DiscoverInfoBuilder(DiscoverInfo discoverInfo) {
super(discoverInfo.getStanzaId());
public DiscoverInfoBuilder(DiscoverInfo discoverInfo, String stanzaId) {
super(discoverInfo, stanzaId);
features.addAll(discoverInfo.getFeatures());
identities.addAll(discoverInfo.getIdentities());
node = discoverInfo.getNode();