james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1481112 - in /james/mime4j/trunk/core/src: main/java/org/apache/james/mime4j/codec/ main/java/org/apache/james/mime4j/stream/ test/java/org/apache/james/mime4j/codec/ test/java/org/apache/james/mime4j/io/ test/java/org/apache/james/mime4j/...
Date Fri, 10 May 2013 17:22:37 GMT
Author: olegk
Date: Fri May 10 17:22:34 2013
New Revision: 1481112

URL: http://svn.apache.org/r1481112
Log:
Fixed resource leak warnings

Modified:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/codec/EncoderUtil.java
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/codec/Base64InputStreamTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamBufferTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/EOLConvertingInputStreamTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LimitedInputStreamTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineNumberInputStreamTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptorTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/PositionInputStreamTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/codec/EncoderUtil.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/codec/EncoderUtil.java?rev=1481112&r1=1481111&r2=1481112&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/codec/EncoderUtil.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/codec/EncoderUtil.java Fri
May 10 17:22:34 2013
@@ -380,8 +380,6 @@ public class EncoderUtil {
                 : Q_RESTRICTED_CHARS;
 
         StringBuilder sb = new StringBuilder();
-
-        final int end = bytes.length;
         for (byte aByte : bytes) {
             int v = aByte & 0xff;
             if (v == 32) {

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java?rev=1481112&r1=1481111&r2=1481112&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
Fri May 10 17:22:34 2013
@@ -29,7 +29,6 @@ import java.util.LinkedList;
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.codec.DecodeMonitor;
 import org.apache.james.mime4j.io.LineNumberInputStream;
-import org.apache.james.mime4j.io.LineNumberSource;
 import org.apache.james.mime4j.util.CharsetUtil;
 
 /**
@@ -178,23 +177,29 @@ public class MimeTokenStream {
     }
 
     private void doParse(InputStream stream, EntityState start) {
-        LineNumberSource lineSource = null;
         if (config.isCountLineNumbers()) {
-            LineNumberInputStream lineInput = new LineNumberInputStream(stream);
-            lineSource = lineInput;
-            stream = lineInput;
+            LineNumberInputStream lnstream = new LineNumberInputStream(stream);
+            rootentity = new MimeEntity(
+                    lnstream,
+                    lnstream,
+                    config,
+                    start,
+                    EntityState.T_END_MESSAGE,
+                    monitor,
+                    fieldBuilder,
+                    bodyDescBuilder);
+        } else {
+            rootentity = new MimeEntity(
+                    null,
+                    stream,
+                    config,
+                    start,
+                    EntityState.T_END_MESSAGE,
+                    monitor,
+                    fieldBuilder,
+                    bodyDescBuilder);
         }
 
-        rootentity = new MimeEntity(
-                lineSource,
-                stream,
-                config,
-                start,
-                EntityState.T_END_MESSAGE,
-                monitor,
-                fieldBuilder,
-                bodyDescBuilder);
-
         rootentity.setRecursionMode(recursionMode);
         currentStateMachine = rootentity;
         entities.clear();

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/codec/Base64InputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/codec/Base64InputStreamTest.java?rev=1481112&r1=1481111&r2=1481112&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/codec/Base64InputStreamTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/codec/Base64InputStreamTest.java
Fri May 10 17:22:34 2013
@@ -173,6 +173,7 @@ public class Base64InputStreamTest {
             for (int i = 0; i < data.length; i++) {
                 Assert.assertEquals(data[i], decoded[i]);
             }
+            decoder.close();
         }
     }
 
@@ -192,6 +193,7 @@ public class Base64InputStreamTest {
                 break;
             out.write(x);
         }
+        decoder.close();
 
         Assert.assertEquals("This is the plain text message!", toString(out
                 .toByteArray()));
@@ -213,6 +215,7 @@ public class Base64InputStreamTest {
                 break;
             i += bytes;
         }
+        decoder.close();
 
         Assert.assertEquals("This is the plain text message!\0\0\0\0\0",
                 toString(data));

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamBufferTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamBufferTest.java?rev=1481112&r1=1481111&r2=1481112&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamBufferTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamBufferTest.java
Fri May 10 17:22:34 2013
@@ -32,7 +32,8 @@ public class BufferedLineReaderInputStre
         byte[] b1 = text.getBytes("US-ASCII");
         String pattern = "blah";
         byte[] b2 = pattern.getBytes("US-ASCII");
-        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1),
4096);
+        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(b1), 4096);
         inbuffer.fillBuffer();
 
         Assert.assertEquals('b', inbuffer.read());
@@ -90,13 +91,15 @@ public class BufferedLineReaderInputStre
         } catch (IndexOutOfBoundsException expected) {
         }
         Assert.assertEquals(10, inbuffer.indexOf((byte) 'y', 2, 17));
+        inbuffer.close();
     }
 
     @Test
     public void testBasicOperations() throws Exception {
         String text = "bla bla yada yada haha haha";
         byte[] b1 = text.getBytes("US-ASCII");
-        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1),
4096);
+        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(b1), 4096);
         inbuffer.fillBuffer();
         Assert.assertEquals(0, inbuffer.pos());
         Assert.assertEquals(27, inbuffer.limit());
@@ -127,6 +130,8 @@ public class BufferedLineReaderInputStre
         Assert.assertEquals(-1, inbuffer.read(tmp1));
         Assert.assertEquals(-1, inbuffer.read());
         Assert.assertEquals(-1, inbuffer.read());
+
+        inbuffer.close();
     }
 
     @Test
@@ -135,10 +140,13 @@ public class BufferedLineReaderInputStre
         String pattern = "d";
         byte[] b1 = text.getBytes("US-ASCII");
         byte[] b2 = pattern.getBytes("US-ASCII");
-        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1),
4096);
+        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(b1), 4096);
         inbuffer.fillBuffer();
         int i = inbuffer.indexOf(b2);
         Assert.assertEquals(7, i);
+
+        inbuffer.close();
     }
 
     @Test
@@ -147,10 +155,13 @@ public class BufferedLineReaderInputStre
         String pattern = "siid";
         byte[] b1 = text.getBytes("US-ASCII");
         byte[] b2 = pattern.getBytes("US-ASCII");
-        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1),
4096);
+        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(b1), 4096);
         inbuffer.fillBuffer();
         int i = inbuffer.indexOf(b2);
         Assert.assertEquals(18, i);
+
+        inbuffer.close();
     }
 
     @Test
@@ -159,10 +170,13 @@ public class BufferedLineReaderInputStre
         String pattern = "blah";
         byte[] b1 = text.getBytes("US-ASCII");
         byte[] b2 = pattern.getBytes("US-ASCII");
-        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1),
4096);
+        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(b1), 4096);
         inbuffer.fillBuffer();
         int i = inbuffer.indexOf(b2);
         Assert.assertEquals(-1, i);
+
+        inbuffer.close();
     }
 
     @Test
@@ -171,10 +185,13 @@ public class BufferedLineReaderInputStre
         String pattern = "bla";
         byte[] b1 = text.getBytes("US-ASCII");
         byte[] b2 = pattern.getBytes("US-ASCII");
-        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1),
4096);
+        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(b1), 4096);
         inbuffer.fillBuffer();
         int i = inbuffer.indexOf(b2);
         Assert.assertEquals(0, i);
+
+        inbuffer.close();
     }
 
     @Test
@@ -183,7 +200,8 @@ public class BufferedLineReaderInputStre
         String pattern1 = "bla bla";
         byte[] b1 = text.getBytes("US-ASCII");
         byte[] b2 = pattern1.getBytes("US-ASCII");
-        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1),
4096);
+        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(b1), 4096);
         inbuffer.fillBuffer();
         byte[] tmp = new byte[3];
         inbuffer.read(tmp);
@@ -191,13 +209,16 @@ public class BufferedLineReaderInputStre
         Assert.assertEquals(-1, i);
         i = inbuffer.indexOf(b2, inbuffer.pos(), inbuffer.length() - 1);
         Assert.assertEquals(-1, i);
+
+        inbuffer.close();
     }
 
     @Test
     public void testCharOutOfBound() throws Exception {
         String text = "zzz blah blah blah ggg";
         byte[] b1 = text.getBytes("US-ASCII");
-        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1),
4096);
+        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(b1), 4096);
         inbuffer.fillBuffer();
         byte[] tmp = new byte[3];
         inbuffer.read(tmp);
@@ -205,15 +226,20 @@ public class BufferedLineReaderInputStre
         Assert.assertEquals(-1, i);
         i = inbuffer.indexOf((byte) 'g', inbuffer.pos(), inbuffer.length() - 3);
         Assert.assertEquals(-1, i);
+
+        inbuffer.close();
     }
 
     @Test
     public void test0xFFInBinaryStream() throws Exception {
         byte[] b1 = new byte[]{1, 2, 3, (byte) 0xff, 10, 1, 2, 3};
         byte[] b2 = new byte[]{10};
-        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1),
4096);
+        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(b1), 4096);
         inbuffer.fillBuffer();
         int i = inbuffer.indexOf(b2);
         Assert.assertEquals(4, i);
+
+        inbuffer.close();
     }
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamTest.java?rev=1481112&r1=1481111&r2=1481112&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/BufferedLineReaderInputStreamTest.java
Fri May 10 17:22:34 2013
@@ -32,7 +32,8 @@ public class BufferedLineReaderInputStre
     public void testBasicOperations() throws Exception {
         String text = "ah blahblah";
         byte[] b1 = text.getBytes("US-ASCII");
-        BufferedLineReaderInputStream instream = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1),
4096);
+        BufferedLineReaderInputStream instream = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(b1), 4096);
 
         Assert.assertEquals((byte) 'a', instream.read());
         Assert.assertEquals((byte) 'h', instream.read());
@@ -46,6 +47,8 @@ public class BufferedLineReaderInputStre
         Assert.assertEquals(-1, instream.read(tmp1));
         Assert.assertEquals(-1, instream.read());
         Assert.assertEquals(-1, instream.read());
+
+        instream.close();
     }
 
     @Test
@@ -71,7 +74,8 @@ public class BufferedLineReaderInputStre
         }
         byte[] raw = outstream.toByteArray();
 
-        BufferedLineReaderInputStream instream = new BufferedLineReaderInputStream(new ByteArrayInputStream(raw),
16);
+        BufferedLineReaderInputStream instream = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(raw), 16);
 
         ByteArrayBuffer linebuf = new ByteArrayBuffer(8);
         for (String teststr : teststrs) {
@@ -82,6 +86,8 @@ public class BufferedLineReaderInputStre
         }
         Assert.assertEquals(-1, instream.readLine(linebuf));
         Assert.assertEquals(-1, instream.readLine(linebuf));
+
+        instream.close();
     }
 
     @Test
@@ -90,7 +96,8 @@ public class BufferedLineReaderInputStre
         String teststr = "\n\n\r\n\r\r\n\n\n\n\n\n";
         byte[] raw = teststr.getBytes("US-ASCII");
 
-        LineReaderInputStream instream = new BufferedLineReaderInputStream(new ByteArrayInputStream(raw),
4);
+        LineReaderInputStream instream = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(raw), 4);
 
         ByteArrayBuffer linebuf = new ByteArrayBuffer(8);
         linebuf.clear();
@@ -140,6 +147,8 @@ public class BufferedLineReaderInputStre
 
         Assert.assertEquals(-1, instream.readLine(linebuf));
         Assert.assertEquals(-1, instream.readLine(linebuf));
+
+        instream.close();
     }
 
     @Test
@@ -153,6 +162,7 @@ public class BufferedLineReaderInputStre
         ByteArrayBuffer linebuf = new ByteArrayBuffer(8);
         linebuf.clear();
         instream1.readLine(linebuf);
+        instream1.close();
 
         LineReaderInputStream instream2 = new BufferedLineReaderInputStream(
                 new ByteArrayInputStream(raw), 1024, 12);
@@ -162,6 +172,8 @@ public class BufferedLineReaderInputStre
             Assert.fail("MaxLineLimitException should have been thrown");
         } catch (MaxLineLimitException ex) {
         }
+
+        instream2.close();
     }
 
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/EOLConvertingInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/EOLConvertingInputStreamTest.java?rev=1481112&r1=1481111&r2=1481112&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/EOLConvertingInputStreamTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/EOLConvertingInputStreamTest.java
Fri May 10 17:22:34 2013
@@ -73,6 +73,8 @@ public class EOLConvertingInputStreamTes
                         EOLConvertingInputStream.CONVERT_BOTH);
         int n = in.read(bytes);
         Assert.assertEquals(s2, toString(bytes, n));
+
+        in.close();
     }
 
     private void testConvertCR(String s1, String s2) throws IOException {
@@ -84,6 +86,8 @@ public class EOLConvertingInputStreamTes
                         EOLConvertingInputStream.CONVERT_CR);
         int n = in.read(bytes);
         Assert.assertEquals(s2, toString(bytes, n));
+
+        in.close();
     }
 
     private void testConvertLF(String s1, String s2) throws IOException {
@@ -95,6 +99,8 @@ public class EOLConvertingInputStreamTes
                         EOLConvertingInputStream.CONVERT_LF);
         int n = in.read(bytes);
         Assert.assertEquals(s2, toString(bytes, n));
+
+        in.close();
     }
 
     private String toString(byte[] b, int len) {

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LimitedInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LimitedInputStreamTest.java?rev=1481112&r1=1481111&r2=1481112&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LimitedInputStreamTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LimitedInputStreamTest.java
Fri May 10 17:22:34 2013
@@ -53,6 +53,8 @@ public class LimitedInputStreamTest {
             Assert.fail("IOException should have been thrown");
         } catch (IOException ex) {
         }
+
+        limitedStream.close();
     }
 
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineNumberInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineNumberInputStreamTest.java?rev=1481112&r1=1481111&r2=1481112&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineNumberInputStreamTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineNumberInputStreamTest.java
Fri May 10 17:22:34 2013
@@ -52,6 +52,8 @@ public class LineNumberInputStreamTest {
 
         Assert.assertEquals(4, is.getLineNumber());
         Assert.assertEquals(-1, is.read());
+
+        is.close();
     }
 
     /**
@@ -78,5 +80,7 @@ public class LineNumberInputStreamTest {
         Assert.assertEquals(4, is.getLineNumber());
 
         Assert.assertEquals(-1, is.read());
+
+        is.close();
     }
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptorTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptorTest.java?rev=1481112&r1=1481111&r2=1481112&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptorTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/LineReaderInputStreamAdaptorTest.java
Fri May 10 17:22:34 2013
@@ -48,6 +48,8 @@ public class LineReaderInputStreamAdapto
         Assert.assertEquals(-1, instream.read(tmp1));
         Assert.assertEquals(-1, instream.read());
         Assert.assertEquals(-1, instream.read());
+
+        instream.close();
     }
 
     @Test
@@ -85,6 +87,8 @@ public class LineReaderInputStreamAdapto
         }
         Assert.assertEquals(-1, instream.readLine(linebuf));
         Assert.assertEquals(-1, instream.readLine(linebuf));
+
+        instream.close();
     }
 
     @Test
@@ -144,6 +148,8 @@ public class LineReaderInputStreamAdapto
 
         Assert.assertEquals(-1, instream.readLine(linebuf));
         Assert.assertEquals(-1, instream.readLine(linebuf));
+
+        instream.close();
     }
 
     @Test
@@ -158,6 +164,8 @@ public class LineReaderInputStreamAdapto
         linebuf.clear();
         instream1.readLine(linebuf);
 
+        instream1.close();
+
         LineReaderInputStreamAdaptor instream2 = new LineReaderInputStreamAdaptor(
                 new ByteArrayInputStream(raw), 12);
         linebuf.clear();
@@ -166,6 +174,8 @@ public class LineReaderInputStreamAdapto
             Assert.fail("MaxLineLimitException should have been thrown");
         } catch (MaxLineLimitException ex) {
         }
+
+        instream2.close();
     }
 
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java?rev=1481112&r1=1481111&r2=1481112&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/MimeBoundaryInputStreamTest.java
Fri May 10 17:22:34 2013
@@ -185,22 +185,23 @@ public class MimeBoundaryInputStreamTest
      */
     @Test
     public void testImmediateBoundary() throws IOException {
-        String text = "--boundary\r\n";
+        String text1 = "--boundary\r\n";
 
-        ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes());
-        BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096);
+        BufferedLineReaderInputStream buffer1 = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(text1.getBytes()), 4096);
+        MimeBoundaryInputStream stream1 = new MimeBoundaryInputStream(buffer1, "boundary");
+        Assert.assertEquals(-1, stream1.read());
 
-        MimeBoundaryInputStream stream =
-                new MimeBoundaryInputStream(buffer, "boundary");
-        Assert.assertEquals(-1, stream.read());
+        stream1.close();
 
-        text = "\r\n--boundary\r\n";
+        String text2 = "\r\n--boundary\r\n";
 
-        bis = new ByteArrayInputStream(text.getBytes());
-        buffer = new BufferedLineReaderInputStream(bis, 4096);
-        stream =
-                new MimeBoundaryInputStream(buffer, "boundary");
-        Assert.assertEquals(-1, stream.read());
+        BufferedLineReaderInputStream buffer2 = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(text2.getBytes()), 4096);
+        MimeBoundaryInputStream stream2 = new MimeBoundaryInputStream(buffer2, "boundary");
+        Assert.assertEquals(-1, stream2.read());
+
+        stream2.close();
     }
 
     /**
@@ -216,6 +217,8 @@ public class MimeBoundaryInputStreamTest
                 new MimeBoundaryInputStream(buffer, "boundary");
         Assert.assertEquals(-1, stream.read());
         Assert.assertTrue(stream.isLastPart());
+
+        stream.close();
     }
 
     /**
@@ -227,8 +230,7 @@ public class MimeBoundaryInputStreamTest
 
         ByteArrayInputStream bis = new ByteArrayInputStream(text.getBytes());
         BufferedLineReaderInputStream buffer = new BufferedLineReaderInputStream(bis, 4096);
-        MimeBoundaryInputStream stream =
-                new MimeBoundaryInputStream(buffer, "boundary");
+        MimeBoundaryInputStream stream = new MimeBoundaryInputStream(buffer, "boundary");
         Assert.assertEquals("Line 1\r\n", read(stream, 100));
 
         text = "--boundary\r\n";
@@ -237,6 +239,8 @@ public class MimeBoundaryInputStreamTest
         buffer = new BufferedLineReaderInputStream(bis, 4096);
         stream = new MimeBoundaryInputStream(buffer, "boundary");
         Assert.assertEquals(-1, stream.read());
+
+        stream.close();
     }
 
 
@@ -266,7 +270,8 @@ public class MimeBoundaryInputStreamTest
         outstream.write(term.getBytes("US-ASCII"));
         byte[] raw = outstream.toByteArray();
 
-        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(raw),
20);
+        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(raw), 20);
         LineReaderInputStream instream = new MimeBoundaryInputStream(inbuffer, "1234");
 
         ByteArrayBuffer linebuf = new ByteArrayBuffer(8);
@@ -278,6 +283,8 @@ public class MimeBoundaryInputStreamTest
         }
         Assert.assertEquals(-1, instream.readLine(linebuf));
         Assert.assertEquals(-1, instream.readLine(linebuf));
+
+        instream.close();
     }
 
     @Test
@@ -286,7 +293,8 @@ public class MimeBoundaryInputStreamTest
         String teststr = "01234567890123456789\n\n\r\n\r\r\n\n\n\n\n\n--1234\r\n";
         byte[] raw = teststr.getBytes("US-ASCII");
 
-        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(raw),
20);
+        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(
+                new ByteArrayInputStream(raw), 20);
         LineReaderInputStream instream = new MimeBoundaryInputStream(inbuffer, "1234");
 
         ByteArrayBuffer linebuf = new ByteArrayBuffer(8);
@@ -332,6 +340,8 @@ public class MimeBoundaryInputStreamTest
 
         Assert.assertEquals(-1, instream.readLine(linebuf));
         Assert.assertEquals(-1, instream.readLine(linebuf));
+
+        instream.close();
     }
 
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/PositionInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/PositionInputStreamTest.java?rev=1481112&r1=1481111&r2=1481112&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/PositionInputStreamTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/PositionInputStreamTest.java
Fri May 10 17:22:34 2013
@@ -50,6 +50,7 @@ public class PositionInputStreamTest {
         Assert.assertEquals(7, countingStream.getPosition());
         Assert.assertTrue(countingStream.read(tmp) == -1);
         Assert.assertEquals(7, countingStream.getPosition());
+        countingStream.close();
     }
 
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java?rev=1481112&r1=1481111&r2=1481112&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java
Fri May 10 17:22:34 2013
@@ -20,7 +20,6 @@
 package org.apache.james.mime4j.stream;
 
 import org.apache.james.mime4j.ExampleMail;
-import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java?rev=1481112&r1=1481111&r2=1481112&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java
Fri May 10 17:22:34 2013
@@ -20,7 +20,6 @@
 package org.apache.james.mime4j.stream;
 
 import org.apache.james.mime4j.MimeIOException;
-import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;



Mime
View raw message