Skip to content

Commit

Permalink
Miscellanous fix (#1371)
Browse files Browse the repository at this point in the history
* Debug

* Update DefaultAsyncQueryDAO.java

* Update DefaultAsyncQueryDAO.java

* Throw exception instead

* Update AsyncQueryInterruptThread.java

* Update pom.xml

* Unit test case update

* Update DefaultAsyncQueryDAO.java
  • Loading branch information
moizarafat authored and Aaron Klish committed Aug 7, 2020
1 parent a1348e6 commit fa22727
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ public void run() {
protected void interruptQuery() {
try {
long interruptTimeMillies = calculateTimeOut(maxRunTimeMinutes, submittedOn);

log.debug("Waiting on the future with the given timeout for {}", interruptTimeMillies);
if (interruptTimeMillies > 0) {
log.debug("Waiting on the future with the given timeout for {}", interruptTimeMillies);
task.get(interruptTimeMillies, TimeUnit.MILLISECONDS);
}
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ protected Object executeInTransaction(DataStore dataStore, Transactional action)
tx.commit(scope);
} catch (IOException e) {
log.error("IOException: {}", e);
} catch (Exception e) {
log.error("Exception: {}", e);
throw new IllegalStateException(e);
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,18 @@ public void testProcessQueryException() {
verify(asyncQueryDao, times(1)).updateStatus(queryObj, QueryStatus.PROCESSING);
verify(asyncQueryDao, times(1)).updateStatus(queryObj, QueryStatus.FAILURE);
}

@Test
public void testAsyncQueryResultNullException() {
String query = "/group?sort=commonName&fields%5Bgroup%5D=commonName,description";

when(queryObj.getQuery()).thenReturn(query);
when(queryObj.getQueryType()).thenReturn(QueryType.JSONAPI_V1_0);
when(asyncQueryDao.createAsyncQueryResult(any(), any(), any(), any())).thenThrow(RuntimeException.class);

queryThread.processQuery();

verify(asyncQueryDao, times(1)).updateStatus(queryObj, QueryStatus.PROCESSING);
verify(asyncQueryDao, times(1)).updateStatus(queryObj, QueryStatus.FAILURE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.hibernate.cfg.AvailableSettings;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties.Naming;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
Expand Down Expand Up @@ -60,6 +61,7 @@ public class ElideDynamicConfiguration {
* @return LocalContainerEntityManagerFactoryBean bean
*/
@Bean
@ConditionalOnMissingBean
public LocalContainerEntityManagerFactoryBean entityManagerFactory (
DataSource source,
JpaProperties jpaProperties,
Expand Down

0 comments on commit fa22727

Please sign in to comment.