-
Notifications
You must be signed in to change notification settings - Fork 2
Address all JDBC ratification comments with small fixes #1 #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address all JDBC ratification comments with small fixes #1 #14
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this annotation? What was the error that FindBugs reported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EI: May expose internal representation by returning reference to mutable object (EI_EXPOSE_REP)
Returning a reference to a mutable object value stored in one of the object's fields exposes the internal representation of the object. If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Returning a new copy of the object is better approach in many situations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EI2: May expose internal representation by incorporating reference to mutable object (EI_EXPOSE_REP2)
This code stores a reference to an externally mutable object into the internal representation of the object. If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to return a mutable reference to the properties though?
Should we instead of exposing the Properties object itself, add getProperty() function? Should we return an immutable view over the Properties?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to make it work with copies of Properties, and with ChildAllocators for some BufferAllocators. But the rest still apply (for vectors).
.../org/apache/arrow/driver/jdbc/accessor/impl/numeric/ArrowFlightJdbcFloat4VectorAccessor.java
Outdated
Show resolved
Hide resolved
2d734ea to
c39619c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure this dependency doesn't show up elsewhere? If it does, let's put it in dependency management.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't used. All dependencies were added here are only for flight-jdbc-driver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must be used elsewhere in the project. Let's make sure we use dependencyManagement appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm overriding the version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary? Should we update the version generally instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It added ErrorCollector.checkThrows and assertThrows: https://github.com/junit-team/junit4/blob/HEAD/doc/ReleaseNotes4.13.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we can express the test using the older JUnit API? I'm not sure if it's a good idea to have different components use different versions of JUnit. We should either universally update the JUnit version or universally use the older versions.
Do we have inconsistent versions of JUnit elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. JUnit 4 is only defined in java/pom.xml to keep running older tests; which also makes me think about maybe starting using JUnit 5 in the future? Not sure about what the implications where when the project started.
I made a simple assertThrows based on JUnit's, which made building with 4.12 possible again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a more appropriate package for this annotation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All SpotBugs/FindBugs annotations are from this package: https://spotbugs.readthedocs.io/en/latest/annotations.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We solved by using an XML filter instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getResourceAsStream returns null if the path isn't found. Suggest we throw something more helpful if we get that (this will probably be an NPE)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In these two error messages, can we also mention the expected format for the URI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
4c93d34 to
8118dee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets remove all @SupressFBWarnings annotations and declare suppresions on a separate .xml file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
672c28f to
f7e2857
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this happen automatically because it's a ClassRule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Removed it.
13d4e76 to
2d00d23
Compare
2d00d23 to
b4afb45
Compare
* Address all ratification comments with small fixes * Small fixes * Revert small changes * Add more exception messages * Remove ExceptionTemplateThrower * Change UnsupportedOperationException to SQLException * Address all ratification comments with small fixes * Fix failing tests * Address to James' review * Removed some suppressions by creating newChildAllocators * Fix CONNECTION_STRING_EXPECTED * nit on CONNECTION_STRING_EXPECTED * Address more review comments * nit on holder comment * Remove FindBugs annotations * Fix rebase issues * Downgraded JUnit version back to what is defined in java/pom.xml * Remove JUnit 5 usage * Fix import order * Format rebased commit * nit: add final
In order to avoid too many PRs, I've addressed all comments that had small fixes (1 to 10 lines of code) in a single PR.
Changes:
java/pom.xmltojava/flight/flight-jdbc-driver/pom.xml. [link]timeZone == nullbehavior to use UTC instead of system default. [link]getObjectClass()toBoolean.class. [link]ArrowFlightJdbcDriver#createVersion()to not usebreak. [link]allocator.close()in ArrowFlightConnection. [link]