jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r707304 - in /jackrabbit/trunk/jackrabbit-text-extractors/src: main/java/org/apache/jackrabbit/extractor/PlainTextExtractor.java test/java/org/apache/jackrabbit/extractor/PlainTextExtractorTest.java
Date Thu, 23 Oct 2008 08:05:51 GMT
Author: mreutegg
Date: Thu Oct 23 01:05:51 2008
New Revision: 707304

URL: http://svn.apache.org/viewvc?rev=707304&view=rev
Log:
JCR-1829: PlainTextExtractor returns an empty reader when encoding is unsupported

Modified:
    jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/PlainTextExtractor.java
    jackrabbit/trunk/jackrabbit-text-extractors/src/test/java/org/apache/jackrabbit/extractor/PlainTextExtractorTest.java

Modified: jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/PlainTextExtractor.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/PlainTextExtractor.java?rev=707304&r1=707303&r2=707304&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/PlainTextExtractor.java
(original)
+++ jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/PlainTextExtractor.java
Thu Oct 23 01:05:51 2008
@@ -49,8 +49,8 @@
     /**
      * Wraps the given input stream to an {@link InputStreamReader} using
      * the given encoding, or the platform default encoding if the encoding
-     * is not given. Closes the stream and returns an empty reader if the
-     * given encoding is not supported.
+     * is not given or is unsupported. Closes the stream and returns an empty
+     * reader if the given encoding is not supported.
      *
      * @param stream binary stream
      * @param type ignored
@@ -64,14 +64,12 @@
         try {
             if (encoding != null) {
                 return new InputStreamReader(stream, encoding);
-            } else {
-                return new InputStreamReader(stream);
             }
         } catch (UnsupportedEncodingException e) {
-            logger.warn("Failed to extract plain text content", e);
-            stream.close();
-            return new StringReader("");
+            logger.warn("Unsupported encoding '{}', using default ({}) instead.",
+                    new Object[]{encoding, System.getProperty("file.encoding")});
         }
+        return new InputStreamReader(stream);
     }
 
 }

Modified: jackrabbit/trunk/jackrabbit-text-extractors/src/test/java/org/apache/jackrabbit/extractor/PlainTextExtractorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-text-extractors/src/test/java/org/apache/jackrabbit/extractor/PlainTextExtractorTest.java?rev=707304&r1=707303&r2=707304&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-text-extractors/src/test/java/org/apache/jackrabbit/extractor/PlainTextExtractorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-text-extractors/src/test/java/org/apache/jackrabbit/extractor/PlainTextExtractorTest.java
Thu Oct 23 01:05:51 2008
@@ -92,7 +92,7 @@
             Reader reader = extractor.extractText(
                     new ByteArrayInputStream(text.getBytes()),
                     "text/plain", "unsupported");
-            assertEquals("", ExtractorHelper.read(reader));
+            assertEquals(text, ExtractorHelper.read(reader));
         } catch (UnsupportedEncodingException e) {
             fail("PlainTextExtractor does not handle unsupported encodings");
         }



Mime
View raw message