From a97dc0de6b11e902213e0f73b0113a376f3c5504 Mon Sep 17 00:00:00 2001
From: akwizgran <michael@briarproject.org>
Date: Fri, 7 Dec 2012 17:22:24 +0000
Subject: [PATCH] Don't let references to this escape from constructors.

---
 briar-core/src/net/sf/briar/plugins/modem/ModemImpl.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/briar-core/src/net/sf/briar/plugins/modem/ModemImpl.java b/briar-core/src/net/sf/briar/plugins/modem/ModemImpl.java
index b61aacd97c..0fc79fdd2a 100644
--- a/briar-core/src/net/sf/briar/plugins/modem/ModemImpl.java
+++ b/briar-core/src/net/sf/briar/plugins/modem/ModemImpl.java
@@ -38,7 +38,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
 
 	private int lineLen = 0;
 
-	private volatile ReliabilityLayer reliabilityLayer;
+	private volatile ReliabilityLayer reliabilityLayer = null;
 
 	ModemImpl(Executor executor, Callback callback, String portName) {
 		this.executor = executor;
@@ -48,7 +48,6 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
 		offHook = new Semaphore(1);
 		connected = new AtomicBoolean(false);
 		line = new byte[MAX_LINE_LENGTH];
-		reliabilityLayer = new ReliabilityLayer(this);
 	}
 
 	public void start() throws IOException {
@@ -106,6 +105,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
 				LOG.info("Not dialling - call in progress");
 			return false;
 		}
+		reliabilityLayer = new ReliabilityLayer(this);
 		reliabilityLayer.start();
 		if(LOG.isLoggable(INFO)) LOG.info("Dialling");
 		try {
@@ -145,7 +145,6 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
 			throw new IOException(e.toString());
 		}
 		reliabilityLayer.stop();
-		reliabilityLayer = new ReliabilityLayer(this);
 		connected.set(false);
 		offHook.release();
 	}
@@ -239,6 +238,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
 				LOG.info("Not answering - call in progress");
 			return;
 		}
+		reliabilityLayer = new ReliabilityLayer(this);
 		reliabilityLayer.start();
 		if(LOG.isLoggable(INFO)) LOG.info("Answering");
 		try {
-- 
GitLab