mirror of https://github.com/shred/acme4j
NPE when no Retry-After header is set. Fixes issue #20.
parent
5879bb698f
commit
31c4d6d133
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue