[OLINGO-1191] Code Improvements

This commit is contained in:
Archana Rai 2018-09-26 11:45:22 +05:30
parent 003f0f4ffa
commit 6bdaed4875
6 changed files with 25 additions and 18 deletions

View File

@ -80,7 +80,8 @@ public final class ODataErrorResponseChecker {
statusLine.getReasonPhrase());
}
if (statusLine.getStatusCode() >= 500 && (error.getDetails() == null || error.getDetails().isEmpty()) &&
if (statusLine.getStatusCode() >= 500 && error!= null &&
(error.getDetails() == null || error.getDetails().isEmpty()) &&
(error.getInnerError() == null || error.getInnerError().size() == 0)) {
result = new ODataServerErrorException(statusLine);
} else {

View File

@ -137,7 +137,7 @@ public class ODataBatchUtilities {
notEndLine = isNotEndLine(controller, currentLine);
if (notEndLine && os != null) {
if (notEndLine && os != null && currentLine!=null) {
os.write(currentLine.getBytes(Constants.UTF8));
os.write(ODataStreamer.CRLF);
}
@ -256,11 +256,14 @@ public class ODataBatchUtilities {
public static Map.Entry<Integer, String> readResponseLine(final ODataBatchLineIterator iterator) {
final String line = readBatchPart(new ODataBatchController(iterator, null), 1);
LOG.debug("Response line '{}'", line);
if(line !=null){
final Matcher matcher = RESPONSE_PATTERN.matcher(line.trim());
final Matcher matcher = RESPONSE_PATTERN.matcher(line.trim());
if (matcher.matches()) {
return new AbstractMap.SimpleEntry<Integer, String>(Integer.valueOf(matcher.group(1)), matcher.group(2));
if (matcher.matches()) {
return new AbstractMap.SimpleEntry<Integer, String>(Integer.valueOf(matcher.group(1)), matcher.group(2));
}
}
throw new IllegalArgumentException("Invalid response line '" + line + "'");

View File

@ -19,10 +19,8 @@
package org.apache.olingo.client.core.metadatavalidator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import org.apache.olingo.client.api.edm.xml.XMLMetadata;

View File

@ -35,10 +35,12 @@ public class FilterFunction implements FilterArg {
@Override
public String build() {
final String[] strParams = params == null || params.length == 0 ? new String[0] : new String[params.length];
for (int i = 0; i < strParams.length; i++) {
strParams[i] = params[i].build();
if(params !=null){
for (int i = 0; i < strParams.length; i++) {
strParams[i] = params[i].build();
}
}
return new StringBuilder(function).
append('(').
append(strParams.length == 0 ? StringUtils.EMPTY : StringUtils.join(strParams, ',')).

View File

@ -63,8 +63,10 @@ public class DebugTabStacktrace implements DebugTab {
gen.writeFieldName("stacktrace");
gen.writeStartArray();
for (final StackTraceElement stackTraceElement : exception.getStackTrace()) {
appendJsonStackTraceElement(gen, stackTraceElement);
if(exception != null){
for (final StackTraceElement stackTraceElement : exception.getStackTrace()) {
appendJsonStackTraceElement(gen, stackTraceElement);
}
}
gen.writeEndArray();

View File

@ -71,12 +71,13 @@ public class ServiceDocumentJsonSerializer {
}
gen.writeArrayFieldStart(Constants.VALUE);
final EdmEntityContainer container = metadata.getEdm().getEntityContainer();
if (container != null) {
writeEntitySets(gen, container);
writeFunctionImports(gen, container);
writeSingletons(gen, container);
if(metadata != null){
final EdmEntityContainer container = metadata.getEdm().getEntityContainer();
if (container != null) {
writeEntitySets(gen, container);
writeFunctionImports(gen, container);
writeSingletons(gen, container);
}
}
}