Repository: olingo-odata4
Updated Branches:
  refs/heads/master d3fad1b16 -> 3e9e69314


[OLINGO-989] static check fix-Reliance on default encoding

Signed-off-by: Christian Amend <[email protected]>


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

Branch: refs/heads/master
Commit: 7c382806b7509a03c4831f2e65aa95128f34636f
Parents: d3fad1b
Author: Kanika Jashrapuria <[email protected]>
Authored: Mon Apr 25 16:30:38 2016 +0530
Committer: Christian Amend <[email protected]>
Committed: Wed Jul 27 14:40:03 2016 +0200

----------------------------------------------------------------------
 .../request/AbstractODataBasicRequest.java      | 15 ++++++++-----
 .../request/AbstractODataRequest.java           |  4 +++-
 .../request/batch/AbstractBatchManager.java     | 18 ++++++++-------
 .../batch/AbstractODataBatchRequestItem.java    | 23 +++++++++++---------
 .../request/batch/ODataChangesetImpl.java       | 18 ++++++++-------
 .../streamed/AbstractODataStreamedRequest.java  |  4 +++-
 6 files changed, 48 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7c382806/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
index 7a53468..e8b1659 100644
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataBasicRequest.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * with the License. You may obtain a copy of the License at
  *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -21,6 +21,7 @@ package org.apache.olingo.client.core.communication.request;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
+import java.nio.charset.Charset;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
 
