olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From archana...@apache.org
Subject olingo-odata4 git commit: [OLINGO-1191]Code improvements
Date Thu, 12 Oct 2017 11:49:32 GMT
Repository: olingo-odata4
Updated Branches:
  refs/heads/master ac02329d1 -> 3344e05b3


[OLINGO-1191]Code improvements


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

Branch: refs/heads/master
Commit: 3344e05b349a5f406f95be4217f48e55f8090824
Parents: ac02329
Author: Archana Rai <archana.rai@sap.com>
Authored: Thu Oct 12 17:19:23 2017 +0530
Committer: Archana Rai <archana.rai@sap.com>
Committed: Thu Oct 12 17:19:23 2017 +0530

----------------------------------------------------------------------
 .../request/AsyncRequestWrapperImpl.java           |  2 +-
 .../request/batch/ODataBatchLineIteratorImpl.java  |  5 +++++
 .../client/core/data/ServiceDocumentImpl.java      | 17 ++++++++---------
 .../core/domain/ClientCollectionValueImpl.java     |  2 +-
 .../client/core/domain/ClientComplexValueImpl.java |  8 ++++----
 .../olingo/client/core/domain/ClientDeltaImpl.java |  6 +++---
 .../olingo/server/api/ODataLibraryException.java   |  8 ++++----
 7 files changed, 26 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3344e05b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncRequestWrapperImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncRequestWrapperImpl.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncRequestWrapperImpl.java
index 6619a10..736d2c7 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncRequestWrapperImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AsyncRequestWrapperImpl.java
@@ -203,7 +203,7 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends
AbstractRe
 
           try {
             // wait for retry-after
-            Thread.sleep(retryAfter * 1000);
+            Thread.sleep((long)retryAfter * 1000);
           } catch (InterruptedException ignore) {
             // ignore
           }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3344e05b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchLineIteratorImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchLineIteratorImpl.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchLineIteratorImpl.java
index 34d621a..d031963 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchLineIteratorImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataBatchLineIteratorImpl.java
@@ -18,6 +18,8 @@
  */
 package org.apache.olingo.client.core.communication.request.batch;
 
+import java.util.NoSuchElementException;
+
 import org.apache.commons.io.LineIterator;
 import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
 
