Skip to content

Apache Lucene open-source search software

Clean up forbiddenapis: No need to serialize and deserialize the package private class

Uwe Schindler67ca244ef1b0
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/CharBlockArray.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/CharBlockArray.java
index f358ed41836..f0d2a58adb6 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/CharBlockArray.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/CharBlockArray.java
@@ -16,15 +16,9 @@
*/
package org.apache.lucene.facet.taxonomy.writercache;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import org.apache.lucene.util.SuppressForbidden;
/**
* Similar to {@link StringBuilder}, but with a more efficient growing strategy. This class uses
@@ -185,34 +179,4 @@ class CharBlockArray implements Appendable, Serializable, CharSequence {
}
return sb.toString();
}
-
- @SuppressForbidden(
- reason = "TODO: don't use java serialization here, inefficient and unnecessary")
- void flush(OutputStream out) throws IOException {
- ObjectOutputStream oos = null;
- try {
- oos = new ObjectOutputStream(out);
- oos.writeObject(this);
- oos.flush();
- } finally {
- if (oos != null) {
- oos.close();
- }
- }
- }
-
- @SuppressForbidden(
- reason = "TODO: don't use java serialization here, inefficient and unnecessary")
- public static CharBlockArray open(InputStream in) throws IOException, ClassNotFoundException {
- ObjectInputStream ois = null;
- try {
- ois = new ObjectInputStream(in);
- CharBlockArray a = (CharBlockArray) ois.readObject();
- return a;
- } finally {
- if (ois != null) {
- ois.close();
- }
- }
- }
}
diff --git a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCharBlockArray.java b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCharBlockArray.java
index f918ed5e150..3c3ae4938a0 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCharBlockArray.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCharBlockArray.java
@@ -16,14 +16,10 @@
*/
package org.apache.lucene.facet.taxonomy.writercache;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
import java.nio.ByteBuffer;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
import org.apache.lucene.facet.FacetTestCase;
public class TestCharBlockArray extends FacetTestCase {
@@ -89,19 +85,6 @@ public class TestCharBlockArray extends FacetTestCase {
}
assertEqualsInternal("GrowingCharArray<->StringBuilder mismatch.", builder, array);
-
- Path tempDir = createTempDir("growingchararray");
- Path f = tempDir.resolve("GrowingCharArrayTest.tmp");
- BufferedOutputStream out = new BufferedOutputStream(Files.newOutputStream(f));
- array.flush(out);
- out.flush();
- out.close();
-
- BufferedInputStream in = new BufferedInputStream(Files.newInputStream(f));
- array = CharBlockArray.open(in);
- assertEqualsInternal(
- "GrowingCharArray<->StringBuilder mismatch after flush/load.", builder, array);
- in.close();
}
private static void assertEqualsInternal(