Skip to content

Commit

Permalink
apache#683 - Replace internal proprietary API sun.reflect.ReflectionF…
Browse files Browse the repository at this point in the history
…actory with Objenisis API
  • Loading branch information
vcottagiri committed Jul 17, 2020
1 parent 5bc6ee7 commit 6e23ec2
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions testmocks/src/main/java/org/apache/zookeeper/MockZooKeeper.java
Expand Up @@ -18,7 +18,13 @@
*/
package org.apache.zookeeper;

import java.lang.reflect.Constructor;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimaps;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
import io.netty.util.concurrent.DefaultThreadFactory;
import java.util.List;
import java.util.Optional;
import java.util.Set;
Expand All @@ -30,7 +36,6 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.BiPredicate;

import org.apache.commons.lang3.tuple.Pair;
import org.apache.zookeeper.AsyncCallback.Children2Callback;
import org.apache.zookeeper.AsyncCallback.ChildrenCallback;
Expand All @@ -48,16 +53,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.HashMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimaps;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;

import io.netty.util.concurrent.DefaultThreadFactory;

@SuppressWarnings({ "deprecation", "restriction", "rawtypes" })
public class MockZooKeeper extends ZooKeeper {
private TreeMap<String, Pair<byte[], Integer>> tree;
private SetMultimap<String, Watcher> watchers;
Expand Down Expand Up @@ -100,7 +95,7 @@ public static MockZooKeeper newInstance(ExecutorService executor) {

public static MockZooKeeper newInstance(ExecutorService executor, int readOpDelayMs) {
try {
ObjectInstantiator mockZooKeeperInstantiator = objenesis.getInstantiatorOf(MockZooKeeper.class);
ObjectInstantiator<MockZooKeeper> mockZooKeeperInstantiator = objenesis.getInstantiatorOf(MockZooKeeper.class);
MockZooKeeper zk = (MockZooKeeper) mockZooKeeperInstantiator.newInstance();
zk.init(executor);
zk.readOpDelayMs = readOpDelayMs;
Expand Down

0 comments on commit 6e23ec2

Please sign in to comment.