mattyb149 commented on code in PR #8495: URL: https://github.com/apache/nifi/pull/8495#discussion_r1534228284
########## nifi-nar-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/PutHDFS.java: ########## @@ -372,54 +370,56 @@ public Object run() { // Write FlowFile to temp file on HDFS final StopWatch stopWatch = new StopWatch(true); - session.read(putFlowFile, new InputStreamCallback() { - - @Override - public void process(InputStream in) throws IOException { - OutputStream fos = null; - Path createdFile = null; - try { - if (conflictResponse.equals(APPEND_RESOLUTION) && destinationExists) { - fos = hdfs.append(copyFile, bufferSize); - } else { - final EnumSet<CreateFlag> cflags = EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE); - - if (shouldIgnoreLocality(context, session)) { - cflags.add(CreateFlag.IGNORE_CLIENT_LOCALITY); - } + session.read(putFlowFile, in -> { + OutputStream fos = null; + Path createdFile = null; + try { + if (conflictResponse.equals(APPEND_RESOLUTION) && destinationExists) { + fos = hdfs.append(copyFile, bufferSize); + } else { + final EnumSet<CreateFlag> cflags = EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE); - fos = hdfs.create(actualCopyFile, FsCreateModes.applyUMask(FsPermission.getFileDefault(), - FsPermission.getUMask(hdfs.getConf())), cflags, bufferSize, replication, blockSize, - null, null); + if (shouldIgnoreLocality(context, session)) { + cflags.add(CreateFlag.IGNORE_CLIENT_LOCALITY); } - if (codec != null) { - fos = codec.createOutputStream(fos); + fos = hdfs.create(actualCopyFile, FsCreateModes.applyUMask(FsPermission.getFileDefault(), + FsPermission.getUMask(hdfs.getConf())), cflags, bufferSize, replication, blockSize, + null, null); + } + + if (codec != null) { + fos = codec.createOutputStream(fos); + } + createdFile = actualCopyFile; + BufferedInputStream bis = new BufferedInputStream(in); + StreamUtils.copy(bis, fos); + bis = null; + fos.flush(); + } catch (IOException e) { + // Catch GSSExceptions and reset the resources + Optional<GSSException> causeOptional = findCause(e, GSSException.class, gsse -> GSSException.NO_CRED == gsse.getMajor()); + if (causeOptional.isPresent()) { + getLogger().warn("Error authenticating when performing file operation, resetting HDFS resources: {} ", e.getCause().getMessage()); + hdfsResources.set(resetHDFSResources(getConfigLocations(context), context)); + } Review Comment: This suggested change removes the error logging and the reset, is that intentional? -- 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: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org