summaryrefslogtreecommitdiff
path: root/ext/java/org/jruby/ext/psych/PsychEmitter.java
diff options
context:
space:
mode:
Diffstat (limited to 'ext/java/org/jruby/ext/psych/PsychEmitter.java')
-rw-r--r--ext/java/org/jruby/ext/psych/PsychEmitter.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/java/org/jruby/ext/psych/PsychEmitter.java b/ext/java/org/jruby/ext/psych/PsychEmitter.java
index ecaf2e5..ec71b93 100644
--- a/ext/java/org/jruby/ext/psych/PsychEmitter.java
+++ b/ext/java/org/jruby/ext/psych/PsychEmitter.java
@@ -336,6 +336,9 @@ public class PsychEmitter extends RubyObject {
if (emitter == null) throw context.runtime.newRuntimeError("uninitialized emitter");
emitter.emit(event);
+
+ // flush writer after each emit
+ writer.flush();
} catch (IOException ioe) {
throw context.runtime.newIOErrorFromException(ioe);
} catch (EmitterException ee) {
@@ -349,10 +352,12 @@ public class PsychEmitter extends RubyObject {
Encoding encoding = PsychLibrary.YAMLEncoding.values()[(int)_encoding.convertToInteger().getLongValue()].encoding;
Charset charset = context.runtime.getEncodingService().charsetForEncoding(encoding);
- emitter = new Emitter(new OutputStreamWriter(new IOOutputStream(io, encoding), charset), options);
+ writer = new OutputStreamWriter(new IOOutputStream(io, encoding), charset);
+ emitter = new Emitter(writer, options);
}
Emitter emitter;
+ Writer writer;
DumperOptions options = new DumperOptions();
IRubyObject io;