@@ -43,6 +44,8 @@ import org.apache.olingo.commons.api.http.HttpMethod;
 public abstract class AbstractODataBasicRequest<T extends ODataResponse>
     extends AbstractODataRequest implements ODataBasicRequest<T> {
 
+  private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
+
   /**
    * Constructor.
    *
@@ -101,7 +104,7 @@ public abstract class AbstractODataBasicRequest<T extends 
ODataResponse>
     try {
       req.rawAppend(toByteArray());
       if (StringUtils.isNotBlank(contentId)) {
-        req.rawAppend((ODataBatchConstants.CHANGESET_CONTENT_ID_NAME + ": " + 
contentId).getBytes());
+        req.rawAppend((ODataBatchConstants.CHANGESET_CONTENT_ID_NAME + ": " + 
contentId).getBytes(DEFAULT_CHARSET));
         req.rawAppend(ODataStreamer.CRLF);
       }
       req.rawAppend(ODataStreamer.CRLF);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7c382806/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
index 6666eba..d6274c0 100644
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Constructor;
 import java.net.URI;
+import java.nio.charset.Charset;
 import java.util.Collection;
 
 import org.apache.commons.io.IOUtils;
@@ -54,6 +55,7 @@ import org.apache.olingo.commons.api.http.HttpMethod;
 public abstract class AbstractODataRequest extends AbstractRequest implements 
ODataRequest {
 
   protected final ODataClient odataClient;
+  private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
 
   /**
    * OData request method.
@@ -220,7 +222,7 @@ public abstract class AbstractODataRequest extends 
AbstractRequest implements OD
       final StringBuilder requestBuilder = new StringBuilder();
       requestBuilder.append(getMethod().toString()).append(' 
').append(uri.toString()).append(' ').append("HTTP/1.1");
 
-      baos.write(requestBuilder.toString().getBytes());
+      baos.write(requestBuilder.toString().getBytes(DEFAULT_CHARSET));
 
       baos.write(ODataStreamer.CRLF);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7c382806/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchManager.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchManager.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchManager.java
index 5609363..fb48d2b 100644
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchManager.java
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchManager.java
@@ -1,23 +1,24 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * with the License. You may obtain a copy of the License at
  *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
 package org.apache.olingo.client.core.communication.request.batch;
 
+import java.nio.charset.Charset;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
@@ -37,6 +38,7 @@ import 
org.apache.olingo.client.core.communication.request.Wrapper;
 public abstract class AbstractBatchManager extends 
AbstractODataStreamManager<ODataBatchResponse> {
 
   protected final boolean continueOnError;
+  private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
 
   /**
    * Batch request current item.
@@ -49,7 +51,7 @@ public abstract class AbstractBatchManager extends 
AbstractODataStreamManager<OD
   protected final ODataBatchRequest req;
 
   protected AbstractBatchManager(final ODataBatchRequest req,
-          final Wrapper<Future<HttpResponse>> futureWrap, final boolean 
continueOnError) {
+      final Wrapper<Future<HttpResponse>> futureWrap, final boolean 
continueOnError) {
 
     super(futureWrap);
     this.req = req;
@@ -123,7 +125,7 @@ public abstract class AbstractBatchManager extends 
AbstractODataStreamManager<OD
     newLine();
 
     // stream batch-boundary
-    stream(("--" + ((AbstractODataBatchRequest<?, ?>) 
req).boundary).getBytes());
+    stream(("--" + ((AbstractODataBatchRequest<?, ?>) 
req).boundary).getBytes(DEFAULT_CHARSET));
     newLine();
   }
 
@@ -133,7 +135,7 @@ public abstract class AbstractBatchManager extends 
AbstractODataStreamManager<OD
   protected void streamCloseDelimiter() {
     // stream close-delimiter
     newLine();
-    stream(("--" + ((AbstractODataBatchRequest<?, ?>) req).boundary + 
"--").getBytes());
+    stream(("--" + ((AbstractODataBatchRequest<?, ?>) req).boundary + 
"--").getBytes(DEFAULT_CHARSET));
   }
 
   protected abstract void validateSingleRequest(ODataBatchableRequest request);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7c382806/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequestItem.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequestItem.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequestItem.java
index c30665c..0a4cddf 100644
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequestItem.java
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequestItem.java
@@ -1,23 +1,25 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * with the License. You may obtain a copy of the License at
  *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
 package org.apache.olingo.client.core.communication.request.batch;
 
+import java.nio.charset.Charset;
+
 import org.apache.olingo.client.api.ODataBatchConstants;
 import 
org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
 import 
org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest;
@@ -28,12 +30,13 @@ import 
org.apache.olingo.client.core.communication.request.AbstractODataStreamer
  * Abstract representation of a batch request item.
  */
 public abstract class AbstractODataBatchRequestItem extends 
AbstractODataStreamer
-        implements ODataBatchRequestItem {
+    implements ODataBatchRequestItem {
 
   /**
    * Stream started check.
    */
   protected boolean hasStreamedSomething = false;
+  private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
 
   /**
    * Stream open check.
@@ -81,8 +84,8 @@ public abstract class AbstractODataBatchRequestItem extends 
AbstractODataStreame
    * @param contentId changeset item id.
    */
   protected void streamRequestHeader(final String contentId) {
-    //stream batch content type
-    stream(ODataBatchConstants.ITEM_CONTENT_TYPE_LINE.getBytes());
+    // stream batch content type
+    
stream(ODataBatchConstants.ITEM_CONTENT_TYPE_LINE.getBytes(DEFAULT_CHARSET));
     newLine();
     stream(ODataBatchConstants.ITEM_TRANSFER_ENCODING_LINE.getBytes());
     newLine();
@@ -97,8 +100,8 @@ public abstract class AbstractODataBatchRequestItem extends 
AbstractODataStreame
    * @param request request to be batched.
    */
   protected void streamRequestHeader(final ODataBatchableRequest request) {
-    //stream batch content type
-    stream(ODataBatchConstants.ITEM_CONTENT_TYPE_LINE.getBytes());
+    // stream batch content type
+    
stream(ODataBatchConstants.ITEM_CONTENT_TYPE_LINE.getBytes(DEFAULT_CHARSET));
     newLine();
     stream(ODataBatchConstants.ITEM_TRANSFER_ENCODING_LINE.getBytes());
     newLine();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7c382806/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetImpl.java
index 51a55ab..e97c01c 100644
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetImpl.java
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetImpl.java
@@ -1,23 +1,24 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * with the License. You may obtain a copy of the License at
  *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
 package org.apache.olingo.client.core.communication.request.batch;
 
+import java.nio.charset.Charset;
 import java.util.UUID;
 
 import 
org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
@@ -32,12 +33,13 @@ import org.apache.olingo.commons.api.http.HttpMethod;
  * Changeset wrapper for the corresponding batch item.
  */
 public class ODataChangesetImpl extends AbstractODataBatchRequestItem
-        implements ODataChangeset {
+    implements ODataChangeset {
 
   /**
    * ContentId.
    */
   private int contentId = 0;
+  private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
 
   /**
    * Changeset boundary.
@@ -79,7 +81,7 @@ public class ODataChangesetImpl extends 
AbstractODataBatchRequestItem
     // stream close-delimiter
     if (hasStreamedSomething) {
       newLine();
-      stream(("--" + boundary + "--").getBytes());
+      stream(("--" + boundary + "--").getBytes(DEFAULT_CHARSET));
       newLine();
       newLine();
     }
@@ -100,7 +102,7 @@ public class ODataChangesetImpl extends 
AbstractODataBatchRequestItem
 
     if (!hasStreamedSomething) {
       stream((HttpHeader.CONTENT_TYPE + ": "
-              + ContentType.MULTIPART_MIXED + ";boundary=" + 
boundary).getBytes());
+          + ContentType.MULTIPART_MIXED + ";boundary=" + 
boundary).getBytes(DEFAULT_CHARSET));
 
       newLine();
       newLine();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7c382806/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java
index 734762f..76e5633 100644
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java
@@ -21,6 +21,7 @@ package 
org.apache.olingo.client.core.communication.request.streamed;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
+import java.nio.charset.Charset;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
 
@@ -54,6 +55,7 @@ public abstract class AbstractODataStreamedRequest<V extends 
ODataResponse, T ex
    * OData payload stream manager.
    */
   protected ODataPayloadManager<V> payloadManager;
+  private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
 
   /**
    * Wrapper for actual streamed request's future. This holds information 
about the HTTP request / response currently
@@ -150,7 +152,7 @@ public abstract class AbstractODataStreamedRequest<V 
extends ODataResponse, T ex
 
       req.rawAppend(toByteArray());
       if (StringUtils.isNotBlank(contentId)) {
-        req.rawAppend((ODataBatchConstants.CHANGESET_CONTENT_ID_NAME + ": " + 
contentId).getBytes());
+        req.rawAppend((ODataBatchConstants.CHANGESET_CONTENT_ID_NAME + ": " + 
contentId).getBytes(DEFAULT_CHARSET));
         req.rawAppend(ODataStreamer.CRLF);
       }
       req.rawAppend(ODataStreamer.CRLF);

Reply via email to