Skip to content

Commit

Permalink
[BugFix] Fix NPE in HeartbeatMgr when FE node is not available (StarR…
Browse files Browse the repository at this point in the history
…ocks#54997)

Fixes 
```
Cannot invoke "com.starrocks.http.rest.BootstrapFinishAction$BootstrapResult.getStatus()" because "result" is null
```

Signed-off-by: gengjun-git <[email protected]>
  • Loading branch information
gengjun-git authored Jan 16, 2025
1 parent 4b79136 commit 1968220
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fe/fe-core/src/main/java/com/starrocks/common/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public static boolean checkColumnSupported(List<Column> columns) {
// Base64.encodeBase64String("user:passwd".getBytes());
// If no auth info, pass a null.
public static String getResultForUrl(String urlStr, String encodedAuthInfo, int connectTimeoutMs,
int readTimeoutMs) {
int readTimeoutMs) throws Exception {
StringBuilder sb = new StringBuilder();
InputStream stream = null;
String safeUrl = urlStr;
Expand All @@ -379,7 +379,7 @@ public static String getResultForUrl(String urlStr, String encodedAuthInfo, int
}
} catch (Exception e) {
LOG.warn("failed to get result from url: {}. {}", safeUrl, e.getMessage());
return null;
throw e;
} finally {
if (stream != null) {
try {
Expand Down
27 changes: 27 additions & 0 deletions fe/fe-core/src/test/java/com/starrocks/common/util/UtilTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2021-present StarRocks, Inc. All rights reserved.
//
// Licensed 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
//
// https://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.starrocks.common.util;

import org.junit.Assert;
import org.junit.Test;

public class UtilTest {

@Test
public void testGetResultForUrl() {
Assert.assertThrows(Exception.class,
() -> Util.getResultForUrl("http://127.0.0.1:23/invalid", null, 1000, 1000));
}
}

0 comments on commit 1968220

Please sign in to comment.