Skip to content

Commit

Permalink
fix HealthIndicatorProcessor.doHealthCheck() bug when exception occur
Browse files Browse the repository at this point in the history
  • Loading branch information
寻芳 committed Dec 27, 2022
1 parent 63b8f28 commit 0640501
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
*/
package com.alipay.sofa.healthcheck.test;

import com.alipay.sofa.healthcheck.*;
import com.alipay.sofa.healthcheck.AfterReadinessCheckCallbackProcessor;
import com.alipay.sofa.healthcheck.HealthCheckProperties;
import com.alipay.sofa.healthcheck.HealthCheckerProcessor;
import com.alipay.sofa.healthcheck.HealthIndicatorProcessor;
import com.alipay.sofa.healthcheck.ReadinessCheckListener;
import com.alipay.sofa.healthcheck.core.HealthCheckExecutor;
import com.alipay.sofa.healthcheck.test.bean.DiskHealthIndicator;
import com.alipay.sofa.healthcheck.test.bean.TimeoutHealthIndicator;
Expand Down Expand Up @@ -128,15 +132,17 @@ public void testCheckIndicatorFailed() {
Health timeoutHealth = hashMap.get("timeout");
Assert.assertNotNull(timeoutHealth);
Assert.assertEquals(Status.UNKNOWN, timeoutHealth.getStatus());
Assert.assertEquals("java.util.concurrent.TimeoutException: null", timeoutHealth.getDetails().get("error"));
Assert.assertEquals("java.util.concurrent.TimeoutException: null", timeoutHealth
.getDetails().get("error"));
}

private void initApplicationContext(boolean health) {
Map<String, Object> properties = new LinkedHashMap<>();
properties.put("disk-health-indicator.health", health);
properties.put("timeout-health-indicator.health", true);
if (!health) {
properties.put("com.alipay.sofa.healthcheck.indicator.timeout.timeoutHealthIndicator", "1");
properties.put("com.alipay.sofa.healthcheck.indicator.timeout.timeoutHealthIndicator",
"1");
}
properties.put("com.alipay.sofa.healthcheck.skip.indicator", "true");
properties.put("spring.application.name", "HealthIndicatorCheckProcessorTest");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
/*
* Ant Group
* Copyright (c) 2004-2022 All Rights Reserved.
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alipay.sofa.healthcheck.test.bean;

Expand Down

0 comments on commit 0640501

Please sign in to comment.