<commit_before>package org.apache.lucene.util;

import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;

public class StoreClassNameRule implements TestRule {
  private volatile Class<?> testClass;

  @Override
  public Statement apply(final Statement s, final Description d) {
    if (!d.isSuite()) {
      throw new IllegalArgumentException("This is a @ClassRule (applies to suites only).");
    }

    return new Statement() {
      @Override
      public void evaluate() throws Throwable {
        try {
          testClass = d.getTestClass();
          s.evaluate();
        } finally {
          testClass = null;
        }
      }
    };
  }
  
  /**
   * Returns the test class currently executing in this rule.
   */
  public Class<?> getTestClass() {
    Class<?> clz = testClass;
    if (clz == null) {
      throw new RuntimeException("The rule is not currently executing.");
    }
    return clz;
  }
}
<commit_msg>Don't load the class before evaluation of a subrule, invoke lazily.<commit_after>package org.apache.lucene.util;

import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;

public class StoreClassNameRule implements TestRule {
  private volatile Description description;

  @Override
  public Statement apply(final Statement s, final Description d) {
    if (!d.isSuite()) {
      throw new IllegalArgumentException("This is a @ClassRule (applies to suites only).");
    }

    return new Statement() {
      @Override
      public void evaluate() throws Throwable {
        try {
          description = d; 
          s.evaluate();
        } finally {
          description = null;
        }
      }
    };
  }
  
  /**
   * Returns the test class currently executing in this rule.
   */
  public Class<?> getTestClass() {
    Description localDescription = description;
    if (localDescription == null) {
      throw new RuntimeException("The rule is not currently executing.");
    }
    return localDescription.getTestClass();
  }
}

{'fraction_non_alphanumeric': 0.10067437379576108, 'fraction_numerical': 0.0, 'mean_word_length': 2.7423423423423423, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1893488', 'n_tokens_mistral': 570, 'n_tokens_neox': 557, 'n_words': 174}