Skip to content

Commit

Permalink
NPE fix
Browse files Browse the repository at this point in the history
gradle plugin updated
  • Loading branch information
Oleg Smelov committed Feb 29, 2024
1 parent 74d139f commit 31eb15a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 29 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
id "org.owasp.dependencycheck" version "8.2.1"
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
id "org.owasp.dependencycheck" version "9.0.9"
id 'signing'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 Exactpro (Exactpro Systems Limited)
* Copyright 2021-2024 Exactpro (Exactpro Systems Limited)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -117,11 +117,14 @@ public AbstractMessageIteratorProvider(String requestInfo, MessageFilter filter,
}

//TODO refactor this method to assigns firstPage outside the method
protected FilterForGreater<Instant> createLeftBoundFilter(MessageFilter filter) throws CradleStorageException
{
protected FilterForGreater<Instant> createLeftBoundFilter(MessageFilter filter) throws CradleStorageException {
FilterForGreater<Instant> result = filter.getTimestampFrom();
firstPage = FilterUtils.findFirstPage(filter.getPageId(), result, book);
Instant leftBoundFromPage = firstPage.getStarted();

if (result == null && firstPage == null)
return null;

Instant leftBoundFromPage = firstPage == null ? Instant.MIN : firstPage.getStarted();
if (result == null || (filter.getPageId() != null && leftBoundFromPage.isAfter(result.getValue())))
return FilterForGreater.forGreaterOrEquals(leftBoundFromPage);

Expand All @@ -132,8 +135,7 @@ protected FilterForGreater<Instant> createLeftBoundFilter(MessageFilter filter)
filter.getDirection().getLabel(), leftBoundLocalDate.toLocalDate(),
leftBoundLocalDate.toLocalTime());

if (nearestBatchTime != null)
{
if (nearestBatchTime != null) {
Instant nearestBatchInstant = TimeUtils.toInstant(leftBoundLocalDate.toLocalDate(), nearestBatchTime);
if (nearestBatchInstant.isBefore(result.getValue()))
result = FilterForGreater.forGreaterOrEquals(nearestBatchInstant);
Expand Down Expand Up @@ -175,11 +177,10 @@ private LocalTime getNearestBatchTime(PageInfo page, String sessionAlias, String
}

//TODO refactor this method to assign last page outside of this method.
protected FilterForLess<Instant> createRightBoundFilter(MessageFilter filter)
{
protected FilterForLess<Instant> createRightBoundFilter(MessageFilter filter) {
FilterForLess<Instant> result = filter.getTimestampTo();
lastPage = FilterUtils.findLastPage(filter.getPageId(), result, book);
Instant endOfPage = lastPage.getEnded() == null ? Instant.now() : lastPage.getEnded();
Instant endOfPage = lastPage == null || lastPage.getEnded() == null ? Instant.now() : lastPage.getEnded();

return FilterForLess.forLessOrEquals(result == null || endOfPage.isBefore(result.getValue()) ? endOfPage : result.getValue());
}
Expand Down Expand Up @@ -240,22 +241,22 @@ protected CassandraStoredMessageFilter createNextFilter(CassandraStoredMessageFi
filter.getOrder());
}

protected boolean performNextIteratorChecks () {
protected boolean interruptIteratorChecks () {
if (cassandraFilter == null) {
return false;
return true;
}

if (takeWhileIterator != null && takeWhileIterator.isHalted()) {
logger.debug("Iterator was interrupted because iterator condition was not met");
return false;
return true;
}

if (limit > 0 && returned.get() >= limit) {
logger.debug("Filtering interrupted because limit for records to return ({}) is reached ({})", limit, returned);
return false;
return true;
}

return true;
return false;
}

protected Iterator<StoredMessageBatch> getBatchedIterator (MappedAsyncPagingIterable<MessageBatchEntity> resultSet) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 Exactpro (Exactpro Systems Limited)
* Copyright 2021-2024 Exactpro (Exactpro Systems Limited)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,15 +38,14 @@ public class MessageBatchesIteratorProvider extends AbstractMessageIteratorProvi

public MessageBatchesIteratorProvider(String requestInfo, MessageFilter filter, CassandraOperators operators, BookInfo book,
ExecutorService composingService, SelectQueryExecutor selectQueryExecutor,
Function<BoundStatementBuilder, BoundStatementBuilder> readAttrs) throws CradleStorageException
{
Function<BoundStatementBuilder, BoundStatementBuilder> readAttrs) throws CradleStorageException {
super(requestInfo, filter, operators, book, composingService, selectQueryExecutor, readAttrs);
}


@Override
public CompletableFuture<Iterator<StoredMessageBatch>> nextIterator() {
if (!performNextIteratorChecks()) {
if (interruptIteratorChecks()) {
return CompletableFuture.completedFuture(null);
}

Expand All @@ -55,4 +54,4 @@ public CompletableFuture<Iterator<StoredMessageBatch>> nextIterator() {
.thenApplyAsync(this::getBatchedIterator, composingService)
.thenApply(it -> limit > 0 ? new LimitedIterator<>(it, limit) : it);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 Exactpro (Exactpro Systems Limited)
* Copyright 2021-2024 Exactpro (Exactpro Systems Limited)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,15 +36,13 @@ public class MessagesIteratorProvider extends AbstractMessageIteratorProvider<St

public MessagesIteratorProvider(String requestInfo, MessageFilter filter, CassandraOperators operators, BookInfo book,
ExecutorService composingService, SelectQueryExecutor selectQueryExecutor,
Function<BoundStatementBuilder, BoundStatementBuilder> readAttrs) throws CradleStorageException
{
Function<BoundStatementBuilder, BoundStatementBuilder> readAttrs) throws CradleStorageException {
super(requestInfo, filter, operators, book, composingService, selectQueryExecutor, readAttrs);
}

@Override
public CompletableFuture<Iterator<StoredMessage>> nextIterator()
{
if (!performNextIteratorChecks()) {
public CompletableFuture<Iterator<StoredMessage>> nextIterator() {
if (interruptIteratorChecks()) {
return CompletableFuture.completedFuture(null);
}

Expand All @@ -53,4 +51,4 @@ public CompletableFuture<Iterator<StoredMessage>> nextIterator()
.thenApplyAsync(this::getBatchedIterator, composingService)
.thenApplyAsync(it -> new FilteredMessageIterator(it, filter, limit, returned), composingService);
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
release_version=5.1.4
release_version=5.1.5
description='Cradle API'
vcs_url=https://github.com/th2-net/cradleapi

0 comments on commit 31eb15a

Please sign in to comment.