I have a java code that was written by some guy before me. The code works fine in AIX but we had to recently move all scripts from AIX to RHEL 7.6. On RHEL the code seems to get stuck in an long loop and the scipts which takes around 5 minutes to completed takes hours just going through that loop.
The loop uses SmbFileInputStream and BufferedOutputStream. The logs do not show any error/exception.
Any help would be highly appreciated as the AIX servers would be de-commissioned in the next week and I need to make it work on RHEL.
public File getSMBFile(SmbFile infile, String username, String password, String localdir) throws Exception {
SmbFileInputStream smbIn = new SmbFileInputStream(infile);
//File temp = File.createTempFile(infile.getName(), null);
//temp.deleteOnExit();
File localFile = new File(localdir, infile.getName());
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(localFile));
byte[] b = new byte[8192];
int n = 0;
while ((n = smbIn.read(b)) > 0) {
log.info("In while" + localFile + " to " + b + " " + 0 + " " + n);
out.write(b, 0, n);
}
out.flush();
out.close();
smbIn.close();
out.close();
log.info("LocalFile " + localFile);
return localFile;
}
This loop is where the code goes into an infinite loop and keeps running for hours:
while ((n = smbIn.read(b)) > 0) {
log.info("In while" + localFile + " to " + b + " " + 0 + " " + n);
out.write(b, 0, n);
}
Log output: Dec 30, 2019 10:16:18 PM com.perceptionit.configuration.inventory.processing.FileCollector getSMBFile INFO: In while/opt/dataloading/data/statisticalbss/4G_Updated_Region-Sheet-15-11-2019.xlsx to [B@fc12260b 0 8192 Dec 30, 2019 10:17:18 PM com.perceptionit.configuration.inventory.processing.FileCollector getSMBFile INFO: In while/opt/dataloading/data/statisticalbss/4G_Updated_Region-Sheet-15-11-2019.xlsx to [B@fc12260b 0 8192 Dec 30, 2019 10:18:18 PM com.perceptionit.configuration.inventory.processing.FileCollector getSMBFile INFO: In while/opt/dataloading/data/statisticalbss/4G_Updated_Region-Sheet-15-11-2019.xlsx to [B@fc12260b 0 8192