Skip to content

Commit f4af7d2

Browse files
author
Burak Serdar
committed
Fix coverity errors
1 parent 9187bd3 commit f4af7d2

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

crud/src/main/java/com/redhat/lightblue/assoc/ep/JoinSearch.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,12 @@ private void retrieveNextBatch() {
145145
findRequest.setFrom(from);
146146
findRequest.setTo(to);
147147
OperationContext opctx = search(ctx, findRequest);
148-
currentIterator=opctx.getDocumentStream();
149-
if(!currentIterator.hasNext()) {
150-
currentIterator.close();
151-
currentIterator=null;
148+
if(opctx!=null) {
149+
currentIterator=opctx.getDocumentStream();
150+
if(!currentIterator.hasNext()) {
151+
currentIterator.close();
152+
currentIterator=null;
153+
}
152154
}
153155
} else {
154156
done=true;

crud/src/main/java/com/redhat/lightblue/hooks/HookManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ public boolean hasHooks(CRUDOperationContext ctx,CRUDOperation op) {
183183
List<Hook> mdHooks = md.getHooks().getHooks();
184184
for (Hook h : mdHooks) {
185185
switch (op) {
186-
case INSERT: if(h.isInsert()) return true;
187-
case UPDATE: if(h.isUpdate()) return true;
188-
case DELETE: if(h.isDelete()) return true;
189-
case FIND: if(h.isFind()) return true;
186+
case INSERT: if(h.isInsert()) return true;break;
187+
case UPDATE: if(h.isUpdate()) return true;break;
188+
case DELETE: if(h.isDelete()) return true;break;
189+
case FIND: if(h.isFind()) return true;break;
190190
}
191191
}
192192
return false;

crud/src/main/java/com/redhat/lightblue/mediator/Mediator.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -721,19 +721,21 @@ private void runBulkConstraintValidation(OperationContext ctx) {
721721
EntityMetadata md = ctx.getTopLevelEntityMetadata();
722722
ConstraintValidator constraintValidator = factory.getConstraintValidator(md);
723723
List<DocCtx> docs = ctx.getInputDocumentsWithoutErrors();
724-
constraintValidator.validateDocs(docs);
725-
Map<JsonDoc, List<Error>> docErrors = constraintValidator.getDocErrors();
726-
for (Map.Entry<JsonDoc, List<Error>> entry : docErrors.entrySet()) {
727-
JsonDoc doc = entry.getKey();
728-
List<Error> errors = entry.getValue();
724+
if(docs!=null) {
725+
constraintValidator.validateDocs(docs);
726+
Map<JsonDoc, List<Error>> docErrors = constraintValidator.getDocErrors();
727+
for (Map.Entry<JsonDoc, List<Error>> entry : docErrors.entrySet()) {
728+
JsonDoc doc = entry.getKey();
729+
List<Error> errors = entry.getValue();
730+
if (errors != null && !errors.isEmpty()) {
731+
((DocCtx) doc).addErrors(errors);
732+
}
733+
}
734+
List<Error> errors = constraintValidator.getErrors();
729735
if (errors != null && !errors.isEmpty()) {
730-
((DocCtx) doc).addErrors(errors);
736+
ctx.addErrors(errors);
731737
}
732738
}
733-
List<Error> errors = constraintValidator.getErrors();
734-
if (errors != null && !errors.isEmpty()) {
735-
ctx.addErrors(errors);
736-
}
737739
LOGGER.debug("Constraint validation complete");
738740
ctx.measure.end("runBulkConstraintValidation");
739741
}

0 commit comments

Comments
 (0)