@Override public void close() { synchronized (lock) { try { out.close(); } catch (SegmentSealedException e) { log.warn("Error closing segment writer {}", out); } conditional.close(); meta.close(); in.close(); } } }
@Test public void testClose() throws SegmentSealedException { MockConnectionFactoryImpl connectionFactory = new MockConnectionFactoryImpl(); MockController controller = new MockController("localhost", 0, connectionFactory); ConditionalOutputStreamFactory factory = new ConditionalOutputStreamFactoryImpl(controller, connectionFactory); Segment segment = new Segment("scope", "testWrite", 1); ConditionalOutputStream cOut = factory.createConditionalOutputStream(segment, "token", EventWriterConfig.builder().build()); cOut.close(); AssertExtensions.assertThrows(IllegalStateException.class, () -> cOut.write(ByteBuffer.allocate(0), 0)); }