jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1340056 - in /jackrabbit/trunk: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jackrabbit-spi-commons/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/
Date Fri, 18 May 2012 09:57:55 GMT
Author: jukka
Date: Fri May 18 09:57:54 2012
New Revision: 1340056

URL: http://svn.apache.org/viewvc?rev=1340056&view=rev
Log:
JCR-3314: Drop commons-io dependency from spi-commons

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/pom.xml
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?rev=1340056&r1=1340055&r2=1340056&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
Fri May 18 09:57:54 2012
@@ -51,7 +51,6 @@ import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
 import org.apache.commons.collections.map.ReferenceMap;
-import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.commons.AbstractSession;
 import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
 import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
@@ -410,8 +409,7 @@ public class SessionImpl extends Abstrac
         } catch (ParserConfigurationException e) {
             throw new RepositoryException("SAX parser configuration error", e);
         } finally {
-            // JCR-2903
-            IOUtils.closeQuietly(in);
+            in.close(); // JCR-2903
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java?rev=1340056&r1=1340055&r2=1340056&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
Fri May 18 09:57:54 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
 import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager;
@@ -344,8 +343,7 @@ public class WorkspaceImpl implements Wo
             // run the import
             wspManager.execute(WorkspaceImport.create(parentState, in, uuidBehavior));
         } finally {
-            // JCR-2903
-            IOUtils.closeQuietly(in);
+            in. close(); // JCR-2903
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-spi-commons/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/pom.xml?rev=1340056&r1=1340055&r2=1340056&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/pom.xml Fri May 18 09:57:54 2012
@@ -92,10 +92,6 @@
       <artifactId>commons-collections</artifactId>
     </dependency>
     <dependency>
-      <groupId>commons-io</groupId>
-      <artifactId>commons-io</artifactId>
-    </dependency>
-    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java?rev=1340056&r1=1340055&r2=1340056&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
Fri May 18 09:57:54 2012
@@ -20,7 +20,6 @@ import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.util.ISO8601;
-import org.apache.commons.io.IOUtils;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -33,7 +32,11 @@ import java.math.BigDecimal;
 import java.net.URI;
 import java.io.InputStream;
 import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
 import java.io.Serializable;
+import java.io.StringWriter;
+import java.io.Writer;
 
 /**
  * <code>AbstractQValue</code>...
@@ -336,13 +339,23 @@ public abstract class AbstractQValue imp
      */
     public String getString() throws RepositoryException {
         if (type == PropertyType.BINARY) {
-            InputStream stream = getStream();
             try {
-                return IOUtils.toString(stream, "UTF-8");
+                InputStream stream = getStream();
+                try {
+                    Reader reader = new InputStreamReader(stream, "UTF-8");
+                    Writer writer = new StringWriter();
+                    char[] buffer = new char[1024];
+                    int n = reader.read(buffer);
+                    while (n != -1) {
+                        writer.write(buffer, 0, n);
+                        n = reader.read(buffer);
+                    }
+                    return writer.toString();
+                } finally {
+                    stream.close();
+                }
             } catch (IOException e) {
                 throw new RepositoryException("conversion from stream to string failed",
e);
-            } finally {
-                IOUtils.closeQuietly(stream);
             }
         } else if (type == PropertyType.DATE) {
             return (String) val;

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java?rev=1340056&r1=1340055&r2=1340056&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ValueFactoryQImpl.java
Fri May 18 09:57:54 2012
@@ -30,7 +30,6 @@ import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.ValueFormatException;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
@@ -153,15 +152,16 @@ public class ValueFactoryQImpl implement
      */
     public Value createValue(InputStream value) {
         try {
-            QValue qvalue = qfactory.create(value);
-            return new QValueValue(qvalue, resolver);
+            try {
+                QValue qvalue = qfactory.create(value);
+                return new QValueValue(qvalue, resolver);
+            } finally {
+                value.close(); // JCR-2903
+            }
         } catch (IOException ex) {
             throw new RuntimeException(ex);
         } catch (RepositoryException ex) {
             throw new RuntimeException(ex);
-        } finally {
-            // JCR-2903
-            IOUtils.closeQuietly(value);
         }
     }
 
@@ -206,15 +206,16 @@ public class ValueFactoryQImpl implement
     public Binary createBinary(InputStream stream) throws RepositoryException {
         // TODO review/optimize/refactor
         try {
-            QValue qvalue = qfactory.create(stream);
-            return qvalue.getBinary();
+            try {
+                QValue qvalue = qfactory.create(stream);
+                return qvalue.getBinary();
+            } finally {
+                stream.close(); // JCR-2903
+            }
         } catch (IOException ex) {
             throw new RuntimeException(ex);
         } catch (RepositoryException ex) {
             throw new RuntimeException(ex);
-        } finally {
-            // JCR-2903
-            IOUtils.closeQuietly(stream);
         }
     }
 
@@ -240,4 +241,5 @@ public class ValueFactoryQImpl implement
         QValue qvalue = qfactory.create(value.getUUID(), weak ? PropertyType.WEAKREFERENCE
: PropertyType.REFERENCE);
         return new QValueValue(qvalue, resolver);
     }
+
 }



Mime
View raw message