Skip to content

Commit

Permalink
fix: don't close PrintStream when using printCell
Browse files Browse the repository at this point in the history
...to avoid closing System.out which is used in most cases as target for
printing a Cell in tests, which lead to incomplete output from tests.
  • Loading branch information
stempler committed Mar 14, 2024
1 parent ef7226d commit ca99edf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Import-Package: com.google.common.base;version="1.6.0",
eu.esdihumboldt.util.io,
javax.annotation;version="[1.2.0,1.2.0]",
net.jcip.annotations,
org.apache.commons.io.output,
org.apache.commons.lang;version="2.4.0",
org.locationtech.jts.geom,
org.slf4j;version="1.5.11",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.URI;

import org.apache.commons.io.output.CloseShieldOutputStream;

import eu.esdihumboldt.hale.common.align.io.EntityResolver;
import eu.esdihumboldt.hale.common.align.io.impl.internal.AlignmentToJaxb;
import eu.esdihumboldt.hale.common.align.io.impl.internal.JaxbToAlignment;
Expand Down Expand Up @@ -171,7 +174,21 @@ public static void save(AlignmentType alignment, IOReporter reporter, OutputStre
}

/**
* Print a cell to an output stream (intended for tests/debugging).
* Print a cell to a {@link PrintStream} (intended for tests/debugging). The
* stream is prevented from being closed, which is intended to prevent for
* instance System.out from being closed.
*
* @param cell the cell to print
* @param out the output stream
* @throws Exception if an error occurs trying to print the cell
*/
public static void printCell(MutableCell cell, PrintStream out) throws Exception {
printCell(cell, CloseShieldOutputStream.wrap(out));
}

/**
* Print a cell to an output stream (intended for tests/debugging). The
* stream is closed when the cell was written.
*
* @param cell the cell to print
* @param out the output stream
Expand Down

0 comments on commit ca99edf

Please sign in to comment.