NPE when no Retry-After header is set. Fixes issue #20.

pull/30/head
Richard Körber 2016-07-27 22:52:36 +02:00
parent 5879bb698f
commit 31c4d6d133
2 changed files with 19 additions and 0 deletions

View File

@ -271,6 +271,9 @@ public class DefaultConnection implements Connection {
// See RFC 2616 section 14.37
String header = conn.getHeaderField("Retry-After");
if (header == null) {
return null;
}
try {
// delta-seconds

View File

@ -245,6 +245,22 @@ public class DefaultConnectionTest {
verify(mockUrlConnection, atLeastOnce()).getHeaderField("Retry-After");
}
/**
* Test if no Retry-After header is correctly handled.
*/
@Test
public void testGetRetryAfterHeaderNull() {
when(mockUrlConnection.getHeaderField("Retry-After"))
.thenReturn(null);
try (DefaultConnection conn = new DefaultConnection(mockHttpConnection)) {
conn.conn = mockUrlConnection;
assertThat(conn.getRetryAfterHeader(), is(nullValue()));
}
verify(mockUrlConnection, atLeastOnce()).getHeaderField("Retry-After");
}
/**
* Test if an {@link AcmeServerException} is thrown on an acme problem.
*/