Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in HopsworksHttpClient #352

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
import org.apache.http.HttpRequest;
import org.apache.http.client.ResponseHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;

public interface HopsworksHttpClient {
static final Logger LOGGER = null;
Logger LOGGER = LoggerFactory.getLogger(HopsworksHttpClient.class);

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

static String readCertKey(String materialPwd) {
try {
return FileUtils.readFileToString(new File(materialPwd));
return FileUtils.readFileToString(new File(materialPwd), Charset.defaultCharset());
} catch (IOException ex) {
LOGGER.warn("Failed to get cert password.", ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@ public void testStringEntitySerialization() throws IOException {
Assertions.assertEquals("{\"email\":\"test@test.com\",\"firstName\":\"test\",\"lastName\":\"de la Rúa Martínez\"}",
json);
}

// FSTORE-1562: readCertKey throws NullPointerException if
@Test
public void testReadCertKey_failure() {
String key = HopsworksHttpClient.readCertKey("/this/path/does/not/exists");
Assertions.assertNull(key);
}

}
Loading