Skip to content

Commit

Permalink
Merge pull request #138 from qase-tms/134-javalangnullpointerexceptio…
Browse files Browse the repository at this point in the history
…n-cannot-invoke-javaneturltouri-because-the-return-value-of-javalangclassloadergetresourcestring-is-null

[cucumber 5] npe fix
  • Loading branch information
savkk committed Jun 18, 2024
2 parents 8a7c356 + 34a153f commit ede63d8
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
Expand Down Expand Up @@ -59,8 +60,12 @@ private void testCaseStarted(TestStepStarted event) {
URI uri = testCase.getUri();
Parser<GherkinDocument> gherkinParser = new Parser<>(new AstBuilder());
try {
GherkinDocument gherkinDocument = gherkinParser.parse(new String(Files.readAllBytes(Paths.get(this.getClass().getClassLoader()
.getResource(uri.toString().replace("classpath:", "")).toURI()))));
URL resource = this.getClass().getClassLoader()
.getResource(uri.toString().replace("classpath:", ""));
if (resource == null) {
return;
}
GherkinDocument gherkinDocument = gherkinParser.parse(new String(Files.readAllBytes(Paths.get(resource.toURI()))));
parseExamples(uri, gherkinDocument);
} catch (URISyntaxException | IOException e) {
log.error(e.getMessage());
Expand Down

0 comments on commit ede63d8

Please sign in to comment.