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

This commit is contained in:
Uwe Schindler 2024-09-05 14:37:04 +02:00
parent 87bc8270ff
commit 67ca244ef1
2 changed files with 0 additions and 53 deletions

View File

@ -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();
}
}
}
}

View File

@ -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(