Author: jdonnerstag
Date: Sun Jan 23 17:31:17 2011
New Revision: 1062474

URL: http://svn.apache.org/viewvc?rev=1062474&view=rev
Log:
WICKET-3372 fixed: XmlReaderTest fail because getClass.getResourceAsStream is 
not markSupported

Modified:
    
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/XmlReader.java

Modified: 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/XmlReader.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/XmlReader.java?rev=1062474&r1=1062473&r2=1062474&view=diff
==============================================================================
--- 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/XmlReader.java 
(original)
+++ 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/XmlReader.java 
Sun Jan 23 17:31:17 2011
@@ -16,7 +16,7 @@
  */
 package org.apache.wicket.util.io;
 
-import java.io.BufferedReader;
+import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -24,6 +24,8 @@ import java.io.Reader;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.wicket.util.lang.Args;
+
 
 /**
  * This is a simple XmlReader. Its only purpose is to read the xml decl string 
from the input and
@@ -69,13 +71,17 @@ public final class XmlReader extends Rea
                // The xml parser does not have a parent filter
                super();
 
-               this.inputStream = inputStream;
-               encoding = defaultEncoding;
+               Args.notNull(inputStream, "inputStream");
 
-               if (inputStream == null)
+               if (!inputStream.markSupported())
+               {
+                       this.inputStream = new BufferedInputStream(inputStream);
+               }
+               else
                {
-                       throw new IllegalArgumentException("Parameter 
'inputStream' must not be null");
+                       this.inputStream = inputStream;
                }
+               encoding = defaultEncoding;
 
                init();
        }
@@ -107,13 +113,7 @@ public final class XmlReader extends Rea
         */
        public void init() throws IOException
        {
-               if (!inputStream.markSupported())
-               {
-                       throw new IOException("The InputStream must support 
mark/reset");
-               }
-
-               // read ahead buffer required for the first line of the markup
-               // (encoding)
+               // read ahead buffer required for the first line of the markup 
(encoding)
                final int readAheadSize = 80;
                inputStream.mark(readAheadSize);
 
@@ -132,12 +132,12 @@ public final class XmlReader extends Rea
                if (encoding == null)
                {
                        // Use JVM default
-                       reader = new BufferedReader(new 
InputStreamReader(inputStream));
+                       reader = new InputStreamReader(inputStream);
                }
                else
                {
                        // Use the encoding provided
-                       reader = new BufferedReader(new 
InputStreamReader(inputStream, encoding));
+                       reader = new InputStreamReader(inputStream, encoding);
                }
        }
 


Reply via email to