Skip to content

Commit

Permalink
copy the old eventHooks list when adding a new eventHook
Browse files Browse the repository at this point in the history
fixes #2296

Sponsored by Lookout Inc.
  • Loading branch information
mkristian committed Dec 11, 2014
1 parent ff3d32c commit 2746b56
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/src/main/java/org/jruby/Ruby.java
Expand Up @@ -44,6 +44,7 @@
import jnr.constants.platform.Errno;
import jnr.posix.POSIX;
import jnr.posix.POSIXFactory;

import org.jcodings.Encoding;
import org.joda.time.DateTimeZone;
import org.jruby.RubyInstanceConfig.CompileMode;
Expand Down Expand Up @@ -156,6 +157,7 @@
import java.security.AccessControlException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
Expand All @@ -180,6 +182,7 @@
import java.util.regex.Pattern;

import static org.jruby.internal.runtime.GlobalVariable.Scope.*;

import org.jruby.internal.runtime.methods.CallConfiguration;
import org.jruby.internal.runtime.methods.JavaMethod;
import org.jruby.util.cli.Options;
Expand Down Expand Up @@ -3025,7 +3028,7 @@ public synchronized void addEventHook(EventHook hook) {
}

EventHook[] hooks = eventHooks;
EventHook[] newHooks = new EventHook[hooks.length + 1];
EventHook[] newHooks = Arrays.copyOf(hooks, hooks.length + 1);
newHooks[hooks.length] = hook;
eventHooks = newHooks;
hasEventHooks = true;
Expand Down

0 comments on commit 2746b56

Please sign in to comment.