diff --git a/wave/src/main/java/org/waveprotocol/box/server/frontend/WaveViewSubscription.java b/wave/src/main/java/org/waveprotocol/box/server/frontend/WaveViewSubscription.java index 6281edd7..8cb19198 100644 --- a/wave/src/main/java/org/waveprotocol/box/server/frontend/WaveViewSubscription.java +++ b/wave/src/main/java/org/waveprotocol/box/server/frontend/WaveViewSubscription.java @@ -36,7 +36,9 @@ import org.waveprotocol.wave.model.version.HashedVersion; import org.waveprotocol.wave.util.logging.Log; +import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.logging.Level; @@ -153,11 +155,28 @@ public synchronized void submitResponse(WaveletName waveletName, HashedVersion v // Forward any queued deltas. List filteredDeltas = filterOwnDeltas(state.heldBackDeltas, state); - if (!filteredDeltas.isEmpty()) { - sendUpdate(waveletName, filteredDeltas, null); - } + splitDeltasAndSendUpdate(waveletName, filteredDeltas); state.heldBackDeltas.clear(); } + + /** + * Sent each delta in a separated message to the client. + *


+ * Workaround for WAVE-446: + * Wave's client fails if a non contiguous list of deltas is sent at once. + *

+ * + * @param waveletName the wavelet's name + * @param deltas list of deltas to be forwarded + */ + protected void splitDeltasAndSendUpdate(WaveletName waveletName, List deltas) { + if (!deltas.isEmpty()) { + for (TransformedWaveletDelta delta : deltas) { + List singletonDeltaList = Collections.singletonList(delta); + sendUpdate(waveletName, singletonDeltaList, null); + } + } + } /** * Sends deltas for this subscription (if appropriate).