You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2015/02/05 19:33:52 UTC

tomee git commit: under windows socket stream are a bit broken compared to linux and we need to override write(byte[]). Thanks to Yann Blazart to have reported it

Repository: tomee
Updated Branches:
  refs/heads/develop bc5f6957c -> 74640eb0b


under windows socket stream are a bit broken compared to linux and we need to override write(byte[]). Thanks to Yann Blazart to have reported it


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/74640eb0
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/74640eb0
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/74640eb0

Branch: refs/heads/develop
Commit: 74640eb0bbc633bc973c454e14a67dec5ba9c43c
Parents: bc5f695
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Thu Feb 5 19:33:35 2015 +0100
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Thu Feb 5 19:33:35 2015 +0100

----------------------------------------------------------------------
 .../server/httpd/HttpListenerRegistry.java       |  4 +++-
 .../server/stream/CountingOutputStream.java      | 19 +++++++++++--------
 2 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/74640eb0/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java
index 15012b1..6d9786e 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpListenerRegistry.java
@@ -57,6 +57,7 @@ public class HttpListenerRegistry implements HttpListener {
     private final ClassLoader defaultClassLoader;
     private final File[] resourceBases;
     private final Map<String, String> defaultContextTypes = new HashMap<>();
+    private final String welcomeFile = SystemInstance.get().getProperty("openejb.http.welcome", "index.html");
 
     public HttpListenerRegistry() {
         HttpServletRequest mock = null;
@@ -200,7 +201,8 @@ public class HttpListenerRegistry implements HttpListener {
                     if (url != null) {
                         serveResource(response, url);
                     } else {
-                        final String pathWithoutSlash = servletPath.startsWith("/") ? servletPath.substring(1) : servletPath;
+                        final String pathWithoutSlash = "/".equals(path) ? welcomeFile :
+                                (servletPath.startsWith("/") ? servletPath.substring(1) : servletPath);
                         url = defaultClassLoader.getResource("META-INF/resources/" + pathWithoutSlash);
                         if (url != null) {
                             serveResource(response, url);

http://git-wip-us.apache.org/repos/asf/tomee/blob/74640eb0/server/openejb-server/src/main/java/org/apache/openejb/server/stream/CountingOutputStream.java
----------------------------------------------------------------------
diff --git a/server/openejb-server/src/main/java/org/apache/openejb/server/stream/CountingOutputStream.java b/server/openejb-server/src/main/java/org/apache/openejb/server/stream/CountingOutputStream.java
index 3924081..e847d40 100644
--- a/server/openejb-server/src/main/java/org/apache/openejb/server/stream/CountingOutputStream.java
+++ b/server/openejb-server/src/main/java/org/apache/openejb/server/stream/CountingOutputStream.java
@@ -16,31 +16,34 @@
  */
 package org.apache.openejb.server.stream;
 
+import java.io.FilterOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 
-public class CountingOutputStream extends OutputStream {
-    private final OutputStream delegate;
+// IMPORTANT: write(byte[]) methods are theorically useless but 1) good for perf, 2) avoid to break on windows (socket impl)
+public class CountingOutputStream extends FilterOutputStream {
     private int count = 0;
 
     public CountingOutputStream(final OutputStream rawIn) {
-        delegate = rawIn;
+        super(rawIn);
     }
 
     @Override
     public void write(final int b) throws IOException {
         count++;
-        delegate.write(b);
+        super.write(b);
     }
 
     @Override
-    public void flush() throws IOException {
-        delegate.flush();
+    public void write(final byte[] b) throws IOException {
+        count += b.length;
+        super.write(b);
     }
 
     @Override
-    public void close() throws IOException {
-        delegate.close();
+    public void write(final byte[] b, final int off, final int len) throws IOException {
+        count += len;
+        super.write(b, off, len);
     }
 
     public int getCount() {