Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Disable tracing during env duping for JRUBY-6603.

  • Loading branch information...
commit 73ab8cb3b24796efbed0d63a6ebafb7e57ce19a2 1 parent 2251661
@headius headius authored
Showing with 30 additions and 18 deletions.
  1. +30 −18 src/org/jruby/util/ShellLauncher.java
View
48 src/org/jruby/util/ShellLauncher.java
@@ -215,26 +215,38 @@ private void closeStreams() {
}
private static String[] getCurrentEnv(Ruby runtime, Map mergeEnv) {
- RubyHash hash = (RubyHash)runtime.getObject().getConstant("ENV").dup();
- String[] ret;
-
- if (mergeEnv != null && !mergeEnv.isEmpty()) {
- ret = new String[hash.size() + mergeEnv.size()];
- } else {
- ret = new String[hash.size()];
- }
+ ThreadContext context = runtime.getCurrentContext();
- int i=0;
- for(Map.Entry e : (Set<Map.Entry>)hash.directEntrySet()) {
- ret[i] = e.getKey().toString() + "=" + e.getValue().toString();
- i++;
- }
- if (mergeEnv != null) for(Map.Entry e : (Set<Map.Entry>)mergeEnv.entrySet()) {
- ret[i] = e.getKey().toString() + "=" + e.getValue().toString();
- i++;
- }
+ // disable tracing for the dup call below
+ boolean traceEnabled = context.isEventHooksEnabled();
+ context.setEventHooksEnabled(false);
+
+ try {
+ // dup for JRUBY-6603 (avoid concurrent modification while we walk it)
+ RubyHash hash = (RubyHash)runtime.getObject().getConstant("ENV").dup();
+ String[] ret;
- return ret;
+ if (mergeEnv != null && !mergeEnv.isEmpty()) {
+ ret = new String[hash.size() + mergeEnv.size()];
+ } else {
+ ret = new String[hash.size()];
+ }
+
+ int i=0;
+ for(Map.Entry e : (Set<Map.Entry>)hash.directEntrySet()) {
+ ret[i] = e.getKey().toString() + "=" + e.getValue().toString();
+ i++;
+ }
+ if (mergeEnv != null) for(Map.Entry e : (Set<Map.Entry>)mergeEnv.entrySet()) {
+ ret[i] = e.getKey().toString() + "=" + e.getValue().toString();
+ i++;
+ }
+
+ return ret;
+
+ } finally {
+ context.setEventHooksEnabled(traceEnabled);
+ }
}
private static boolean filenameIsPathSearchable(String fname, boolean forExec) {
Please sign in to comment.
Something went wrong with that request. Please try again.