Github user JPercivall commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/525#discussion_r67439340
  
    --- Diff: 
nifi-nar-bundles/nifi-windows-event-log-bundle/nifi-windows-event-log-processors/src/main/java/org/apache/nifi/processors/windows/event/log/jna/EventSubscribeXmlRenderingCallback.java
 ---
    @@ -0,0 +1,100 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.nifi.processors.windows.event.log.jna;
    +
    +import com.google.common.annotations.VisibleForTesting;
    +import com.sun.jna.Memory;
    +import com.sun.jna.platform.win32.Kernel32;
    +import com.sun.jna.platform.win32.W32Errors;
    +import com.sun.jna.platform.win32.WinDef;
    +import com.sun.jna.platform.win32.WinNT;
    +import org.apache.commons.io.Charsets;
    +import org.apache.nifi.logging.ComponentLog;
    +
    +import java.util.function.Consumer;
    +
    +/**
    + * Callback that will render the XML representation of the event using 
native Windows API
    + */
    +public class EventSubscribeXmlRenderingCallback implements 
WEvtApi.EVT_SUBSCRIBE_CALLBACK {
    +    public static final String RECEIVED_THE_FOLLOWING_WIN32_ERROR = 
"Received the following Win32 error: ";
    +    public static final int INITIAL_BUFFER_SIZE = 1024;
    +
    +    private final ComponentLog logger;
    +    private final Consumer<String> consumer;
    +    private final int maxBufferSize;
    +    private final WEvtApi wEvtApi;
    +    private final Kernel32 kernel32;
    +
    +    private int size;
    +    private Memory buffer;
    +    private Memory used;
    +    private Memory propertyCount;
    +
    +    public EventSubscribeXmlRenderingCallback(ComponentLog logger, 
Consumer<String> consumer, int maxBufferSize, WEvtApi wEvtApi, Kernel32 
kernel32) {
    +        this.logger = logger;
    +        this.consumer = consumer;
    +        this.maxBufferSize = maxBufferSize;
    +        this.wEvtApi = wEvtApi;
    +        this.kernel32 = kernel32;
    +        this.size = Math.min(maxBufferSize, INITIAL_BUFFER_SIZE);
    +        this.buffer = new Memory(size);
    +        this.used = new Memory(4);
    +        this.propertyCount = new Memory(4);
    +    }
    +
    +    @Override
    +    public synchronized int onEvent(int evtSubscribeNotifyAction, 
WinDef.PVOID userContext, WinNT.HANDLE eventHandle) {
    --- End diff --
    
    This method has a return type of int but only ever returns 0, what is the 
purpose of that?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to