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 2013/12/12 08:18:57 UTC

git commit: [OLINGO-32] Fix NPE in ListsProcessor

Updated Branches:
  refs/heads/master c87def1ec -> d6d839b21


[OLINGO-32] Fix NPE in ListsProcessor


Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/commit/d6d839b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/tree/d6d839b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/diff/d6d839b2

Branch: refs/heads/master
Commit: d6d839b217240ce2ed1f8f376fa3fcf696efaa6c
Parents: c87def1
Author: Michael Bolz <mi...@apache.org>
Authored: Thu Dec 12 08:18:37 2013 +0100
Committer: Michael Bolz <mi...@apache.org>
Committed: Thu Dec 12 08:18:37 2013 +0100

----------------------------------------------------------------------
 .../core/annotation/processor/ListsProcessor.java     | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/d6d839b2/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/core/annotation/processor/ListsProcessor.java
----------------------------------------------------------------------
diff --git a/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/core/annotation/processor/ListsProcessor.java b/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/core/annotation/processor/ListsProcessor.java
index 19218d7..d002fad 100644
--- a/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/core/annotation/processor/ListsProcessor.java
+++ b/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/core/annotation/processor/ListsProcessor.java
@@ -1219,11 +1219,21 @@ public class ListsProcessor extends DataSourceProcessor {
         try {
           int result = 0;
           for (final OrderExpression expression : orderBy.getOrders()) {
-            result = evaluateExpression(entity1, expression.getExpression()).compareTo(
-                evaluateExpression(entity2, expression.getExpression()));
+            String first = evaluateExpression(entity1, expression.getExpression());
+            String second = evaluateExpression(entity2, expression.getExpression());
+            
+            if (first != null && second != null) {
+              result = first.compareTo(second);
+            } else if (first == null && second != null) {
+              result = 1;
+            } else if (first != null && second == null) {
+              result = -1;
+            }
+
             if (expression.getSortOrder() == SortOrder.desc) {
               result = -result;
             }
+            
             if (result != 0) {
               break;
             }