jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r707310 - in /jackrabbit/trunk/jackrabbit-text-extractors/src: main/java/org/apache/jackrabbit/extractor/XMLTextExtractor.java test/java/org/apache/jackrabbit/extractor/XMLTextExtractorTest.java
Date Thu, 23 Oct 2008 08:31:10 GMT
Author: mreutegg
Date: Thu Oct 23 01:31:10 2008
New Revision: 707310

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

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

Modified: jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/XMLTextExtractor.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/XMLTextExtractor.java?rev=707310&r1=707309&r2=707310&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/XMLTextExtractor.java
(original)
+++ jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/XMLTextExtractor.java
Thu Oct 23 01:31:10 2008
@@ -23,6 +23,7 @@
 import java.io.InputStream;
 import java.io.Reader;
 import java.io.StringReader;
+import java.nio.charset.Charset;
 
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
@@ -95,7 +96,13 @@
                 }
             });
             if (encoding != null) {
-                source.setEncoding(encoding);
+                try {
+                    Charset.forName(encoding);
+                    source.setEncoding(encoding);
+                } catch (Exception e) {
+                    logger.warn("Unsupported encoding '{}', using default ({}) instead.",
+                            new Object[]{encoding, System.getProperty("file.encoding")});
+                }
             }
             reader.parse(source);
 

Modified: jackrabbit/trunk/jackrabbit-text-extractors/src/test/java/org/apache/jackrabbit/extractor/XMLTextExtractorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-text-extractors/src/test/java/org/apache/jackrabbit/extractor/XMLTextExtractorTest.java?rev=707310&r1=707309&r2=707310&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-text-extractors/src/test/java/org/apache/jackrabbit/extractor/XMLTextExtractorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-text-extractors/src/test/java/org/apache/jackrabbit/extractor/XMLTextExtractorTest.java
Thu Oct 23 01:31:10 2008
@@ -110,7 +110,7 @@
             Reader reader = extractor.extractText(
                     new ByteArrayInputStream(xml.getBytes()),
                     "text/xml", "unsupported");
-            assertEquals("", ExtractorHelper.read(reader));
+            assertEquals("attribute value text content", ExtractorHelper.read(reader));
         } catch (UnsupportedEncodingException e) {
             fail("XMLTextExtractor does not handle unsupported encodings");
         } catch (IOException e) {



Mime
View raw message