### Question:
JsonGeneratorImpl implements JsonGenerator, JsonChars, Serializable { @Override public void close() { if (closed) { return; } JsonGenerationException ex = null; final GeneratorState state = currentState(); if (state != GeneratorState.END && state != GeneratorState.ROOT_VALUE) { ex = new JsonGenerationException("Invalid json"); } try { if (ex == null) { flushBuffer(); } writer.close(); } catch (final IOException e) { if (ex != null) { throw ex; } throw new JsonException(e.getMessage(), e); } finally { closed = true; bufferProvider.release(buffer); } if (ex != null) { throw ex; } } JsonGeneratorImpl(final Writer writer, final BufferStrategy.BufferProvider<char[]> bufferProvider,
                      final boolean prettyPrint);   JsonGeneratorImpl(final OutputStream out, final BufferStrategy.BufferProvider<char[]> bufferProvider,
                      final boolean prettyPrint);   JsonGeneratorImpl(final OutputStream out, final Charset encoding, final BufferStrategy.BufferProvider<char[]> bufferProvider,
                      final boolean prettyPrint); @Override JsonGenerator writeStartObject(); @Override JsonGenerator writeStartObject(final String name); @Override JsonGenerator writeStartArray(); @Override JsonGenerator writeStartArray(final String name); @Override JsonGenerator write(final String name, final JsonValue value); @Override JsonGenerator write(final String name, final String value); @Override JsonGenerator write(final String name, final BigInteger value); @Override JsonGenerator write(final String name, final BigDecimal value); @Override JsonGenerator write(final String name, final int value); @Override JsonGenerator write(final String name, final long value); @Override JsonGenerator write(final String name, final double value); @Override JsonGenerator write(final String name, final boolean value); @Override JsonGenerator writeNull(final String name); @Override JsonGenerator writeEnd(); @Override JsonGenerator write(final JsonValue value); @Override JsonGenerator write(final String value); @Override JsonGenerator write(final BigDecimal value); @Override JsonGenerator write(final BigInteger value); @Override JsonGenerator write(final int value); @Override JsonGenerator write(final long value); @Override JsonGenerator write(final double value); @Override JsonGenerator write(final boolean value); @Override JsonGenerator writeNull(); @Override JsonGenerator writeKey(final String key); @Override void close(); @Override void flush();  }### Answer:
@Test(expected=JsonGenerationException.class) public void fail5() { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); Json.createGenerator(baos) .close(); }