Skip to content

Commit

Permalink
Merge branch 'refs/heads/refactor/YamlOutputStreamWriter' into refact…
Browse files Browse the repository at this point in the history
…or/StreamReader
  • Loading branch information
aSemy committed May 11, 2024
2 parents d7d6fca + ef584aa commit a8149be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ import java.nio.charset.Charset
* @param out the output
* @param cs encoding to use to translate String to bytes
*/
abstract class YamlOutputStreamWriter(
open class YamlOutputStreamWriter(
out: OutputStream,
cs: Charset,
) : OutputStreamWriter(out, cs), StreamDataWriter {
/**
* to be implemented
*
* @param e - the reason
*/
abstract fun processIOException(e: IOException?)

/** Handle [IOException]s thrown while writing. */
open fun processIOException(e: IOException) {
throw e
}

override fun flush() {
try {
Expand Down
7 changes: 1 addition & 6 deletions src/jvmTest/java/org/snakeyaml/engine/v2/api/DumpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,7 @@ void dumpToFile() throws IOException {
assertFalse(file.exists());
file.getParentFile().mkdirs();
file.createNewFile();
StreamDataWriter writer = new YamlOutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8) {
@Override
public void processIOException(IOException e) {
throw new RuntimeException(e);
}
};
StreamDataWriter writer = new YamlOutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8);
dump.dump(ImmutableMap.of("x", 1, "y", 2, "z", 3), writer);
assertTrue(file.exists());
file.delete();// on Windows the file is not deleted
Expand Down

0 comments on commit a8149be

Please sign in to comment.