Skip to content

Test - #1

Open
adarbari wants to merge 188 commits into
2020_01_06from
master
Open

Test#1
adarbari wants to merge 188 commits into
2020_01_06from
master

Conversation

@adarbari

Copy link
Copy Markdown
Owner

Test

Akshay Shirahatti and others added 30 commits December 16, 2019 09:09
}
}
public static <T> void writeAsLines(File outFile, Collection<T> c) throws IOException {
writeAsLines(new FileOutputStream(outFile), c, true);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code contains a resource that might not be closed properly. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the resource created by the following constructor call: FileOutputStream. The resource is referenced in statements at the following line: 11. The resource closure statement is at line: 22. There are other execution paths that do not contain closure statements, for example, when an else-branch is taken at line 21. Either a) close the object returned by FileOutputStream() in a try-finally block or b) close the resource by declaring the object returned by FileOutputStream() in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

BufferedReader reader;

envMap = new HashMap<String, String>();
reader = new BufferedReader(new InputStreamReader(new FileInputStream(envFile)));

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code contains a resource that might not be closed properly. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the following resource: reader. The resource is referenced in statements at the following lines: 119, 121. The resource closure statement is at line: 134. There are other execution paths that do not contain closure statements, for example, when BufferedReader.readLine throws an exception. Either a) close reader in a try-finally block or b) close the resource by declaring reader in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

displayMissing = true;
displayMissingSW.reset();
}
} catch (InterruptedException ie) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: InterruptedException is ignored. This can delay thread shutdown and clear the thread’s interrupt status. Only code that implements a thread’s interruption policy can swallow an interruption request.

Fix: Rethrow the InterruptedException or reinterrupt the current thread using Thread.currentThread().interrupt() so that higher-level interrupt handlers can function correctly.
If you are wrapping the InterruptedException inside a RuntimeException, call Thread.currentThread().interrupt() before throwing the RuntimeException.

Learn more about interrupts and dealing with InterruptedException

} finally {
convergencePauseMutex.unlock();
convergencePauseCV.await();
} catch (InterruptedException ie) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: InterruptedException is ignored. This can delay thread shutdown and clear the thread’s interrupt status. Only code that implements a thread’s interruption policy can swallow an interruption request.

Fix: Rethrow the InterruptedException or reinterrupt the current thread using Thread.currentThread().interrupt() so that higher-level interrupt handlers can function correctly.
If you are wrapping the InterruptedException inside a RuntimeException, call Thread.currentThread().interrupt() before throwing the RuntimeException.

Learn more about interrupts and dealing with InterruptedException

// existence beforehand.
file.getParentFile().mkdirs();
file.createNewFile();
FileWriter writer = new FileWriter(file);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code contains a resource that might not be closed properly. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the following resource: writer. The resource is referenced in statements at the following line: 108. The resource closure statement is at line: 109. There are other execution paths that do not contain closure statements, for example, when Writer.write throws an exception. Either a) close writer in a try-finally block or b) close the resource by declaring writer in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).


_statsFile = statsFile(c);
_statsFile.getParentFile().mkdirs();
statsFile = new RandomAccessFile(_statsFile, "rw");

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code contains a resource that might not be closed properly. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the following resource: statsFile. The resource is referenced in statements at the following lines: 25, 26. The resource closure statement is at line: 27. There are other execution paths that do not contain closure statements, for example, when RandomAccessFile.length throws an exception. Either a) close statsFile in a try-finally block or b) close the resource by declaring statsFile in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

}

public static ExclusionSet parse(File file) throws IOException {
return new ExclusionSet(ServerSet.parse(new FileInputStream(file), VersionedDefinition.NO_VERSION));

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code might contain a resource leak. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the resource created by the following constructor call: FileInputStream. Currently, there are execution paths that do not contain closure statements, for example, when ServerSet.parse throws an exception. Either a) close the object returned by FileInputStream() in a try-finally block or b) close the resource by declaring the object returned by FileInputStream() in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

}
} else {
return javaTypeMapping.getExternalType();
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Similar code fragments were detected in the same file at the following lines: 434:443, 455:464.
Refactoring can help improve code maintainability. Consider reducing duplicate code by extracting it into a separate method. You can then replace duplicated code with calls to this new method.

} else {
return complete;
}
} catch (InterruptedException ie) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: InterruptedException is ignored. This can delay thread shutdown and clear the thread’s interrupt status. Only code that implements a thread’s interruption policy can swallow an interruption request.

