-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reproduce exception with PriorityQueue with lambda expression
- Loading branch information
1 parent
396eacf
commit 3f1f826
Showing
3 changed files
with
76 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
chill-java/src/test/java/com/twitter/chill/java/TestPriorityQueue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.twitter.chill.java; | ||
|
||
import com.esotericsoftware.kryo.Kryo; | ||
import com.esotericsoftware.kryo.io.Input; | ||
import com.esotericsoftware.kryo.io.Output; | ||
|
||
import java.util.Comparator; | ||
import java.util.PriorityQueue; | ||
|
||
public class TestPriorityQueue { | ||
|
||
private static final Kryo kryo = new Kryo(); | ||
|
||
private static final PriorityQueue<String> test_priority_queue1 = | ||
new PriorityQueue<>((o1, o2) -> o1.length() - o2.length() - 1); | ||
|
||
private static final PriorityQueue<String> test_priority_queue2 = | ||
new PriorityQueue<>(new Comparator<String>() { | ||
@Override | ||
public int compare(String o1, String o2) { | ||
return o1.length() - o2.length() - 1; | ||
} | ||
}); | ||
|
||
static { | ||
test_priority_queue1.add("12345"); | ||
test_priority_queue1.add("123"); | ||
test_priority_queue1.add("12456789"); | ||
|
||
test_priority_queue2.add("12345"); | ||
test_priority_queue2.add("123"); | ||
test_priority_queue2.add("12456789"); | ||
} | ||
|
||
public static PriorityQueue<String> serializeAndDeserializeQueue1() { | ||
Output output = new Output(1000, -1); | ||
kryo.writeClassAndObject(output, test_priority_queue1); | ||
Input input = new Input(output.toBytes()); | ||
return (PriorityQueue<String>) kryo.readClassAndObject(input); | ||
} | ||
|
||
public static PriorityQueue<String> serializeAndDeserializeQueue1(Kryo kryo) { | ||
Output output = new Output(1000, -1); | ||
kryo.writeClassAndObject(output, test_priority_queue1); | ||
Input input = new Input(output.toBytes()); | ||
return (PriorityQueue<String>) kryo.readClassAndObject(input); | ||
} | ||
|
||
public static PriorityQueue<String> serializeAndDeserializeQueue2(Kryo kryo) { | ||
Output output = new Output(1000, -1); | ||
kryo.writeClassAndObject(output, test_priority_queue2); | ||
Input input = new Input(output.toBytes()); | ||
return (PriorityQueue<String>) kryo.readClassAndObject(input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters