You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2007/11/12 10:52:00 UTC

svn commit: r594069 - in /jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs: IdentityDecoder.java IdentityEncoder.java LengthDelimitedDecoder.java LengthDelimitedEncoder.java

Author: olegk
Date: Mon Nov 12 01:51:57 2007
New Revision: 594069

URL: http://svn.apache.org/viewvc?rev=594069&view=rev
Log:
Minor code cleanups

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java?rev=594069&r1=594068&r2=594069&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java Mon Nov 12 01:51:57 2007
@@ -84,10 +84,11 @@
     }
     
     public long transfer(
-            final FileChannel fileChannel, 
+            final FileChannel dst, 
             long position, 
             long count) throws IOException {
-        if (fileChannel == null) {
+        
+        if (dst == null) {
             return 0;
         }
         if (this.completed) {
@@ -99,9 +100,9 @@
             ByteBuffer tmpDst = ByteBuffer.allocate((int)count);
             this.buffer.read(tmpDst);
             tmpDst.flip();
-            bytesRead = fileChannel.write(tmpDst);
+            bytesRead = dst.write(tmpDst);
         } else {
-            bytesRead = fileChannel.transferFrom(this.channel, position, count);
+            bytesRead = dst.transferFrom(this.channel, position, count);
             if (bytesRead > 0) {
                 this.metrics.incrementBytesTransferred(bytesRead);
             }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java?rev=594069&r1=594068&r2=594069&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java Mon Nov 12 01:51:57 2007
@@ -73,14 +73,15 @@
     }
  
     public long transfer(
-            final FileChannel filechannel, 
+            final FileChannel src, 
             long position, 
             long count) throws IOException {
-        if (filechannel == null) {
+        
+        if (src == null) {
             return 0;
         }
         assertNotCompleted();
-        long bytesWritten = filechannel.transferTo(position, count, this.channel);
+        long bytesWritten = src.transferTo(position, count, this.channel);
         if (bytesWritten > 0) {
             this.metrics.incrementBytesTransferred(bytesWritten);
         }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java?rev=594069&r1=594068&r2=594069&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java Mon Nov 12 01:51:57 2007
@@ -107,8 +107,12 @@
         return bytesRead;
     }
     
-    public long transfer(final FileChannel fileChannel, long position, long count) throws IOException {
-        if (fileChannel == null) {
+    public long transfer(
+            final FileChannel dst, 
+            long position, 
+            long count) throws IOException {
+        
+        if (dst == null) {
             return 0;
         }
         if (this.completed) {
@@ -122,13 +126,12 @@
             int maxLen = Math.min(lenRemaining, this.buffer.length());
             ByteBuffer tmpDst = ByteBuffer.allocate(maxLen);
             this.buffer.read(tmpDst, maxLen);
-            bytesRead = fileChannel.write(tmpDst);
+            bytesRead = dst.write(tmpDst);
         } else {
             if (count > lenRemaining) {
-                bytesRead = fileChannel.transferFrom(this.channel, position, lenRemaining);
-            } else {
-                bytesRead = fileChannel.transferFrom(this.channel, position, count);
+                count = lenRemaining;
             }
+            bytesRead = dst.transferFrom(this.channel, position, count);
             if (bytesRead > 0) {
                 this.metrics.incrementBytesTransferred(bytesRead);
             }

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java?rev=594069&r1=594068&r2=594069&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java Mon Nov 12 01:51:57 2007
@@ -97,8 +97,12 @@
         return bytesWritten;
     }
 
-    public long transfer(final FileChannel fileChannel, long position, long count) throws IOException {
-        if (fileChannel == null) {
+    public long transfer(
+            final FileChannel src, 
+            long position, 
+            long count) throws IOException {
+        
+        if (src == null) {
             return 0;
         }
         assertNotCompleted();
@@ -106,10 +110,9 @@
         
         long bytesWritten;
         if (count > lenRemaining) {
-            bytesWritten = fileChannel.transferTo(position, lenRemaining, this.channel);
-        } else {
-            bytesWritten = fileChannel.transferTo(position, count, this.channel);
+            count = lenRemaining;
         }
+        bytesWritten = src.transferTo(position, count, this.channel);
         if (bytesWritten > 0) {
             this.metrics.incrementBytesTransferred(bytesWritten);
         }