diff --git a/build.gradle b/build.gradle index 02e00ad..ee5e359 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ allprojects { - version = '1.2.0' + version = '1.2.1' repositories { mavenCentral() google() diff --git a/core/src/main/java/com/novoda/merlin/HttpRequestMaker.java b/core/src/main/java/com/novoda/merlin/HttpRequestMaker.java index 8352e50..f4234e4 100644 --- a/core/src/main/java/com/novoda/merlin/HttpRequestMaker.java +++ b/core/src/main/java/com/novoda/merlin/HttpRequestMaker.java @@ -11,8 +11,9 @@ class HttpRequestMaker implements RequestMaker { @Override public Request head(Endpoint endpoint) { + HttpURLConnection urlConnection = null; try { - HttpURLConnection urlConnection = connectTo(endpoint); + urlConnection = connectTo(endpoint); urlConnection.setRequestProperty("Accept-Encoding", ""); setConnectionToHeadRequest(urlConnection); @@ -21,6 +22,10 @@ public Request head(Endpoint endpoint) { return new MerlinHttpRequest(urlConnection); } catch (IOException e) { throw new RequestException(e); + } finally { + if (urlConnection != null) { + urlConnection.disconnect(); + } } } @@ -55,7 +60,6 @@ public int getResponseCode() { request.disconnect(); } } - } } diff --git a/core/src/main/java/com/novoda/merlin/Register.java b/core/src/main/java/com/novoda/merlin/Register.java index 8f40e49..6993c16 100644 --- a/core/src/main/java/com/novoda/merlin/Register.java +++ b/core/src/main/java/com/novoda/merlin/Register.java @@ -18,7 +18,7 @@ void register(T registerable) { } List registerables() { - return registerables; + return new ArrayList<>(registerables); } void clear() { diff --git a/core/src/test/java/com/novoda/merlin/ConnectCallbackManagerTest.java b/core/src/test/java/com/novoda/merlin/ConnectCallbackManagerTest.java index 2ee8cd3..b089bc9 100644 --- a/core/src/test/java/com/novoda/merlin/ConnectCallbackManagerTest.java +++ b/core/src/test/java/com/novoda/merlin/ConnectCallbackManagerTest.java @@ -7,6 +7,7 @@ import org.junit.Test; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; public class ConnectCallbackManagerTest { @@ -40,6 +41,15 @@ public void givenMultipleRegisteredConnectables_whenCallingOnConnect_thenCallsCo } } + @Test + public void givenRegisteredConnectable_whenCallingOnConnectAndAddingConnectable_thenCallsConnectForConnectable() { + Connectable connectable = givenRegisteredConnectableModifyingConnectables(); + + connectCallbackManager.onConnect(); + + verify(connectable).onConnect(); + } + private List givenMultipleRegisteredConnectables() { List connectables = new ArrayList<>(); @@ -57,4 +67,17 @@ private Connectable givenRegisteredConnectable() { return connectable; } + private Connectable givenRegisteredConnectableModifyingConnectables() { + Connectable connectable = new Connectable() { + + @Override + public void onConnect() { + connectables.register(mock(Connectable.class)); + } + }; + Connectable spyConnectable = spy(connectable); + connectables.register(spyConnectable); + return spyConnectable; + } + } diff --git a/releases/merlin-core-v0.2.jar b/releases/merlin-core-v0.2.jar deleted file mode 100644 index d94bddc..0000000 Binary files a/releases/merlin-core-v0.2.jar and /dev/null differ diff --git a/releases/merlin-core-v0.4.1.jar b/releases/merlin-core-v0.4.1.jar deleted file mode 100644 index b447ac3..0000000 Binary files a/releases/merlin-core-v0.4.1.jar and /dev/null differ diff --git a/releases/merlin-core-v0.5.aar b/releases/merlin-core-v0.5.aar deleted file mode 100644 index d9f8af7..0000000 Binary files a/releases/merlin-core-v0.5.aar and /dev/null differ diff --git a/releases/res/on_connect.jpg b/releases/res/on_connect.jpg deleted file mode 100644 index 75b719b..0000000 Binary files a/releases/res/on_connect.jpg and /dev/null differ diff --git a/releases/res/on_disconnect.jpg b/releases/res/on_disconnect.jpg deleted file mode 100644 index e16972b..0000000 Binary files a/releases/res/on_disconnect.jpg and /dev/null differ