Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 13b6fc30d1e7
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6e5f32ed2106
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 24, 2014

  1. Copy the full SHA
    6414b4b View commit details
  2. Copy the full SHA
    6e5f32e View commit details
Showing with 12 additions and 24 deletions.
  1. +10 −23 core/src/test/java/org/jruby/TestRegexpCache.java
  2. +2 −1 test/mri/excludes/TestTime.rb
33 changes: 10 additions & 23 deletions core/src/test/java/org/jruby/TestRegexpCache.java
Original file line number Diff line number Diff line change
@@ -10,33 +10,20 @@ public class TestRegexpCache extends TestRubyBase {
private static final ByteList GH2078_TEST_BYTELIST = ByteList.create("GH2078");
public void testCacheRetention() {
RubyRegexp.quotedPatternCache.clear();
Regex regex = RubyRegexp.getQuotedRegexpFromCache(runtime, GH2078_TEST_BYTELIST, GH2078_TEST_BYTELIST.getEncoding(), RegexpOptions.NULL_OPTIONS);

// Should be the same object if cached
assertSame(RubyRegexp.getQuotedRegexpFromCache(runtime, GH2078_TEST_BYTELIST, GH2078_TEST_BYTELIST.getEncoding(), RegexpOptions.NULL_OPTIONS), RubyRegexp.getQuotedRegexpFromCache(runtime, GH2078_TEST_BYTELIST, GH2078_TEST_BYTELIST.getEncoding(), RegexpOptions.NULL_OPTIONS));

// Should only have one entry
assertEquals(1, RubyRegexp.quotedPatternCache.size());

// Should be the same object if cached
assertSame(regex, RubyRegexp.getQuotedRegexpFromCache(runtime, GH2078_TEST_BYTELIST, GH2078_TEST_BYTELIST.getEncoding(), RegexpOptions.NULL_OPTIONS));

// clear reference and attempt to trigger GC
regex = null;
System.gc();
Thread.yield();
System.gc();
Thread.yield();
System.gc();
Thread.yield();
System.gc();
Thread.yield();
System.gc();
Thread.yield();
System.gc();
Thread.yield();
System.gc();
Thread.yield();
System.gc();
Thread.yield();
System.gc();
// attempt to trigger GC and clean up cache for ten seconds
long time = System.currentTimeMillis();
while ((System.currentTimeMillis() - time) < 10000) {
Thread.yield();
System.gc();
if (RubyRegexp.quotedPatternCache.size() == 0) break;
}

// Should be no retained references once cleaned
assertEquals(0, RubyRegexp.quotedPatternCache.size());
3 changes: 2 additions & 1 deletion test/mri/excludes/TestTime.rb
Original file line number Diff line number Diff line change
@@ -9,4 +9,5 @@
exclude :test_strftime_rational, "needs investigation"
exclude :test_strftime_too_wide, "needs investigation"
exclude :test_time_interval, "needs investigation"
exclude :test_utc_or_local, "needs investigation"
exclude :test_utc_or_local, "needs investigation"
exclude :test_xmlschema, "raising Joda errors recently, #2237"