Skip to content

Commit f9c0042

Browse files
committed
NullPointerException in HopsworksHttpClient
1 parent d3b916e commit f9c0042

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

java/hsfs/src/main/java/com/logicalclocks/hsfs/metadata/HopsworksHttpClient.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
import org.apache.http.HttpRequest;
2323
import org.apache.http.client.ResponseHandler;
2424
import org.slf4j.Logger;
25+
import org.slf4j.LoggerFactory;
2526

2627
import java.io.File;
2728
import java.io.IOException;
29+
import java.nio.charset.Charset;
2830

2931
public interface HopsworksHttpClient {
30-
static final Logger LOGGER = null;
32+
Logger LOGGER = LoggerFactory.getLogger(HopsworksHttpClient.class);
3133

3234
<T> T handleRequest(HttpRequest request, ResponseHandler<T> responseHandler)
3335
throws IOException, FeatureStoreException;
@@ -46,7 +48,7 @@ <T> T handleRequest(HttpRequest request, ResponseHandler<T> responseHandler)
4648

4749
static String readCertKey(String materialPwd) {
4850
try {
49-
return FileUtils.readFileToString(new File(materialPwd));
51+
return FileUtils.readFileToString(new File(materialPwd), Charset.defaultCharset());
5052
} catch (IOException ex) {
5153
LOGGER.warn("Failed to get cert password.", ex);
5254
}

java/hsfs/src/test/java/com/logicalclocks/hsfs/metadata/TestHopsworksClient.java

+8
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,12 @@ public void testStringEntitySerialization() throws IOException {
4646
Assertions.assertEquals("{\"email\":\"test@test.com\",\"firstName\":\"test\",\"lastName\":\"de la Rúa Martínez\"}",
4747
json);
4848
}
49+
50+
// FSTORE-1562: readCertKey throws NullPointerException if
51+
@Test
52+
public void testReadCertKey_failure() {
53+
String key = HopsworksHttpClient.readCertKey("/this/path/does/not/exists");
54+
Assertions.assertNull(key);
55+
}
56+
4957
}

0 commit comments

Comments
 (0)