Skip to content

Commit f402385

Browse files
committed
minor clean up
1 parent 9554f72 commit f402385

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

extras/simple/src/test/java/org/asynchttpclient/extras/simple/SimpleAsyncHttpClientTest.java

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,10 @@ public void testPutZeroBytesFileTest() throws Exception {
129129

130130
@Test(groups = "standalone")
131131
public void testDerive() throws Exception {
132-
SimpleAsyncHttpClient client = new SimpleAsyncHttpClient.Builder().build();
133-
SimpleAsyncHttpClient derived = client.derive().build();
134-
try {
135-
assertNotSame(derived, client);
136-
} finally {
137-
client.close();
138-
derived.close();
132+
try(SimpleAsyncHttpClient client = new SimpleAsyncHttpClient.Builder().build()) {
133+
try(SimpleAsyncHttpClient derived = client.derive().build()) {
134+
assertNotSame(derived, client);
135+
}
139136
}
140137
}
141138

@@ -220,7 +217,6 @@ public void onBytesReceived(Uri uri, long amount, long current, long total) {
220217
};
221218

222219
try (SimpleAsyncHttpClient client = new SimpleAsyncHttpClient.Builder()//
223-
//
224220
.setUrl(getTargetUrl())//
225221
.setHeader("Custom", "custom")//
226222
.setListener(listener).build()) {
@@ -268,16 +264,17 @@ public void testCloseDerivedValidMaster() throws Exception {
268264
@Test(groups = "standalone", expectedExceptions = IllegalStateException.class)
269265
public void testCloseMasterInvalidDerived() throws Throwable {
270266
SimpleAsyncHttpClient client = new SimpleAsyncHttpClient.Builder().setUrl(getTargetUrl()).build();
271-
SimpleAsyncHttpClient derived = client.derive().build();
272-
273-
client.close();
274-
275-
try {
276-
derived.get().get();
277-
fail("Expected closed AHC");
278-
} catch (ExecutionException e) {
279-
throw e.getCause();
267+
try (SimpleAsyncHttpClient derived = client.derive().build()) {
268+
client.close();
269+
270+
try {
271+
derived.get().get();
272+
fail("Expected closed AHC");
273+
} catch (ExecutionException e) {
274+
throw e.getCause();
275+
}
280276
}
277+
281278
}
282279

283280
@Test(groups = "standalone")

0 commit comments

Comments
 (0)