Skip to content

Instantly share code, notes, and snippets.

@headius
Created August 29, 2012 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save headius/3507988 to your computer and use it in GitHub Desktop.
Save headius/3507988 to your computer and use it in GitHub Desktop.
diff --git a/src/org/jruby/ext/coverage/CoverageData.java b/src/org/jruby/ext/coverage/CoverageData.java
index 8833289..7cc6a81 100644
--- a/src/org/jruby/ext/coverage/CoverageData.java
+++ b/src/org/jruby/ext/coverage/CoverageData.java
@@ -33,6 +33,8 @@ public class CoverageData {
}
public synchronized Map<String, Integer[]> prepareCoverage(String filename, Integer[] lines) {
+ assert lines != null;
+
Map<String, Integer[]> coverage = this.coverage;
if (coverage != null) {
diff --git a/src/org/jruby/parser/ParserConfiguration.java b/src/org/jruby/parser/ParserConfiguration.java
index 3db299c..991c94f 100644
--- a/src/org/jruby/parser/ParserConfiguration.java
+++ b/src/org/jruby/parser/ParserConfiguration.java
@@ -62,7 +62,9 @@ public class ParserConfiguration {
private Encoding defaultEncoding;
private Ruby runtime;
- private Integer[] coverage;
+ private Integer[] coverage = EMPTY_COVERAGE;
+
+ private static final Integer[] EMPTY_COVERAGE = new Integer[0];
public ParserConfiguration(Ruby runtime, int lineNumber, boolean inlineSource,
CompatVersion version) {
@@ -221,6 +223,8 @@ public class ParserConfiguration {
* Zero out coverable lines as they're encountered
*/
public void coverLine(int i) {
+ if (i < 0) return; // JRUBY-6868: why would there be negative line numbers?
+
if (runtime.getCoverageData().isCoverageEnabled()) {
if (coverage == null) {
coverage = new Integer[i + 1];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment