rmetzger commented on a change in pull request #13796:
URL: https://github.com/apache/flink/pull/13796#discussion_r517181365
##########
File path:
tools/ci/java-ci-tools/src/main/java/org/apache/flink/tools/ci/licensecheck/LicenseChecker.java
##########
@@ -251,21 +266,19 @@ private static String readFile(Path path) throws
IOException {
}
private static List<String> loadFromResources(String fileName) {
- List<String> res = new ArrayList<>();
- try (InputStream in =
LicenseChecker.class.getResourceAsStream("/" + fileName)) {
- try (Scanner scanner = new Scanner(in)) {
- while (scanner.hasNext()) {
- String line = scanner.nextLine();
- if (!line.startsWith("#")){
- res.add(line);
- }
- }
- }
- } catch (IOException e) {
+ try {
+ Path resource =
Paths.get(LicenseChecker.class.getResource("/" + fileName).toURI());
+ List<String> result = Files
+ .readAllLines(resource)
+ .stream()
+ .filter(line -> !line.startsWith("#") &&
!line.isEmpty())
+ .collect(Collectors.toList());
+ LOG.debug("Loaded {} items from resource {}",
result.size(), fileName);
+ return result;
+ } catch (Throwable e) {
LOG.warn("Error while loading resource", e);
Review comment:
I didn't want to throw an exception here, because it would lead to an
ugly `ExceptionInInitializerError`, but you are right, it is probably worth it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]