Skip to content
This repository was archived by the owner on Feb 11, 2022. It is now read-only.

Commit 74e8bf2

Browse files
author
Xavi Rigau
authored
Merge pull request #185 from novoda/develop
Develop to Release
2 parents 8b3278b + e9e8451 commit 74e8bf2

File tree

9 files changed

+31
-4
lines changed

9 files changed

+31
-4
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
allprojects {
2-
version = '1.2.0'
2+
version = '1.2.1'
33
repositories {
44
mavenCentral()
55
google()

core/src/main/java/com/novoda/merlin/HttpRequestMaker.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ class HttpRequestMaker implements RequestMaker {
1111

1212
@Override
1313
public Request head(Endpoint endpoint) {
14+
HttpURLConnection urlConnection = null;
1415
try {
15-
HttpURLConnection urlConnection = connectTo(endpoint);
16+
urlConnection = connectTo(endpoint);
1617
urlConnection.setRequestProperty("Accept-Encoding", "");
1718

1819
setConnectionToHeadRequest(urlConnection);
@@ -21,6 +22,10 @@ public Request head(Endpoint endpoint) {
2122
return new MerlinHttpRequest(urlConnection);
2223
} catch (IOException e) {
2324
throw new RequestException(e);
25+
} finally {
26+
if (urlConnection != null) {
27+
urlConnection.disconnect();
28+
}
2429
}
2530
}
2631

@@ -55,7 +60,6 @@ public int getResponseCode() {
5560
request.disconnect();
5661
}
5762
}
58-
5963
}
6064

6165
}

core/src/main/java/com/novoda/merlin/Register.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void register(T registerable) {
1818
}
1919

2020
List<T> registerables() {
21-
return registerables;
21+
return new ArrayList<>(registerables);
2222
}
2323

2424
void clear() {

core/src/test/java/com/novoda/merlin/ConnectCallbackManagerTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.junit.Test;
88

99
import static org.mockito.Mockito.mock;
10+
import static org.mockito.Mockito.spy;
1011
import static org.mockito.Mockito.verify;
1112

1213
public class ConnectCallbackManagerTest {
@@ -40,6 +41,15 @@ public void givenMultipleRegisteredConnectables_whenCallingOnConnect_thenCallsCo
4041
}
4142
}
4243

44+
@Test
45+
public void givenRegisteredConnectable_whenCallingOnConnectAndAddingConnectable_thenCallsConnectForConnectable() {
46+
Connectable connectable = givenRegisteredConnectableModifyingConnectables();
47+
48+
connectCallbackManager.onConnect();
49+
50+
verify(connectable).onConnect();
51+
}
52+
4353
private List<Connectable> givenMultipleRegisteredConnectables() {
4454
List<Connectable> connectables = new ArrayList<>();
4555

@@ -57,4 +67,17 @@ private Connectable givenRegisteredConnectable() {
5767
return connectable;
5868
}
5969

70+
private Connectable givenRegisteredConnectableModifyingConnectables() {
71+
Connectable connectable = new Connectable() {
72+
73+
@Override
74+
public void onConnect() {
75+
connectables.register(mock(Connectable.class));
76+
}
77+
};
78+
Connectable spyConnectable = spy(connectable);
79+
connectables.register(spyConnectable);
80+
return spyConnectable;
81+
}
82+
6083
}

releases/merlin-core-v0.2.jar

-436 KB
Binary file not shown.

releases/merlin-core-v0.4.1.jar

-437 KB
Binary file not shown.

releases/merlin-core-v0.5.aar

-22.8 KB
Binary file not shown.

releases/res/on_connect.jpg

-6.92 KB
Binary file not shown.

releases/res/on_disconnect.jpg

-6.92 KB
Binary file not shown.

0 commit comments

Comments
 (0)