Fix: Rethrow the InterruptedException or reinterrupt the current thread using Thread.currentThread().interrupt() so that higher-level interrupt handlers can function correctly.
If you are wrapping the InterruptedException inside a RuntimeException, call Thread.currentThread().interrupt() before throwing the RuntimeException.

Learn more about interrupts and dealing with InterruptedException

}
}
return ImmutableSet.copyOf(def.split(pattern));

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem:
This line of code lacks validation when processing input data through the following parameter: 'pattern' (index: 1 | type: String). The parameter is exposed to external callers, because its enclosing class and method are publicly accessible. This means that upstream validation, if it exists, can be bypassed. Other validated parameters: 'def'. Malicious, malformed, or unbounded inputs can cause unexpected runtime behavior or crashes, and can slow performance.

Fix:
Add checks to ensure the validity of the parameter's value, such as testing it for nullness (for example, using the @nonnull annotation as described in the Lombok library), emptiness, or equality. Or to prevent direct calls to it, reduce the method's visibility.

Learn more about potential threats and guidance from the Common Weakness Enumeration website and the OWASP Cheat Sheet series.

}

public static long streamToFile(InputStream in, File outFile, boolean close) throws IOException {
return stream(in, new FileOutputStream(outFile), close);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code contains a resource that might not be closed properly. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the resource created by the following constructor call: FileOutputStream. The resource is referenced in statements at the following line: 246. The resource closure statement is at line: 236. There are other execution paths that do not contain closure statements, for example, when an else-branch is taken at line 234. Either a) close the object returned by FileOutputStream() in a try-finally block or b) close the resource by declaring the object returned by FileOutputStream() in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

b2 = readByte(in);
b1 = readByte(in);
b0 = readByte(in);
return NumConversion.bytesToInt(b0, b1, b2, b3);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Similar code fragments were detected in the same file at the following lines: 48:52, 61:65.
Refactoring can help improve code maintainability. Consider reducing duplicate code by extracting it into a separate method. You can then replace duplicated code with calls to this new method.

// FUTURE - let this replica know that it's bad
Log.warning("Storing paused checksum tree ", uuid);
pausedChecksumTrees.put(new PausedChecksumTree(uuid, remoteTree, cp, connection));
} catch (InterruptedException e) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: InterruptedException is ignored. This can delay thread shutdown and clear the thread’s interrupt status. Only code that implements a thread’s interruption policy can swallow an interruption request.

Fix: Rethrow the InterruptedException or reinterrupt the current thread using Thread.currentThread().interrupt() so that higher-level interrupt handlers can function correctly.
If you are wrapping the InterruptedException inside a RuntimeException, call Thread.currentThread().interrupt() before throwing the RuntimeException.

Learn more about interrupts and dealing with InterruptedException

}

public static List<String> parseGZFileLines(File file, TrimMode trimMode) throws IOException {
return parseLines(new GZIPInputStream(new FileInputStream(file)), trimMode);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code might contain a resource leak. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the resource created by the following constructor call: FileInputStream. Currently, there are execution paths that do not contain closure statements, for example, when StreamParser.parseLines (in method parseLines) throws an exception. Either a) close the object returned by FileInputStream() in a try-finally block or b) close the resource by declaring the object returned by FileInputStream() in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

stat = new Stat();
getData(path, false, stat);
return stat;
} catch (InterruptedException ie) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: InterruptedException is ignored. This can delay thread shutdown and clear the thread’s interrupt status. Only code that implements a thread’s interruption policy can swallow an interruption request.

