You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by sp...@apache.org on 2017/04/21 20:24:19 UTC
hive git commit: HIVE-15761: ObjectStore.getNextNotification could
return an empty NotificationEventResponse causing TProtocolException (Sergio
Pena, reviewed by Aihua Xu)
Repository: hive
Updated Branches:
refs/heads/master 17fcac09a -> 13967d8f2
HIVE-15761: ObjectStore.getNextNotification could return an empty NotificationEventResponse causing TProtocolException (Sergio Pena, reviewed by Aihua Xu)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/13967d8f
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/13967d8f
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/13967d8f
Branch: refs/heads/master
Commit: 13967d8f284a4c7af8f2cc1f6c0256e507769357
Parents: 17fcac0
Author: Sergio Pena <se...@cloudera.com>
Authored: Fri Apr 21 15:23:52 2017 -0500
Committer: Sergio Pena <se...@cloudera.com>
Committed: Fri Apr 21 15:23:52 2017 -0500
----------------------------------------------------------------------
.../java/org/apache/hadoop/hive/metastore/ObjectStore.java | 7 ++++---
.../org/apache/hadoop/hive/metastore/TestObjectStore.java | 5 +++++
2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/13967d8f/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
----------------------------------------------------------------------
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java b/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
index 6b21751..8e79e4f 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
@@ -8263,6 +8263,9 @@ public class ObjectStore implements RawStore, Configurable {
public NotificationEventResponse getNextNotification(NotificationEventRequest rqst) {
boolean commited = false;
Query query = null;
+
+ NotificationEventResponse result = new NotificationEventResponse();
+ result.setEvents(new ArrayList<NotificationEvent>());
try {
openTransaction();
long lastEvent = rqst.getLastEvent();
@@ -8272,11 +8275,9 @@ public class ObjectStore implements RawStore, Configurable {
Collection<MNotificationLog> events = (Collection) query.execute(lastEvent);
commited = commitTransaction();
if (events == null) {
- return null;
+ return result;
}
Iterator<MNotificationLog> i = events.iterator();
- NotificationEventResponse result = new NotificationEventResponse();
- result.setEvents(new ArrayList<NotificationEvent>());
int maxEvents = rqst.getMaxEvents() > 0 ? rqst.getMaxEvents() : Integer.MAX_VALUE;
int numEvents = 0;
while (i.hasNext() && numEvents++ < maxEvents) {
http://git-wip-us.apache.org/repos/asf/hive/blob/13967d8f/metastore/src/test/org/apache/hadoop/hive/metastore/TestObjectStore.java
----------------------------------------------------------------------
diff --git a/metastore/src/test/org/apache/hadoop/hive/metastore/TestObjectStore.java b/metastore/src/test/org/apache/hadoop/hive/metastore/TestObjectStore.java
index 9b8eaf2..6524ee7 100644
--- a/metastore/src/test/org/apache/hadoop/hive/metastore/TestObjectStore.java
+++ b/metastore/src/test/org/apache/hadoop/hive/metastore/TestObjectStore.java
@@ -153,11 +153,16 @@ public class TestObjectStore {
Assert.assertEquals(2, eventResponse.getEventsSize());
Assert.assertEquals(FIRST_EVENT_ID, eventResponse.getEvents().get(0).getEventId());
Assert.assertEquals(SECOND_EVENT_ID, eventResponse.getEvents().get(1).getEventId());
+
// Verify that getNextNotification(last) returns events after a specified event
eventResponse = objectStore.getNextNotification(new NotificationEventRequest(FIRST_EVENT_ID));
Assert.assertEquals(1, eventResponse.getEventsSize());
Assert.assertEquals(SECOND_EVENT_ID, eventResponse.getEvents().get(0).getEventId());
+ // Verify that getNextNotification(last) returns zero events if there are no more notifications available
+ eventResponse = objectStore.getNextNotification(new NotificationEventRequest(SECOND_EVENT_ID));
+ Assert.assertEquals(0, eventResponse.getEventsSize());
+
// Verify that cleanNotificationEvents() cleans up all old notifications
Thread.sleep(1);
objectStore.cleanNotificationEvents(1);