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 2016/03/25 05:35:55 UTC

olingo-odata4 git commit: [OLINGO-852] Fixed Apache analysis issues

Repository: olingo-odata4
Updated Branches:
  refs/heads/master 9658091ae -> 3190d00fd


[OLINGO-852] Fixed Apache analysis issues


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/3190d00f
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/3190d00f
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/3190d00f

Branch: refs/heads/master
Commit: 3190d00fd1c368dc83d90d050dd88e1ed46b544a
Parents: 9658091
Author: mibo <mi...@apache.org>
Authored: Fri Mar 25 05:33:34 2016 +0100
Committer: mibo <mi...@apache.org>
Committed: Fri Mar 25 05:33:34 2016 +0100

----------------------------------------------------------------------
 .../olingo/commons/core/edm/AbstractEdm.java    |  3 -
 .../EntityCollectionSerializerOptions.java      |  6 +-
 .../olingo/server/core/ODataDispatcher.java     |  3 +-
 .../olingo/server/core/ODataHandlerImpl.java    |  2 +-
 .../core/debug/DebugResponseHelperImpl.java     | 42 +++++--------
 .../olingo/server/core/debug/DebugTabUri.java   | 16 +++--
 .../serializer/BatchResponseSerializer.java     |  4 +-
 .../core/serializer/utils/ResultHelper.java     | 65 --------------------
 .../olingo/server/core/uri/parser/Parser.java   | 14 ++++-
 .../server/core/uri/parser/ParserHelper.java    | 16 +++--
 .../queryoption/expression/EnumerationImpl.java |  2 +-
 .../queryoption/expression/TypeLiteralImpl.java |  2 +-
 12 files changed, 56 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3190d00f/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 b31b827..44597f3 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,9 +106,6 @@ public abstract class AbstractEdm implements Edm {
     Map<String, EdmSchema> localSchemas = createSchemas();
     schemas = Collections.synchronizedMap(localSchemas);
 
-    if (schemas == null) {
-      schemas = Collections.emptyMap();
-    }
     schemaList = Collections.unmodifiableList(new ArrayList<EdmSchema>(schemas.values()));
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3190d00f/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/EntityCollectionSerializerOptions.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/EntityCollectionSerializerOptions.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/EntityCollectionSerializerOptions.java
index 9578ba7..6e49f81 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/EntityCollectionSerializerOptions.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/EntityCollectionSerializerOptions.java
@@ -33,7 +33,7 @@ public class EntityCollectionSerializerOptions {
   private SelectOption select;
   private boolean writeOnlyReferences;
   private String id;
-  private ODataContentWriteErrorCallback ODataContentWriteErrorCallback;
+  private ODataContentWriteErrorCallback odataContentWriteErrorCallback;
   private String xml10InvalidCharReplacement;
 
   /** Gets the {@link ContextURL}. */
@@ -75,7 +75,7 @@ public class EntityCollectionSerializerOptions {
    *
    */
   public ODataContentWriteErrorCallback getODataContentWriteErrorCallback() {
-    return ODataContentWriteErrorCallback;
+    return odataContentWriteErrorCallback;
   }
   /** Gets the replacement string for unicode characters, that is not allowed in XML 1.0 */
   public String xml10InvalidCharReplacement() {
@@ -140,7 +140,7 @@ public class EntityCollectionSerializerOptions {
      * @return the builder
      */
     public Builder writeContentErrorCallback(ODataContentWriteErrorCallback ODataContentWriteErrorCallback) {
-      options.ODataContentWriteErrorCallback = ODataContentWriteErrorCallback;
+      options.odataContentWriteErrorCallback = ODataContentWriteErrorCallback;
       return this;
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3190d00f/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java
index 052a0f7..3d4bdc7 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataDispatcher.java
@@ -543,7 +543,8 @@ public class ODataDispatcher {
       throws ODataHandlerException, ContentNegotiatorException {
     if (contentTypeHeader == null) {
       if (mustNotBeNull) {
-        throw new ODataHandlerException(contentTypeHeader, ODataHandlerException.MessageKeys.MISSING_CONTENT_TYPE);
+        throw new ODataHandlerException("ContentTypeHeader parameter is null",
+            ODataHandlerException.MessageKeys.MISSING_CONTENT_TYPE);
       }
       return null;
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3190d00f/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandlerImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandlerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandlerImpl.java
index 1d6a415..705c767 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandlerImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandlerImpl.java
@@ -211,7 +211,7 @@ public class ODataHandlerImpl implements ODataHandler {
 
       final String formatOption = SystemQueryOptionKind.FORMAT.toString();
       int index = query.indexOf(formatOption);
-      int endIndex = query.indexOf("&", index);
+      int endIndex = query.indexOf('&', index);
       if(endIndex == -1) {
         endIndex = query.length();
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3190d00f/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugResponseHelperImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugResponseHelperImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugResponseHelperImpl.java
index 5ee63b8..98c2930 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugResponseHelperImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugResponseHelperImpl.java
@@ -68,24 +68,21 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
       final List<DebugTab> parts = createParts(debugInfo);
 
       ODataResponse response = new ODataResponse();
-      String contentTypeString;
-      InputStream body;
-      switch (requestedFormat) {
-      case DOWNLOAD:
-        response.setHeader("Content-Disposition", "attachment; filename=OData-Response."
-            + new Date().toString().replace(' ', '_').replace(':', '.') + ".html");
-        // Download is the same as html except for the above header
-      case HTML:
+      final String contentTypeString;
+      final InputStream body;
+      if(requestedFormat == DebugFormat.DOWNLOAD || requestedFormat == DebugFormat.HTML) {
         String title = debugInfo.getRequest() == null ?
             "V4 Service" : "V4 Service: " + debugInfo.getRequest().getRawODataPath();
         body = wrapInHtml(parts, title);
         contentTypeString = ContentType.TEXT_HTML.toContentTypeString();
-        break;
-      case JSON:
-      default:
+      } else { // for JSON and also default response handling
         body = wrapInJson(parts);
         contentTypeString = ContentType.APPLICATION_JSON.toContentTypeString();
-        break;
+      }
+      // for download add additional Content-Disposition header
+      if(requestedFormat == DebugFormat.DOWNLOAD) {
+        response.setHeader("Content-Disposition", "attachment; filename=OData-Response."
+            + new Date().toString().replace(' ', '_').replace(':', '.') + ".html");
       }
       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
       response.setHeader(HttpHeader.CONTENT_TYPE, contentTypeString);
@@ -133,7 +130,6 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
   }
 
   private InputStream wrapInJson(final List<DebugTab> parts) throws IOException {
-    IOException cachedException = null;
     OutputStream outputStream = null;
 
     try {
@@ -170,11 +166,7 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
         try {
           outputStream.close();
         } catch (IOException e) {
-          if (cachedException != null) {
-            throw cachedException;
-          } else {
-            throw e;
-          }
+          throw e;
         }
       }
     }
@@ -265,12 +257,12 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
       gen.writeNull();
     } else {
       gen.writeStartObject();
-      for (final String name : entries.keySet()) {
-        gen.writeFieldName(name);
-        if (entries.get(name) == null) {
+      for (final Map.Entry<String, String> entry : entries.entrySet()) {
+        gen.writeFieldName(entry.getKey());
+        if (entry.getValue() == null) {
           gen.writeNull();
         } else {
-          gen.writeString(entries.get(name));
+          gen.writeString(entry.getValue());
         }
       }
       gen.writeEndObject();
@@ -282,10 +274,10 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
     .append("<tr><th class=\"name\">Name</th><th class=\"value\">Value</th></tr>\n")
     .append("</thead>\n<tbody>\n");
     if (entries != null && !entries.isEmpty()) {
-      for (final String name : entries.keySet()) {
-        writer.append("<tr><td class=\"name\">").append(name).append("</td>")
+      for (final Map.Entry<String, String> entry : entries.entrySet()) {
+        writer.append("<tr><td class=\"name\">").append(entry.getKey()).append("</td>")
         .append("<td class=\"value\">")
-        .append(escapeHtml(entries.get(name)))
+        .append(escapeHtml(entry.getValue()))
         .append("</td></tr>\n");
       }
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3190d00f/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabUri.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabUri.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabUri.java
index 7909334..842b8f5 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabUri.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabUri.java
@@ -276,24 +276,22 @@ public class DebugTabUri implements DebugTab {
   }
 
   private String getSelectString(final SelectItem selectItem) {
-    String selectedProperty = "";
     if (selectItem.isStar()) {
       if (selectItem.getAllOperationsInSchemaNameSpace() == null) {
-        selectedProperty = "*";
+        return "*";
       } else {
-        selectedProperty = selectItem.getAllOperationsInSchemaNameSpace().getFullQualifiedNameAsString() + ".*";
+        return selectItem.getAllOperationsInSchemaNameSpace().getFullQualifiedNameAsString() + ".*";
       }
     } else {
-      boolean first = true;
+      final StringBuilder tmp = new StringBuilder();
       for (UriResource resourcePart : selectItem.getResourcePath().getUriResourceParts()) {
-        if (!first) {
-          selectedProperty += '/';
+        if (tmp.length() > 0) {
+          tmp.append('/');
         }
-        selectedProperty += resourcePart.toString();
-        first = false;
+        tmp.append(resourcePart.toString());
       }
+      return tmp.toString();
     }
-    return selectedProperty;
   }
 
   private void appendSearchJson(final JsonGenerator json, final SearchExpression searchExpression) throws IOException {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3190d00f/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java
index a5afba1..0a78c19 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/BatchResponseSerializer.java
@@ -227,10 +227,10 @@ public class BatchResponseSerializer {
   /**
    * Body part which is read and stored as bytes (no charset conversion).
    */
-  private class Body {
+  private static class Body {
     private final byte[] content;
 
-    public Body(final ODataResponse response) {
+    Body(final ODataResponse response) {
       content = getBody(response);
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3190d00f/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ResultHelper.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ResultHelper.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ResultHelper.java
deleted file mode 100644
index fd57593..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/utils/ResultHelper.java
+++ /dev/null
@@ -1,65 +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.olingo.server.core.serializer.utils;
-
-import org.apache.olingo.commons.api.ex.ODataRuntimeException;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channel;
-import java.nio.channels.Channels;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.WritableByteChannel;
-
-public class ResultHelper {
-
-  public static final int COPY_BUFFER_SIZE = 8192;
-
-  public static void copy(InputStream input, OutputStream output) {
-    copy(Channels.newChannel(input), Channels.newChannel(output));
-  }
-
-  public static void copy(ReadableByteChannel input, WritableByteChannel output) {
-    try {
-      ByteBuffer inBuffer = ByteBuffer.allocate(COPY_BUFFER_SIZE);
-      while (input.read(inBuffer) > 0) {
-        inBuffer.flip();
-        output.write(inBuffer);
-        inBuffer.clear();
-      }
-    } catch (IOException e) {
-      throw new ODataRuntimeException("Error on reading request content", e);
-    } finally {
-      closeStream(input);
-      closeStream(output);
-    }
-  }
-
-  private static void closeStream(final Channel closeable) {
-    if (closeable != null) {
-      try {
-        closeable.close();
-      } catch (IOException e) {
-        // ignore
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3190d00f/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
index b4469d8..0cc1977 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
@@ -44,6 +44,7 @@ import org.apache.olingo.server.api.uri.queryoption.FilterOption;
 import org.apache.olingo.server.api.uri.queryoption.OrderByItem;
 import org.apache.olingo.server.api.uri.queryoption.OrderByOption;
 import org.apache.olingo.server.api.uri.queryoption.QueryOption;
+import org.apache.olingo.server.api.uri.queryoption.SearchOption;
 import org.apache.olingo.server.api.uri.queryoption.SelectOption;
 import org.apache.olingo.server.api.uri.queryoption.SystemQueryOption;
 import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
@@ -58,6 +59,7 @@ import org.apache.olingo.server.core.uri.queryoption.FilterOptionImpl;
 import org.apache.olingo.server.core.uri.queryoption.FormatOptionImpl;
 import org.apache.olingo.server.core.uri.queryoption.IdOptionImpl;
 import org.apache.olingo.server.core.uri.queryoption.OrderByOptionImpl;
+import org.apache.olingo.server.core.uri.queryoption.SearchOptionImpl;
 import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl;
 import org.apache.olingo.server.core.uri.queryoption.SkipOptionImpl;
 import org.apache.olingo.server.core.uri.queryoption.SkipTokenOptionImpl;
@@ -224,10 +226,13 @@ public class Parser {
         throw new UriParserSyntaxException("Unknown system query option!",
             UriParserSyntaxException.MessageKeys.UNKNOWN_SYSTEM_QUERY_OPTION, optionName);
       }
-      SystemQueryOption systemOption = null;
+      final SystemQueryOptionImpl systemOption;
       switch (kind) {
       case SEARCH:
-        systemOption = new SearchParser().parse(optionValue);
+        SearchOption searchOption = new SearchParser().parse(optionValue);
+        SearchOptionImpl tmp = new SearchOptionImpl();
+        tmp.setSearchExpression(searchOption.getSearchExpression());
+        systemOption = tmp;
         break;
       case FILTER:
         systemOption = new FilterOptionImpl();
@@ -288,8 +293,11 @@ public class Parser {
       case LEVELS:
         throw new UriParserSyntaxException("System query option '$levels' is allowed only inside '$expand'!",
             UriParserSyntaxException.MessageKeys.SYSTEM_QUERY_OPTION_LEVELS_NOT_ALLOWED_HERE);
+      default:
+          throw new UriParserSyntaxException("System query option '" + kind + "' is not known!",
+              UriParserSyntaxException.MessageKeys.UNKNOWN_SYSTEM_QUERY_OPTION, optionName);
       }
-      ((SystemQueryOptionImpl) systemOption).setText(optionValue);
+      systemOption.setText(optionValue);
       return systemOption;
 
     } else if (optionName.startsWith(AT)) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3190d00f/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ParserHelper.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ParserHelper.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ParserHelper.java
index 9986542..e42a511 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ParserHelper.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ParserHelper.java
@@ -22,9 +22,11 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumMap;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Set;
 
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
@@ -156,6 +158,7 @@ public class ParserHelper {
       final Map<String, AliasQueryOption> aliases)
       throws UriParserException, UriValidationException {
     List<UriParameter> parameters = new ArrayList<UriParameter>();
+    Set<String> parameterNames = new HashSet<String>();
     ParserHelper.requireNext(tokenizer, TokenKind.OPEN);
     if (tokenizer.next(TokenKind.CLOSE)) {
       return parameters;
@@ -163,10 +166,11 @@ public class ParserHelper {
     do {
       ParserHelper.requireNext(tokenizer, TokenKind.ODataIdentifier);
       final String name = tokenizer.getText();
-      if (parameters.contains(name)) {
+      if (parameterNames.contains(name)) {
         throw new UriParserSemanticException("Duplicated function parameter " + name,
             UriParserSemanticException.MessageKeys.INVALID_KEY_VALUE, name);
       }
+      parameterNames.add(name);
       ParserHelper.requireNext(tokenizer, TokenKind.EQ);
       if (tokenizer.next(TokenKind.COMMA) || tokenizer.next(TokenKind.CLOSE) || tokenizer.next(TokenKind.EOF)) {
         throw new UriParserSyntaxException("Parameter value expected.", UriParserSyntaxException.MessageKeys.SYNTAX);
@@ -349,15 +353,17 @@ public class ParserHelper {
       final Edm edm, final EdmType referringType, final Map<String, AliasQueryOption> aliases)
       throws UriParserException, UriValidationException {
     final EdmProperty edmProperty = edmKeyPropertyRef == null ? null : edmKeyPropertyRef.getProperty();
-    if (nextPrimitiveTypeValue(tokenizer,
-        edmProperty == null ? null : (EdmPrimitiveType) edmProperty.getType(),
-        edmProperty == null ? false : edmProperty.isNullable())) {
+    final EdmPrimitiveType primitiveType = edmProperty == null ? null : (EdmPrimitiveType) edmProperty.getType();
+    final boolean nullable = edmProperty != null && edmProperty.isNullable();
+
+    if (nextPrimitiveTypeValue(tokenizer, primitiveType, nullable)) {
       final String literalValue = tokenizer.getText();
       ParserHelper.requireNext(tokenizer, TokenKind.CLOSE);
       return createUriParameter(edmProperty, edmKeyPropertyRef.getName(), literalValue, edm, referringType, aliases);
     } else {
+      String keyPropertyRefName = edmKeyPropertyRef == null ? "NULL EdmKeyPropertyRef" : edmKeyPropertyRef.getName();
       throw new UriParserSemanticException("The key value is not valid.",
-          UriParserSemanticException.MessageKeys.INVALID_KEY_VALUE, edmKeyPropertyRef.getName());
+          UriParserSemanticException.MessageKeys.INVALID_KEY_VALUE, keyPropertyRefName);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3190d00f/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/EnumerationImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/EnumerationImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/EnumerationImpl.java
index 45a4ba0..4dcd664 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/EnumerationImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/EnumerationImpl.java
@@ -56,7 +56,7 @@ public class EnumerationImpl implements Enumeration {
 
   @Override
   public String toString() {
-    return type == null ? null :
+    return type == null ? "NULL" :
       type.getFullQualifiedName().getFullQualifiedNameAsString() + getValues();
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3190d00f/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/TypeLiteralImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/TypeLiteralImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/TypeLiteralImpl.java
index 2e6a40e..d6f4118 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/TypeLiteralImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/TypeLiteralImpl.java
@@ -44,6 +44,6 @@ public class TypeLiteralImpl implements TypeLiteral {
 
   @Override
   public String toString() {
-    return type == null ? null : type.getFullQualifiedName().getFullQualifiedNameAsString();
+    return type == null ? "NULL" : type.getFullQualifiedName().getFullQualifiedNameAsString();
   }
 }