Fix: Rethrow the InterruptedException or reinterrupt the current thread using Thread.currentThread().interrupt() so that higher-level interrupt handlers can function correctly.
If you are wrapping the InterruptedException inside a RuntimeException, call Thread.currentThread().interrupt() before throwing the RuntimeException.

Learn more about interrupts and dealing with InterruptedException

int retriesCount = 0;
List<String> ips = getIps(instances);
while (!ips.isEmpty()) {
DescribeInstancesResult response = ec2.describeInstances(diRequest);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

This code appears to be waiting for a resource before it runs. You could use the waiters feature to help improve efficiency. Consider using InstanceExists, InstanceRunning, InstanceStopped or InstanceTerminated. For more information, see https://aws.amazon.com/blogs/developer/waiters-in-the-aws-sdk-for-java/

}
try {
bufferLengthsBuffer = ByteBuffer.allocate(numBuffers * NumConversion.BYTES_PER_INT);
} catch (OutOfMemoryError oome) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: While wrapping the caught exception into a custom one, information about the caught exception is being lost, including information about the stack trace of the exception.

Fix: If the caught exception object does not contain sensitive information, consider passing it as the "rootCause" or inner exception parameter to the constructor of the new exception before throwing the new exception. (Note that not all exception constructors support inner exceptions. Use a wrapper exception that supports inner exceptions.)
Learn more

if (levelMet(Level.SEVERE)) {
try {
logQueue.put(new LogEntry(Level.SEVERE, o, m));
} catch (InterruptedException ie) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: InterruptedException is ignored. This can delay thread shutdown and clear the thread’s interrupt status. Only code that implements a thread’s interruption policy can swallow an interruption request.

Fix: Rethrow the InterruptedException or reinterrupt the current thread using Thread.currentThread().interrupt() so that higher-level interrupt handlers can function correctly.
If you are wrapping the InterruptedException inside a RuntimeException, call Thread.currentThread().interrupt() before throwing the RuntimeException.

Learn more about interrupts and dealing with InterruptedException

try {
Map<String, String> m;

m = MapUtil.parseStringMap(new FileInputStream(args[0]), '\t', MapUtil.NoDelimiterAction.Warn);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code might contain a resource leak. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the resource created by the following constructor call: FileInputStream. Currently, there are execution paths that do not contain closure statements. Either a) close the object returned by FileInputStream() in a try-finally block or b) close the resource by declaring the object returned by FileInputStream() in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

} else {
cv.awaitNanos(spinDurationNanos);
}
} catch (InterruptedException ie) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: InterruptedException is ignored. This can delay thread shutdown and clear the thread’s interrupt status. Only code that implements a thread’s interruption policy can swallow an interruption request.

Fix: Rethrow the InterruptedException or reinterrupt the current thread using Thread.currentThread().interrupt() so that higher-level interrupt handlers can function correctly.
If you are wrapping the InterruptedException inside a RuntimeException, call Thread.currentThread().interrupt() before throwing the RuntimeException.

Learn more about interrupts and dealing with InterruptedException

