mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 05:22:06 +01:00
Make writer/reader fields final in XMPPTCPConnection
This commit is contained in:
parent
09bffb8dca
commit
60f324eb1b
2 changed files with 5 additions and 13 deletions
|
@ -173,12 +173,12 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
/**
|
||||
* Protected access level because of unit test purposes
|
||||
*/
|
||||
protected PacketWriter packetWriter;
|
||||
protected final PacketWriter packetWriter = new PacketWriter();
|
||||
|
||||
/**
|
||||
* Protected access level because of unit test purposes
|
||||
*/
|
||||
protected PacketReader packetReader;
|
||||
protected final PacketReader packetReader = new PacketReader();
|
||||
|
||||
private final SynchronizationPoint<Exception> initialOpenStreamSend = new SynchronizationPoint<>(
|
||||
this, "initial open stream element send to server");
|
||||
|
@ -642,17 +642,11 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
* @throws InterruptedException
|
||||
*/
|
||||
private void initConnection() throws IOException, InterruptedException {
|
||||
boolean isFirstInitialization = packetReader == null || packetWriter == null;
|
||||
compressionHandler = null;
|
||||
|
||||
// Set the reader and writer instance variables
|
||||
initReaderAndWriter();
|
||||
|
||||
if (isFirstInitialization) {
|
||||
packetWriter = new PacketWriter();
|
||||
packetReader = new PacketReader();
|
||||
}
|
||||
|
||||
int availableReaderWriterSemaphorePermits = readerWriterSemaphore.availablePermits();
|
||||
if (availableReaderWriterSemaphorePermits < 2) {
|
||||
Object[] logObjects = new Object[] {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2014 Florian Schmaus
|
||||
* Copyright 2014-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.
|
||||
|
@ -49,11 +49,9 @@ public class PacketWriterTest {
|
|||
@Test
|
||||
public void shouldBlockAndUnblockTest() throws InterruptedException, BrokenBarrierException, NotConnectedException, XmppStringprepException {
|
||||
XMPPTCPConnection connection = new XMPPTCPConnection("user", "pass", "example.org");
|
||||
final PacketWriter pw = connection.new PacketWriter();
|
||||
connection.packetWriter = pw;
|
||||
connection.packetReader = connection.new PacketReader();
|
||||
final PacketWriter pw = connection.packetWriter;
|
||||
connection.setWriter(new BlockingStringWriter());
|
||||
pw.init();
|
||||
connection.packetWriter.init();
|
||||
|
||||
for (int i = 0; i < XMPPTCPConnection.PacketWriter.QUEUE_SIZE; i++) {
|
||||
pw.sendStreamElement(new Message());
|
||||
|
|
Loading…
Reference in a new issue