@@ -63,6 +65,9 @@ public class ODataBatchLineIteratorImpl implements ODataBatchLineIterator
{
    */
   @Override
   public String next() {
+    if(!hasNext()){
+      throw new NoSuchElementException();
+    }
     return nextLine();
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3344e05b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/ServiceDocumentImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/ServiceDocumentImpl.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/ServiceDocumentImpl.java
index 4bf6a09..a0a1630 100755
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/ServiceDocumentImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/ServiceDocumentImpl.java
@@ -134,17 +134,16 @@ public final class ServiceDocumentImpl implements ServiceDocument {
     if (title != null ? !title.equals(that.title) : that.title != null) {
       return false;
     }
-    if (entitySets != null ? !entitySets.equals(that.entitySets) : that.entitySets != null)
{
+    if (!entitySets.equals(that.entitySets)) {
       return false;
     }
-    if (functionImports != null ? !functionImports.equals(that.functionImports) : that.functionImports
!= null) {
+    if (!functionImports.equals(that.functionImports)) {
       return false;
     }
-    if (singletons != null ? !singletons.equals(that.singletons) : that.singletons != null)
{
+    if (!singletons.equals(that.singletons)) {
       return false;
     }
-    if (relatedServiceDocuments != null ?
-        !relatedServiceDocuments.equals(that.relatedServiceDocuments) : that.relatedServiceDocuments
!= null) {
+    if (!relatedServiceDocuments.equals(that.relatedServiceDocuments)) {
       return false;
     }
     return !(metadata != null ? !metadata.equals(that.metadata) : that.metadata != null);
@@ -154,10 +153,10 @@ public final class ServiceDocumentImpl implements ServiceDocument {
   @Override
   public int hashCode() {
     int result = title != null ? title.hashCode() : 0;
-    result = 31 * result + (entitySets != null ? entitySets.hashCode() : 0);
-    result = 31 * result + (functionImports != null ? functionImports.hashCode() : 0);
-    result = 31 * result + (singletons != null ? singletons.hashCode() : 0);
-    result = 31 * result + (relatedServiceDocuments != null ? relatedServiceDocuments.hashCode()
: 0);
+    result = 31 * result + (entitySets.hashCode());
+    result = 31 * result + (functionImports.hashCode());
+    result = 31 * result + (singletons.hashCode());
+    result = 31 * result + (relatedServiceDocuments.hashCode());
     result = 31 * result + (metadata != null ? metadata.hashCode() : 0);
     return result;
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3344e05b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientCollectionValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientCollectionValueImpl.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientCollectionValueImpl.java
index 2a3aebc..0a0ac33 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientCollectionValueImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientCollectionValueImpl.java
@@ -124,7 +124,7 @@ public class ClientCollectionValueImpl<OV extends ClientValue> extends
AbstractC
   public int hashCode() {
     final int prime = 31;
     int result = super.hashCode();
-    result = prime * result + ((values == null) ? 0 : values.hashCode());
+    result = prime * result + (values.hashCode());
     return result;
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3344e05b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientComplexValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientComplexValueImpl.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientComplexValueImpl.java
index 1338a92..fd8d36f 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientComplexValueImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientComplexValueImpl.java
@@ -207,10 +207,10 @@ public class ClientComplexValueImpl extends AbstractClientValue implements
Clien
   public int hashCode() {
     final int prime = 31;
     int result = super.hashCode();
-    result = prime * result + ((annotations == null) ? 0 : annotations.hashCode());
-    result = prime * result + ((associationLinks == null) ? 0 : associationLinks.hashCode());
-    result = prime * result + ((fields == null) ? 0 : fields.hashCode());
-    result = prime * result + ((navigationLinks == null) ? 0 : navigationLinks.hashCode());
+    result = prime * result + (annotations.hashCode());
+    result = prime * result + (associationLinks.hashCode());
+    result = prime * result + (fields.hashCode());
+    result = prime * result + (navigationLinks.hashCode());
     return result;
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3344e05b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientDeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientDeltaImpl.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientDeltaImpl.java
index 30f3356..f0ce647 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientDeltaImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientDeltaImpl.java
@@ -61,9 +61,9 @@ public class ClientDeltaImpl extends ClientEntitySetImpl implements ClientDelta
   public int hashCode() {
     final int prime = 31;
     int result = super.hashCode();
-    result = prime * result + ((addedLinks == null) ? 0 : addedLinks.hashCode());
-    result = prime * result + ((deletedEntities == null) ? 0 : deletedEntities.hashCode());
-    result = prime * result + ((deletedLinks == null) ? 0 : deletedLinks.hashCode());
+    result = prime * result + (addedLinks.hashCode());
+    result = prime * result + (deletedEntities.hashCode());
+    result = prime * result + (deletedLinks.hashCode());
     return result;
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3344e05b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataLibraryException.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataLibraryException.java
b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataLibraryException.java
index 6c9fe05..f5b175b 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataLibraryException.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataLibraryException.java
@@ -112,13 +112,11 @@ public abstract class ODataLibraryException extends ODataException {
 
   private ODataErrorMessage buildMessage(final ResourceBundle bundle, final Locale locale)
{
     String message = null;
-
+    StringBuilder builder = new StringBuilder();
+    Formatter f = new Formatter(builder, locale);
     try {
       message = bundle.getString(getClass().getSimpleName() + '.' + messageKey.getKey());
-      StringBuilder builder = new StringBuilder();
-      Formatter f = new Formatter(builder, locale);
       f.format(message, parameters);
-      f.close();
       Locale usedLocale = bundle.getLocale();
       if (Locale.ROOT.equals(usedLocale)) {
         usedLocale = DEFAULT_LOCALE;
@@ -129,6 +127,8 @@ public abstract class ODataLibraryException extends ODataException {
     } catch (MissingFormatArgumentException e) {
       return new ODataErrorMessage("Missing replacement for place holder in message '" +
message +
           "' for following arguments '" + Arrays.toString(parameters) + "'!", DEFAULT_LOCALE);
+    }finally{
+      f.close();
     }
   }
 


Mime
View raw message