You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2019/08/22 03:46:54 UTC

[camel] branch camel-2.x updated: Revert "CAMEL-13886: camel-servlet + camel-http4 with null body causes "Stream closed" IOException"

This is an automated email from the ASF dual-hosted git repository.

tsato pushed a commit to branch camel-2.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.x by this push:
     new a265b02  Revert "CAMEL-13886: camel-servlet + camel-http4 with null body causes "Stream closed" IOException"
a265b02 is described below

commit a265b022cdee448fe97246c6deb5a5f059da437c
Author: Tadayoshi Sato <sa...@gmail.com>
AuthorDate: Thu Aug 22 12:46:16 2019 +0900

    Revert "CAMEL-13886: camel-servlet + camel-http4 with null body causes "Stream closed" IOException"
    
    This reverts commit eb33736ab1ddc84b83147ebc19fefd8ce104d75b.
    This causes test failures in camel-jetty and camel-servlet.
---
 components/camel-http-common/pom.xml               |  5 ---
 .../org/apache/camel/http/common/HttpHelper.java   |  4 +-
 .../apache/camel/http/common/HttpHelperTest.java   | 50 ----------------------
 3 files changed, 2 insertions(+), 57 deletions(-)

diff --git a/components/camel-http-common/pom.xml b/components/camel-http-common/pom.xml
index 6f690f4..16e9d5e 100644
--- a/components/camel-http-common/pom.xml
+++ b/components/camel-http-common/pom.xml
@@ -84,11 +84,6 @@
       <version>${assertj-version}</version>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-core</artifactId>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
 
 </project>
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
index 6d7dae4..c2d271c 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
@@ -203,7 +203,7 @@ public final class HttpHelper {
      * @throws IOException is thrown if error reading response body
      */
     public static Object readRequestBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
-        if (is == null || is.available() <= 0) {
+        if (is == null) {
             return null;
         }
         boolean disableStreamCaching = false;
@@ -232,7 +232,7 @@ public final class HttpHelper {
      * @throws IOException is thrown if error reading response body
      */
     public static Object readResponseBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
-        if (is == null || is.available() <= 0) {
+        if (is == null) {
             return null;
         }
         // convert the input stream to StreamCache if the stream cache is not disabled
diff --git a/components/camel-http-common/src/test/java/org/apache/camel/http/common/HttpHelperTest.java b/components/camel-http-common/src/test/java/org/apache/camel/http/common/HttpHelperTest.java
deleted file mode 100644
index 0cfca20..0000000
--- a/components/camel-http-common/src/test/java/org/apache/camel/http/common/HttpHelperTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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.camel.http.common;
-
-import java.io.IOException;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.impl.DefaultExchange;
-import org.junit.Test;
-
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class HttpHelperTest {
-
-    @Test
-    public void readRequestBodyFromServletRequest() throws IOException {
-        HttpServletRequest request = mock(HttpServletRequest.class);
-        ServletInputStream is = mock(ServletInputStream.class);
-        when(request.getInputStream()).thenReturn(is);
-        when(is.available()).thenReturn(0);
-
-        CamelContext context = new DefaultCamelContext();
-        Exchange exchange = new DefaultExchange(context);
-
-        assertNull(HttpHelper.readRequestBodyFromServletRequest(null, exchange));
-        assertNull(HttpHelper.readRequestBodyFromServletRequest(request, exchange));
-    }
-
-}