You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Benedikt Ritter <br...@apache.org> on 2016/06/18 11:03:41 UTC
Re: svn commit: r1748880 - /commons/proper/bcel/trunk/src/test/java/org/apache/bcel/ElementValueGenTestCase.java
Hello Gary,
please check your IDE settings. This commit has replaced spaces with tabs
for indentation. I've corrected this.
Benedikt
<gg...@apache.org> schrieb am Fr., 17. Juni 2016 um 19:41 Uhr:
> Author: ggregory
> Date: Fri Jun 17 17:41:52 2016
> New Revision: 1748880
>
> URL: http://svn.apache.org/viewvc?rev=1748880&view=rev
> Log:
> Use try-with-resources.
>
> Modified:
>
> commons/proper/bcel/trunk/src/test/java/org/apache/bcel/ElementValueGenTestCase.java
>
> Modified:
> commons/proper/bcel/trunk/src/test/java/org/apache/bcel/ElementValueGenTestCase.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/test/java/org/apache/bcel/ElementValueGenTestCase.java?rev=1748880&r1=1748879&r2=1748880&view=diff
>
> ==============================================================================
> ---
> commons/proper/bcel/trunk/src/test/java/org/apache/bcel/ElementValueGenTestCase.java
> (original)
> +++
> commons/proper/bcel/trunk/src/test/java/org/apache/bcel/ElementValueGenTestCase.java
> Fri Jun 17 17:41:52 2016
> @@ -209,32 +209,24 @@ public class ElementValueGenTestCase ext
> checkSerialize(evg, cp);
> }
>
> - private void checkSerialize(final ElementValueGen evgBefore, final
> ConstantPoolGen cpg)
> - {
> - try
> - {
> - String beforeValue = evgBefore.stringifyValue();
> - ByteArrayOutputStream baos = new ByteArrayOutputStream();
> - DataOutputStream dos = new DataOutputStream(baos);
> - evgBefore.dump(dos);
> - dos.flush();
> - dos.close();
> - byte[] bs = baos.toByteArray();
> - ByteArrayInputStream bais = new ByteArrayInputStream(bs);
> - DataInputStream dis = new DataInputStream(bais);
> - ElementValueGen evgAfter =
> ElementValueGen.readElementValue(dis,
> - cpg);
> - dis.close();
> - String afterValue = evgAfter.stringifyValue();
> - if (!beforeValue.equals(afterValue))
> - {
> - fail("Deserialization failed: before='" + beforeValue
> - + "' after='" + afterValue + "'");
> - }
> - }
> - catch (IOException ioe)
> - {
> - fail("Unexpected exception whilst checking serialization: " +
> ioe);
> - }
> - }
> + private void checkSerialize(final ElementValueGen evgBefore, final
> ConstantPoolGen cpg) {
> + try {
> + String beforeValue = evgBefore.stringifyValue();
> + ByteArrayOutputStream baos = new
> ByteArrayOutputStream();
> + try (DataOutputStream dos = new
> DataOutputStream(baos)) {
> + evgBefore.dump(dos);
> + dos.flush();
> + }
> + ElementValueGen evgAfter;
> + try (DataInputStream dis = new DataInputStream(new
> ByteArrayInputStream(baos.toByteArray()))) {
> + evgAfter =
> ElementValueGen.readElementValue(dis, cpg);
> + }
> + String afterValue = evgAfter.stringifyValue();
> + if (!beforeValue.equals(afterValue)) {
> + fail("Deserialization failed: before='" +
> beforeValue + "' after='" + afterValue + "'");
> + }
> + } catch (IOException ioe) {
> + fail("Unexpected exception whilst checking
> serialization: " + ioe);
> + }
> + }
> }
>
>
>