db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpendle...@apache.org
Subject svn commit: r1346234 - in /db/derby/code/trunk/java/client/org/apache/derby/client/net: DynamicByteArrayOutputStream.java EncodedInputStream.java InputStreamUtil.java PublicBufferOutputStream.java Request.java
Date Tue, 05 Jun 2012 04:17:37 GMT
Author: bpendleton
Date: Tue Jun  5 04:17:36 2012
New Revision: 1346234

URL: http://svn.apache.org/viewvc?rev=1346234&view=rev
Log:
DERBY-5786: Duplicate copies of InputStreamUtil and DynamicByteArrayOutputStream

This patch was contributed by Mohamed Nufail (nufail56 at gmail dot com)

In solving DERBY-4491, the InputStreamUtil and DynamicByteArrayOutputStream
classes were copied from org.apache.derby.iapi.services.io to create duplicate
copies of those classes in the org.apache.derby.client.net package.

Since the client uses only a small part of the functionality those classes
provide, this change modifies the client to use the PublicBufferOutputStream
which was present as a nested class within the EncodedInputStream class,
promoting the class into a top-level class to enable this use.

Added:
    db/derby/code/trunk/java/client/org/apache/derby/client/net/PublicBufferOutputStream.java
Removed:
    db/derby/code/trunk/java/client/org/apache/derby/client/net/DynamicByteArrayOutputStream.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/InputStreamUtil.java
Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/net/EncodedInputStream.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/EncodedInputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/EncodedInputStream.java?rev=1346234&r1=1346233&r2=1346234&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/EncodedInputStream.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/EncodedInputStream.java Tue
Jun  5 04:17:36 2012
@@ -23,7 +23,6 @@ package org.apache.derby.client.net;
 import java.io.InputStream;
 import java.io.Reader;
 import java.io.OutputStreamWriter;
-import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayInputStream;
 
 import java.io.IOException;
@@ -210,17 +209,5 @@ public final class EncodedInputStream ex
 		}
 	
     }
-    
-    
-    static class PublicBufferOutputStream extends ByteArrayOutputStream{
-	
-		PublicBufferOutputStream(int size){
-			super(size);
-		}
 
-		public byte[] getBuffer(){
-			return buf;
-		}
-	
-    }
 }

Added: db/derby/code/trunk/java/client/org/apache/derby/client/net/PublicBufferOutputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/PublicBufferOutputStream.java?rev=1346234&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/PublicBufferOutputStream.java
(added)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/PublicBufferOutputStream.java
Tue Jun  5 04:17:36 2012
@@ -0,0 +1,46 @@
+/*
+    Derby - Class org.apache.derby.client.net.PublicBufferOutputStream
+
+    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.derby.client.net;
+
+import java.io.ByteArrayOutputStream;
+
+/**
+ * A ByteArrayOutputStream which gives a direct reference of the buffer array
+ */
+public class PublicBufferOutputStream extends ByteArrayOutputStream {
+
+    public PublicBufferOutputStream() {
+        super();
+    }
+
+    public PublicBufferOutputStream(int size) {
+        super(size);
+    }
+
+    /**
+     * Get a reference to the buffer array stored in the byte array
+     * output stream
+     */
+    public byte[] getBuffer() {
+        return buf;
+    }
+
+}

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java?rev=1346234&r1=1346233&r2=1346234&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java Tue Jun  5 04:17:36
2012
@@ -1427,13 +1427,13 @@ public class Request {
         
         try
         {
-            DynamicByteArrayOutputStream dbaos = new DynamicByteArrayOutputStream();
-            ObjectOutputStream oos = new ObjectOutputStream( dbaos );
+            PublicBufferOutputStream pbos = new PublicBufferOutputStream();
+            ObjectOutputStream oos = new ObjectOutputStream( pbos );
 
             oos.writeObject( val );
 
-            buffer = dbaos.getByteArray();
-            length = dbaos.getUsed();
+            buffer = pbos.getBuffer();
+            length = pbos.size();
         }
         catch (Exception e)
         {



Mime
View raw message