1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-25 07:42:06 +01:00

Make StanzaCollector final

This commit is contained in:
Florian Schmaus 2019-05-08 11:52:36 +02:00
parent f4ee7dd541
commit d20a2675a8
2 changed files with 7 additions and 9 deletions

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2003-2007 Jive Software, 2016-2018 Florian Schmaus.
* Copyright 2003-2007 Jive Software, 2016-2019 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -41,7 +41,7 @@ import org.jivesoftware.smack.packet.Stanza;
* @see XMPPConnection#createStanzaCollector(StanzaFilter)
* @author Matt Tucker
*/
public class StanzaCollector implements AutoCloseable {
public final class StanzaCollector implements AutoCloseable {
private final StanzaFilter packetFilter;
@ -69,7 +69,7 @@ public class StanzaCollector implements AutoCloseable {
* @param connection the connection the collector is tied to.
* @param configuration the configuration used to construct this collector
*/
protected StanzaCollector(XMPPConnection connection, Configuration configuration) {
StanzaCollector(XMPPConnection connection, Configuration configuration) {
this.connection = connection;
this.packetFilter = configuration.packetFilter;
this.resultQueue = new ArrayDeque<>(configuration.size);

View file

@ -30,7 +30,7 @@ public class StanzaCollectorTest {
@Test
public void verifyRollover() throws InterruptedException {
TestStanzaCollector collector = new TestStanzaCollector(null, new OKEverything(), 5);
StanzaCollector collector = createTestStanzaCollector(null, new OKEverything(), 5);
for (int i = 0; i < 6; i++) {
Stanza testPacket = new TestPacket(i);
@ -70,7 +70,7 @@ public class StanzaCollectorTest {
@Test
public void verifyThreadSafety() throws InterruptedException {
final int insertCount = 500;
final TestStanzaCollector collector = new TestStanzaCollector(null, new OKEverything(), insertCount);
final StanzaCollector collector = createTestStanzaCollector(null, new OKEverything(), insertCount);
final AtomicInteger consumer1Dequeued = new AtomicInteger();
final AtomicInteger consumer2Dequeued = new AtomicInteger();
@ -170,10 +170,8 @@ public class StanzaCollectorTest {
}
static class TestStanzaCollector extends StanzaCollector {
protected TestStanzaCollector(XMPPConnection conection, StanzaFilter packetFilter, int size) {
super(conection, StanzaCollector.newConfiguration().setStanzaFilter(packetFilter).setSize(size));
}
private static StanzaCollector createTestStanzaCollector(XMPPConnection connection, StanzaFilter packetFilter, int size) {
return new StanzaCollector(connection, StanzaCollector.newConfiguration().setStanzaFilter(packetFilter).setSize(size));
}
static class TestPacket extends Stanza {