You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2014/11/05 14:31:53 UTC
[3/9] git commit: [OLINGO-468] Minor code clean up
[OLINGO-468] Minor code clean up
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/d84f843f
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/d84f843f
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/d84f843f
Branch: refs/heads/OLINGO-450_FunctionActionExecution
Commit: d84f843f227d5a7f3f1240fb445efe5928751b63
Parents: 9e5b284
Author: Michael Bolz <mi...@sap.com>
Authored: Thu Oct 23 14:38:17 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Thu Oct 23 14:38:17 2014 +0200
----------------------------------------------------------------------
.../olingo/commons/core/edm/AbstractEdm.java | 1 -
.../server/core/ODataHttpHandlerImpl.java | 30 ++++++++++++--------
2 files changed, 18 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d84f843f/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
index e9aea82..bc0b304 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
@@ -106,7 +106,6 @@ public abstract class AbstractEdm implements Edm {
aliasToNamespaceInfo = new HashMap<String, String>();
for (EdmSchema schema : schemas.values()) {
final String namespace = schema.getNamespace();
- schemas.put(namespace, schema);
if (schema.getAlias() != null) {
aliasToNamespaceInfo.put(schema.getAlias(), namespace);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d84f843f/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
index b06c3c8..36cbd18 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
@@ -18,6 +18,7 @@
*/
package org.apache.olingo.server.core;
+import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -59,7 +60,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
@Override
public void process(final HttpServletRequest request, final HttpServletResponse response) {
ODataRequest odRequest = null;
- ODataResponse odResponse = null;
+ ODataResponse odResponse;
try {
odRequest = createODataRequest(request, split);
odResponse = handler.process(odRequest);
@@ -99,11 +100,11 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
InputStream input = odResponse.getContent();
if (input != null) {
- OutputStream output;
+ OutputStream output = null;
try {
output = response.getOutputStream();
byte[] buffer = new byte[1024];
- int n = 0;
+ int n;
while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
}
@@ -111,13 +112,18 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
LOG.error(e.getMessage(), e);
throw new ODataRuntimeException(e);
} finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- throw new ODataRuntimeException(e);
- }
- }
+ closeStream(output);
+ closeStream(input);
+ }
+ }
+ }
+
+ private static void closeStream(Closeable closeable) {
+ if(closeable != null) {
+ try {
+ closeable.close();
+ } catch (IOException e) {
+ LOG.error(e.getMessage(), e);
}
}
}
@@ -150,9 +156,9 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
if (xHttpMethod == null && xHttpMethodOverride == null) {
odRequest.setMethod(httpRequestMethod);
- } else if (xHttpMethod == null && xHttpMethodOverride != null) {
+ } else if (xHttpMethod == null) {
odRequest.setMethod(HttpMethod.valueOf(xHttpMethodOverride));
- } else if (xHttpMethod != null && xHttpMethodOverride == null) {
+ } else if (xHttpMethodOverride == null) {
odRequest.setMethod(HttpMethod.valueOf(xHttpMethod));
} else {
if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {