This is an automated email from the ASF dual-hosted git repository. mibo pushed a commit to branch pr-14 in repository https://gitbox.apache.org/repos/asf/olingo-odata2.git
commit 35e99abec2ea5abd77dea15e594ec4cd1a257f43 Author: Song Yihan <[email protected]> AuthorDate: Wed Jan 3 14:56:11 2018 +0800 [OLINGO-1219] Fix NullPointerException if given input is null in current Encoder implementation, if given input is null, an NPE would be thrown The scenario would be, consider an Entity which key is allowed to be null in Edmx, thus, the data retrieved in data source would be a HashMap only with non-null value, when createEntryKey<-createSelfLink, we generate the key representation from the given data, some of the key would be null and passed to Encoder, which would throw NullPointerException --- .../main/java/org/apache/olingo/odata2/core/commons/Encoder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/commons/Encoder.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/commons/Encoder.java index aceb6cf..478b83c 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/commons/Encoder.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/commons/Encoder.java @@ -96,7 +96,12 @@ public class Encoder { */ private String encodeInternal(final String input) { StringBuilder resultStr = new StringBuilder(); - + + // avoid NPE if the given input is null + if (input == null) { + return null; + } + try { for (byte utf8Byte : input.getBytes("UTF-8")) { final char character = (char) utf8Byte;
