NIFI-6996 This closes #3981. Fixed a stackoverflow that occurs when a subscription fails.

Signed-off-by: Joe Witt <joewitt@apache.org>
This commit is contained in:
Gal Shinder 2020-01-11 23:39:49 +02:00 committed by Joe Witt
parent b35ad7cd20
commit 4fec54debf
No known key found for this signature in database
GPG Key ID: 9093BF854F811A1A
1 changed files with 6 additions and 2 deletions

View File

@ -239,8 +239,12 @@ public class ConsumeWindowsEventLog extends AbstractSessionFactoryProcessor {
return null; return null;
} }
private boolean isSubscriptionHandleOpen(){
return subscriptionHandle != null && subscriptionHandle.getPointer() != null;
}
private boolean isSubscribed() { private boolean isSubscribed() {
final boolean subscribed = subscriptionHandle != null && subscriptionHandle.getPointer() != null; final boolean subscribed = isSubscriptionHandleOpen();
final boolean subscriptionFailed = evtSubscribeCallback != null final boolean subscriptionFailed = evtSubscribeCallback != null
&& ((EventSubscribeXmlRenderingCallback) evtSubscribeCallback).isSubscriptionFailed(); && ((EventSubscribeXmlRenderingCallback) evtSubscribeCallback).isSubscriptionFailed();
final boolean subscribing = subscribed && !subscriptionFailed; final boolean subscribing = subscribed && !subscriptionFailed;
@ -287,7 +291,7 @@ public class ConsumeWindowsEventLog extends AbstractSessionFactoryProcessor {
} }
private void unsubscribe() { private void unsubscribe() {
if (isSubscribed()) { if (isSubscriptionHandleOpen()) {
wEvtApi.EvtClose(subscriptionHandle); wEvtApi.EvtClose(subscriptionHandle);
} }
subscriptionHandle = null; subscriptionHandle = null;