mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 06:12:05 +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 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 access level because of unit test purposes
|
||||||
*/
|
*/
|
||||||
protected PacketReader packetReader;
|
protected final PacketReader packetReader = new PacketReader();
|
||||||
|
|
||||||
private final SynchronizationPoint<Exception> initialOpenStreamSend = new SynchronizationPoint<>(
|
private final SynchronizationPoint<Exception> initialOpenStreamSend = new SynchronizationPoint<>(
|
||||||
this, "initial open stream element send to server");
|
this, "initial open stream element send to server");
|
||||||
|
@ -642,17 +642,11 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
private void initConnection() throws IOException, InterruptedException {
|
private void initConnection() throws IOException, InterruptedException {
|
||||||
boolean isFirstInitialization = packetReader == null || packetWriter == null;
|
|
||||||
compressionHandler = null;
|
compressionHandler = null;
|
||||||
|
|
||||||
// Set the reader and writer instance variables
|
// Set the reader and writer instance variables
|
||||||
initReaderAndWriter();
|
initReaderAndWriter();
|
||||||
|
|
||||||
if (isFirstInitialization) {
|
|
||||||
packetWriter = new PacketWriter();
|
|
||||||
packetReader = new PacketReader();
|
|
||||||
}
|
|
||||||
|
|
||||||
int availableReaderWriterSemaphorePermits = readerWriterSemaphore.availablePermits();
|
int availableReaderWriterSemaphorePermits = readerWriterSemaphore.availablePermits();
|
||||||
if (availableReaderWriterSemaphorePermits < 2) {
|
if (availableReaderWriterSemaphorePermits < 2) {
|
||||||
Object[] logObjects = new Object[] {
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -49,11 +49,9 @@ public class PacketWriterTest {
|
||||||
@Test
|
@Test
|
||||||
public void shouldBlockAndUnblockTest() throws InterruptedException, BrokenBarrierException, NotConnectedException, XmppStringprepException {
|
public void shouldBlockAndUnblockTest() throws InterruptedException, BrokenBarrierException, NotConnectedException, XmppStringprepException {
|
||||||
XMPPTCPConnection connection = new XMPPTCPConnection("user", "pass", "example.org");
|
XMPPTCPConnection connection = new XMPPTCPConnection("user", "pass", "example.org");
|
||||||
final PacketWriter pw = connection.new PacketWriter();
|
final PacketWriter pw = connection.packetWriter;
|
||||||
connection.packetWriter = pw;
|
|
||||||
connection.packetReader = connection.new PacketReader();
|
|
||||||
connection.setWriter(new BlockingStringWriter());
|
connection.setWriter(new BlockingStringWriter());
|
||||||
pw.init();
|
connection.packetWriter.init();
|
||||||
|
|
||||||
for (int i = 0; i < XMPPTCPConnection.PacketWriter.QUEUE_SIZE; i++) {
|
for (int i = 0; i < XMPPTCPConnection.PacketWriter.QUEUE_SIZE; i++) {
|
||||||
pw.sendStreamElement(new Message());
|
pw.sendStreamElement(new Message());
|
||||||
|
|
Loading…
Reference in a new issue