hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1447366 - /httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/NRandomDataHandler.java
Date Mon, 18 Feb 2013 16:06:32 GMT
Author: olegk
Date: Mon Feb 18 16:06:31 2013
New Revision: 1447366

URL: http://svn.apache.org/r1447366
Log:
Made content generation code more consistent with other implementations

Modified:
    httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/NRandomDataHandler.java

Modified: httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/NRandomDataHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/NRandomDataHandler.java?rev=1447366&r1=1447365&r2=1447366&view=diff
==============================================================================
--- httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/NRandomDataHandler.java
(original)
+++ httpcomponents/benchmark/httpcore/trunk/src/main/java/org/apache/http/benchmark/httpcore/NRandomDataHandler.java
Mon Feb 18 16:06:31 2013
@@ -55,12 +55,14 @@ class NRandomDataHandler implements Http
         super();
     }
 
+    @Override
     public HttpAsyncRequestConsumer<HttpRequest> processRequest(
             final HttpRequest request,
             final HttpContext context) throws HttpException, IOException {
         return new BasicAsyncRequestConsumer();
     }
 
+    @Override
     public void handle(
             final HttpRequest request,
             final HttpAsyncExchange httpexchange,
@@ -100,21 +102,24 @@ class NRandomDataHandler implements Http
         public RandomAsyncResponseProducer(final int count) {
             super();
             this.count = count;
-            this.buf = ByteBuffer.allocate(count);
-            final int r = Math.abs(this.buf.hashCode());
+
+            final byte[] b = new byte[count];
+            final int r = Math.abs(b.hashCode());
             for (int i = 0; i < count; i++) {
-                final byte b = (byte) ((r + i) % 96 + 32);
-                this.buf.put(b);
+                b[i] = (byte) ((r + i) % 96 + 32);
             }
-            this.buf.flip();
+            this.buf = ByteBuffer.wrap(b);
         }
 
+        @Override
         public void close() throws IOException {
         }
 
+        @Override
         public void failed(final Exception ex) {
         }
 
+        @Override
         public HttpResponse generateResponse() {
             final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
             final BasicHttpEntity entity  = new BasicHttpEntity();
@@ -124,9 +129,11 @@ class NRandomDataHandler implements Http
             return response;
         }
 
+        @Override
         public void responseCompleted(final HttpContext context) {
         }
 
+        @Override
         public void produceContent(
                 final ContentEncoder encoder, final IOControl ioctrl) throws IOException
{
             while (this.buf.hasRemaining()) {



Mime
View raw message