tika-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1222886 - in /tika/trunk/tika-core/src/main/java/org/apache/tika/fork: ForkClient.java MemoryURLStreamHandler.java MemoryURLStreamRecord.java
Date Fri, 23 Dec 2011 23:30:07 GMT
Author: jukka
Date: Fri Dec 23 23:30:07 2011
New Revision: 1222886

URL: http://svn.apache.org/viewvc?rev=1222886&view=rev
Log:
TIKA-808: Fork Parser doesn't work for PDF files

Turn MemoryURLStreamHandler.Record into a standalone class to avoid classloading trouble.
This fixes the reported problem.

Added:
    tika/trunk/tika-core/src/main/java/org/apache/tika/fork/MemoryURLStreamRecord.java   (with
props)
Modified:
    tika/trunk/tika-core/src/main/java/org/apache/tika/fork/ForkClient.java
    tika/trunk/tika-core/src/main/java/org/apache/tika/fork/MemoryURLStreamHandler.java

Modified: tika/trunk/tika-core/src/main/java/org/apache/tika/fork/ForkClient.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/main/java/org/apache/tika/fork/ForkClient.java?rev=1222886&r1=1222885&r2=1222886&view=diff
==============================================================================
--- tika/trunk/tika-core/src/main/java/org/apache/tika/fork/ForkClient.java (original)
+++ tika/trunk/tika-core/src/main/java/org/apache/tika/fork/ForkClient.java Fri Dec 23 23:30:07
2011
@@ -246,8 +246,10 @@ class ForkClient {
             Class<?>[] bootstrap = {
                     ForkServer.class, ForkObjectInputStream.class,
                     ForkProxy.class, ClassLoaderProxy.class,
-                    MemoryURLConnection.class, MemoryURLStreamHandler.class,
-                    MemoryURLStreamHandlerFactory.class
+                    MemoryURLConnection.class,
+                    MemoryURLStreamHandler.class,
+                    MemoryURLStreamHandlerFactory.class,
+                    MemoryURLStreamRecord.class
             };
             ClassLoader loader = ForkServer.class.getClassLoader();
             for (Class<?> klass : bootstrap) {

Modified: tika/trunk/tika-core/src/main/java/org/apache/tika/fork/MemoryURLStreamHandler.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/main/java/org/apache/tika/fork/MemoryURLStreamHandler.java?rev=1222886&r1=1222885&r2=1222886&view=diff
==============================================================================
--- tika/trunk/tika-core/src/main/java/org/apache/tika/fork/MemoryURLStreamHandler.java (original)
+++ tika/trunk/tika-core/src/main/java/org/apache/tika/fork/MemoryURLStreamHandler.java Fri
Dec 23 23:30:07 2011
@@ -31,19 +31,15 @@ class MemoryURLStreamHandler extends URL
 
     private static final AtomicInteger counter = new AtomicInteger();
 
-    private static class Record {
-        public WeakReference<URL> url;
-        public byte[] data;
-    }
-
-    private static final List<Record> records = new LinkedList<Record>();
+    private static final List<MemoryURLStreamRecord> records =
+        new LinkedList<MemoryURLStreamRecord>();
 
     public static URL createURL(byte[] data) {
         try {
             int i = counter.incrementAndGet();
             URL url =  new URL("tika-in-memory", "localhost", "/" + i);
 
-            Record record = new Record();
+            MemoryURLStreamRecord record = new MemoryURLStreamRecord();
             record.url = new WeakReference<URL>(url);
             record.data = data;
             records.add(record);
@@ -56,9 +52,9 @@ class MemoryURLStreamHandler extends URL
 
     @Override
     protected URLConnection openConnection(URL u) throws IOException {
-        Iterator<Record> iterator = records.iterator();
+        Iterator<MemoryURLStreamRecord> iterator = records.iterator();
         while (iterator.hasNext()) {
-            Record record = iterator.next();
+            MemoryURLStreamRecord record = iterator.next();
             URL url = record.url.get();
             if (url == null) {
                 iterator.remove();

Added: tika/trunk/tika-core/src/main/java/org/apache/tika/fork/MemoryURLStreamRecord.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-core/src/main/java/org/apache/tika/fork/MemoryURLStreamRecord.java?rev=1222886&view=auto
==============================================================================
--- tika/trunk/tika-core/src/main/java/org/apache/tika/fork/MemoryURLStreamRecord.java (added)
+++ tika/trunk/tika-core/src/main/java/org/apache/tika/fork/MemoryURLStreamRecord.java Fri
Dec 23 23:30:07 2011
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.fork;
+
+import java.lang.ref.WeakReference;
+import java.net.URL;
+
+class MemoryURLStreamRecord {
+
+    public WeakReference<URL> url;
+    public byte[] data;
+
+}
\ No newline at end of file

Propchange: tika/trunk/tika-core/src/main/java/org/apache/tika/fork/MemoryURLStreamRecord.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message