chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r957163 - in /incubator/chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/ chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/...
Date Wed, 23 Jun 2010 11:28:54 GMT
Author: fmui
Date: Wed Jun 23 11:28:53 2010
New Revision: 957163

URL: http://svn.apache.org/viewvc?rev=957163&view=rev
Log:
- removed an unnecessary dependency on Sun classes
- made sure that content streams are getting closed so that network resources can be released

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/ContentStreamImpl.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java?rev=957163&r1=957162&r2=957163&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java
Wed Jun 23 11:28:53 2010
@@ -18,7 +18,8 @@
  */
 package org.apache.chemistry.opencmis.client.runtime;
 
-
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
@@ -31,8 +32,6 @@ import org.apache.chemistry.opencmis.cli
 import org.junit.Before;
 import org.junit.Test;
 
-import com.sun.xml.ws.util.ByteArrayBuffer;
-
 public class CacheTest {
 
     @Before
@@ -106,12 +105,12 @@ public class CacheTest {
             cache.put(obj, cacheKey);
         }
 
-        ByteArrayBuffer buffer = new ByteArrayBuffer();
+        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream(buffer);
         out.writeObject(cache);
         out.close();
 
-        ObjectInputStream in = new ObjectInputStream(buffer.newInputStream());
+        ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
         Cache cache2 = (Cache) in.readObject();
         in.close();
 

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/ContentStreamImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/ContentStreamImpl.java?rev=957163&r1=957162&r2=957163&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/ContentStreamImpl.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/ContentStreamImpl.java
Wed Jun 23 11:28:53 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.chemistry.opencmis.commons.impl.dataobjects;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.math.BigInteger;
 
@@ -25,16 +26,13 @@ import org.apache.chemistry.opencmis.com
 
 /**
  * Content stream data implementation.
- * 
- * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
- * 
  */
 public class ContentStreamImpl extends AbstractExtensionData implements ContentStream {
 
-    private String fFilename;
-    private BigInteger fLength;
-    private String fMimeType;
-    private InputStream fStream;
+    private String filename;
+    private BigInteger length;
+    private String mimeType;
+    private InputStream stream;
 
     /**
      * Constructor.
@@ -52,60 +50,58 @@ public class ContentStreamImpl extends A
         setStream(stream);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.opencmis.client.provider.ContentStreamData#getFilename()
-     */
     public String getFileName() {
-        return fFilename;
+        return filename;
     }
 
     public void setFileName(String filename) {
-        fFilename = filename;
+        this.filename = filename;
     }
 
     public long getLength() {
-        return fLength == null ? -1 : fLength.longValue();
+        return length == null ? -1 : length.longValue();
     }
 
     public BigInteger getBigLength() {
-        return fLength;
+        return length;
     }
 
     public void setLength(BigInteger length) {
-        fLength = length;
+        this.length = length;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.opencmis.client.provider.ContentStreamData#getMimeType()
-     */
     public String getMimeType() {
-        return fMimeType;
+        return mimeType;
     }
 
-    public void setMimeType(String mimetype) {
-        fMimeType = mimetype;
+    public void setMimeType(String mimeType) {
+        this.mimeType = mimeType;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.opencmis.client.provider.ContentStreamData#getStream()
-     */
     public InputStream getStream() {
-        return fStream;
+        return stream;
     }
 
     public void setStream(InputStream stream) {
-        fStream = stream;
+        this.stream = stream;
     }
 
     @Override
     public String toString() {
-        return "ContentStream [filename=" + fFilename + ", length=" + fLength + ", MIME type="
+ fMimeType
-                + ", has stream=" + (fStream != null) + "]" + super.toString();
+        return "ContentStream [filename=" + filename + ", length=" + length + ", MIME type="
+ mimeType
+                + ", has stream=" + (stream != null) + "]" + super.toString();
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        try {
+            if (stream != null) {
+                // this stream must be closed to release the underlying network resources
+                stream.close();
+            }
+        } catch (IOException e) {
+        } finally {
+            super.finalize();
+        }
     }
 }



Mime
View raw message