vyommani commented on code in PR #536:
URL: https://github.com/apache/ranger/pull/536#discussion_r1966451600


##########
agents-audit/src/main/java/org/apache/ranger/audit/utils/RangerJSONAuditWriter.java:
##########
@@ -94,17 +95,23 @@ public synchronized boolean logJSON(final 
Collection<String> events) throws Exce
             logger.debug("UGI = {}, will write to HDFS file = {}", 
MiscUtil.getUGILoginUser(), currentFileName);
 
             out = 
MiscUtil.executePrivilegedAction((PrivilegedExceptionAction<PrintWriter>) () -> 
{
-                PrintWriter out1 = getLogFileStream();
+                PrintWriter out1 = null;
 
-                for (String event : events) {
-                    out1.println(event);
+                if (CollectionUtils.isEmpty(events)) {
+                    closeFileIfNeeded();
+                } else {
+                    out1 = getLogFileStream();

Review Comment:
   you can reduce the scope of out1 to else block .



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@ranger.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to