private static void fineAsyncInternal(LogEntry le) {
try {
logQueue.put(le);
} catch (InterruptedException ie) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: InterruptedException is ignored. This can delay thread shutdown and clear the thread’s interrupt status. Only code that implements a thread’s interruption policy can swallow an interruption request.

Fix: Rethrow the InterruptedException or reinterrupt the current thread using Thread.currentThread().interrupt() so that higher-level interrupt handlers can function correctly.
If you are wrapping the InterruptedException inside a RuntimeException, call Thread.currentThread().interrupt() before throwing the RuntimeException.

Learn more about interrupts and dealing with InterruptedException

long numWritten;

numWritten = 0;
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Similar code fragments were detected in the same file at the following lines: 191:197, 198:204, 227:233, 234:240.
Refactoring can help improve code maintainability. Consider reducing duplicate code by extracting it into a separate method. You can then replace duplicated code with calls to this new method.

while (running) {
try {
this.wait();
} catch (InterruptedException ie) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: InterruptedException is ignored. This can delay thread shutdown and clear the thread’s interrupt status. Only code that implements a thread’s interruption policy can swallow an interruption request.

Fix: Rethrow the InterruptedException or reinterrupt the current thread using Thread.currentThread().interrupt() so that higher-level interrupt handlers can function correctly.
If you are wrapping the InterruptedException inside a RuntimeException, call Thread.currentThread().interrupt() before throwing the RuntimeException.

Learn more about interrupts and dealing with InterruptedException

ByteBuffer opts = getOptionBuffer(mg);
opts.position(auStartPos+NumConversion.BYTES_PER_INT);
opts.get(au, 0, auLength);
return au;
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Similar code fragments were detected in the same file at the following lines: 199:207, 183:191.
Refactoring can help improve code maintainability. Consider reducing duplicate code by extracting it into a separate method. You can then replace duplicated code with calls to this new method.


groupSize = readOps.takeMultiple(groupOps);
read(groupOps, groupSize);
} catch (InterruptedException ie) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: InterruptedException is ignored. This can delay thread shutdown and clear the thread’s interrupt status. Only code that implements a thread’s interruption policy can swallow an interruption request.

Fix: Rethrow the InterruptedException or reinterrupt the current thread using Thread.currentThread().interrupt() so that higher-level interrupt handlers can function correctly.
If you are wrapping the InterruptedException inside a RuntimeException, call Thread.currentThread().interrupt() before throwing the RuntimeException.

Learn more about interrupts and dealing with InterruptedException

while (!result.isComplete() && !timer.hasExpired()) {
try {
timer.await(cv);
} catch (InterruptedException e) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: InterruptedException is ignored. This can delay thread shutdown and clear the thread’s interrupt status. Only code that implements a thread’s interruption policy can swallow an interruption request.

Fix: Rethrow the InterruptedException or reinterrupt the current thread using Thread.currentThread().interrupt() so that higher-level interrupt handlers can function correctly.
If you are wrapping the InterruptedException inside a RuntimeException, call Thread.currentThread().interrupt() before throwing the RuntimeException.

Learn more about interrupts and dealing with InterruptedException

accessMode = AccessMode.ReadOnly;
// Presently, the index does not contain sufficient information to allow this in SINGLE_VERSION mode
}
raFile = new RandomAccessFile(fileForSegment(nsDir, segmentNumber), fileOpenMode);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code might contain a resource leak. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the following resource: raFile. Currently, there are execution paths that do not contain closure statements, for example, when FileChannel.map throws an exception. Either a) close raFile in a try-finally block or b) close the resource by declaring raFile in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

}
} catch (NoSuchFieldException nsfe) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: While wrapping the caught exception into a custom one, information about the caught exception is being lost, including information about the stack trace of the exception.

Fix: If the caught exception object does not contain sensitive information, consider passing it as the "rootCause" or inner exception parameter to the constructor of the new exception before throwing the new exception. (Note that not all exception constructors support inner exceptions. Use a wrapper exception that supports inner exceptions.)
Learn more

try {
channel = SocketChannel.open();
LWTThreadUtil.setBlocked();
channel.socket().connect(dest, defSocketConnectTimeout);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code contains a resource that might not be closed properly. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the resource returned by the following method call: socket. The resource is referenced in statements at the following lines: 319, 325, 326, 333, 335, 339. The resource closure statement is at line: 337. There are other execution paths that do not contain closure statements, for example, when Socket.connect throws an exception, and an else-branch is taken at line 335. Either a) close the object returned by socket() in a try-finally block or b) close the resource by declaring the object returned by socket() in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

}

public static Histogram parse(String fileName, int numBins, double logBase) throws IOException {
return parse(new FileInputStream(fileName), numBins, logBase);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem
This line of code might contain a resource leak. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the resource created by the following constructor call: FileInputStream. Currently, there are execution paths that do not contain closure statements, for example, when Histogram.parse throws an exception. Either a) close the object returned by FileInputStream() in a try-finally block or b) close the resource by declaring the object returned by FileInputStream() in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants