Skip to content

Commit 88ff8b9

Browse files
alai8rjeberhard
authored andcommitted
WlsRetriever disallow null service in constructor
1 parent 4677f0b commit 88ff8b9

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

operator/src/main/java/oracle/kubernetes/operator/wlsconfig/WlsRetriever.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ static final class WithHttpClientStep extends Step {
244244
public WithHttpClientStep(RequestType requestType, V1Service service, Step next) {
245245
super(next);
246246
this.requestType = requestType;
247+
if (service == null) {
248+
throw new IllegalArgumentException("service cannot be null");
249+
}
247250
this.service = service;
248251
}
249252

@@ -359,18 +362,19 @@ public NextAction apply(Packet packet) {
359362

360363
return doNext(packet);
361364
} catch (Throwable t) {
365+
// do not retry for health check
366+
if (RequestType.HEALTH.equals(requestType)) {
367+
LOGGER.fine(
368+
MessageKeys.WLS_HEALTH_READ_FAILED, packet.get(ProcessingConstants.SERVER_NAME), t);
369+
return doNext(packet);
370+
}
362371
// exponential back-off
363372
Integer retryCount = (Integer) packet.get(RETRY_COUNT);
364373
if (retryCount == null) {
365374
retryCount = 0;
366375
// Log warning if this is the first try. Do not log for retries to prevent
367376
// filling up the log repeatedly with same log message
368-
if (RequestType.CONFIG.equals(requestType)) {
369-
LOGGER.warning(MessageKeys.WLS_CONFIGURATION_READ_FAILED, t);
370-
} else {
371-
LOGGER.fine(
372-
MessageKeys.WLS_HEALTH_READ_FAILED, packet.get(ProcessingConstants.SERVER_NAME), t);
373-
}
377+
LOGGER.warning(MessageKeys.WLS_CONFIGURATION_READ_FAILED, t);
374378
}
375379
long waitTime = Math.min((2 << ++retryCount) * SCALE, MAX) + (R.nextInt(HIGH - LOW) + LOW);
376380
packet.put(RETRY_COUNT, retryCount);

operator/src/test/java/oracle/kubernetes/operator/wlsconfig/WlsRetrieverTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void withHttpClientStep_Health_logIfFailed() {
9292
assertThat(logRecords, containsFine(WLS_HEALTH_READ_FAILED, SERVER_NAME));
9393
}
9494

95-
@Test
95+
// @Test - no longer retry for Health check
9696
public void withHttpClientStep_Health_nologIfFailedOnRetry() {
9797
V1Service service = Stub.createStub(V1ServiceStub.class);
9898
Step next = new MockStep(null);

0 commit comments

Comments
 (0)