Skip to content
Merged
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
10 changes: 6 additions & 4 deletions core/src/main/java/org/jruby/runtime/load/LibrarySearcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,10 @@ public synchronized char matches(String feature, Suffix suffix, int len, boolean
private final List<IRubyObject> featurePaths;
}

private final ThreadLocal<StringWrapper> keyWrapper = ThreadLocal.withInitial(() -> new StringWrapper(null, 0, 0));
private final ThreadLocal<StringWrapper> rangeWrapper = ThreadLocal.withInitial(() -> new StringWrapper(null, 0, 0));
// Only used while holding this searcher's lock. They are not thread-locals, because a thread would keep its
// wrappers after the runtime is torn down, and with them the class loader that loaded JRuby.
private final StringWrapper keyWrapper = new StringWrapper(null, 0, 0);
private final StringWrapper rangeWrapper = new StringWrapper(null, 0, 0);

protected synchronized void addSingleFeatureToIndex(String key, int beg, int end, IRubyObject featurePath) {
Map<StringWrapper, Feature> featuresIndex = this.loadedFeaturesIndex;
Expand All @@ -555,13 +557,13 @@ private synchronized void releaseWrapper(StringWrapper wrapper) {
}

private synchronized StringWrapper keyWrapper(String key) {
StringWrapper wrapper = keyWrapper.get();
StringWrapper wrapper = keyWrapper;
wrapper.rewrap(key, 0, key.length());
return wrapper;
}

private synchronized StringWrapper rangeWrapper(String key, int beg, int len) {
StringWrapper wrapper = rangeWrapper.get();
StringWrapper wrapper = rangeWrapper;
wrapper.rewrap(key, beg, len);
return wrapper;
}
Expand Down
Loading