Skip to content
Open
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ buildscript {

group = 'com.blackduck.integration'

version = '12.0.0-SIGQA3-SNAPSHOT'
version = '12.0.0-SIGQA4-IDETECT-5134-SNAPSHOT'

apply plugin: 'com.blackduck.integration.solution'
apply plugin: 'org.springframework.boot'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.blackduck.integration.detectable.detectables.pnpm.lockfile.process;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.List;

import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -62,9 +63,9 @@ public List<CodeLocation> parse(File pnpmLockYamlFile, @Nullable NameVersion pro
*
* @param pnpmLockYamlFile the File path to the pnpm-lock.yaml file
* @return a memory representation of the lock file.
* @throws FileNotFoundException
* @throws IOException if the file cannot be read or closed
*/
private PnpmLockYamlBase parseYamlFile(File pnpmLockYamlFile) throws FileNotFoundException {
private PnpmLockYamlBase parseYamlFile(File pnpmLockYamlFile) throws IOException {
DumperOptions dumperOptions = new DumperOptions();
Representer representer = new Representer(dumperOptions);
representer.getPropertyUtils().setSkipMissingProperties(true);
Expand All @@ -74,11 +75,15 @@ private PnpmLockYamlBase parseYamlFile(File pnpmLockYamlFile) throws FileNotFoun
// Try to read the lockfile into the current Yaml classes. It's more common and
// should hopefully work more of the time.
Yaml yaml = new Yaml(new Constructor(PnpmLockYaml.class, loaderOptions), representer);
return yaml.load(new FileReader(pnpmLockYamlFile));
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(pnpmLockYamlFile), StandardCharsets.UTF_8)) {
return yaml.load(reader);
}
} catch (ConstructorException e) {
// If the reading fails try to read a v5 Yaml.
Yaml yaml = new Yaml(new Constructor(PnpmLockYamlv5.class, loaderOptions), representer);
return yaml.load(new FileReader(pnpmLockYamlFile));
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(pnpmLockYamlFile), StandardCharsets.UTF_8)) {
return yaml.load(reader);
}
}
}
}