mirror of https://github.com/apache/lucene.git
SOLR-11012: Fix three (JavaBinCodec not being closed) Resource Leak warnings.
This commit is contained in:
parent
abdb7292db
commit
e23ac243ef
|
@ -69,6 +69,8 @@ Bug Fixes
|
|||
* SOLR-8984: EnumField's error reporting to now indicate the field name in failure log (Lanny Ripple,
|
||||
Ann Addicks via Ishan Chattopadhyaya)
|
||||
|
||||
* SOLR-11012: Fix three (JavaBinCodec not being closed) Resource Leak warnings. (Christine Poerschke)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -183,12 +183,14 @@ public class TestUtils extends SolrTestCaseJ4 {
|
|||
|
||||
public void testBinaryCommands() throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
new JavaBinCodec().marshal((MapWriter) ew -> {
|
||||
ew.put("set-user", fromJSONString("{x:y}"));
|
||||
ew.put("set-user", fromJSONString("{x:y,x1:y1}"));
|
||||
ew.put("single", Arrays.asList(fromJSONString("[{x:y,x1:y1},{x2:y2}]"), fromJSONString( "{x2:y2}")));
|
||||
ew.put("multi", Arrays.asList(fromJSONString("{x:y,x1:y1}"), fromJSONString( "{x2:y2}")));
|
||||
}, baos);
|
||||
try (final JavaBinCodec jbc = new JavaBinCodec()) {
|
||||
jbc.marshal((MapWriter) ew -> {
|
||||
ew.put("set-user", fromJSONString("{x:y}"));
|
||||
ew.put("set-user", fromJSONString("{x:y,x1:y1}"));
|
||||
ew.put("single", Arrays.asList(fromJSONString("[{x:y,x1:y1},{x2:y2}]"), fromJSONString( "{x2:y2}")));
|
||||
ew.put("multi", Arrays.asList(fromJSONString("{x:y,x1:y1}"), fromJSONString( "{x2:y2}")));
|
||||
}, baos);
|
||||
}
|
||||
|
||||
ContentStream stream = new ContentStreamBase.ByteArrayStream(baos.toByteArray(),null, "application/javabin");
|
||||
List<CommandOperation> commands = CommandOperation.readCommands(Collections.singletonList(stream), new NamedList(), Collections.singleton("single"));
|
||||
|
|
|
@ -245,14 +245,16 @@ public class CommandOperation {
|
|||
}
|
||||
};
|
||||
|
||||
new JavaBinCodec() {
|
||||
try (final JavaBinCodec jbc = new JavaBinCodec() {
|
||||
int level = 0;
|
||||
@Override
|
||||
protected Map<Object, Object> newMap(int size) {
|
||||
level++;
|
||||
return level == 1 ? map : super.newMap(size);
|
||||
}
|
||||
}.unmarshal(in);
|
||||
}) {
|
||||
jbc.unmarshal(in);
|
||||
}
|
||||
return operations;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,9 +106,11 @@ public class Utils {
|
|||
}
|
||||
|
||||
public static InputStream toJavabin(Object o) throws IOException {
|
||||
BinaryRequestWriter.BAOS baos = new BinaryRequestWriter.BAOS();
|
||||
new JavaBinCodec().marshal(o,baos);
|
||||
return new ByteBufferInputStream(ByteBuffer.wrap(baos.getbuf(),0,baos.size()));
|
||||
try (final JavaBinCodec jbc = new JavaBinCodec()) {
|
||||
BinaryRequestWriter.BAOS baos = new BinaryRequestWriter.BAOS();
|
||||
jbc.marshal(o,baos);
|
||||
return new ByteBufferInputStream(ByteBuffer.wrap(baos.getbuf(),0,baos.size()));
|
||||
}
|
||||
}
|
||||
|
||||
public static Collection getDeepCopy(Collection c, int maxDepth, boolean mutable) {
|
||||
|
|
Loading…
Reference in New Issue