-
Notifications
You must be signed in to change notification settings - Fork 48
Teach Reader to use a URL #1
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
Conversation
These objects are in the same package as the Test, and thus do not require import.
Updated the test to exercise both the File and the URL flavors.
Since this project is Open Source, it is very handy to have Maven download the sources for the jars found in central. Some projects also attach javadoc, but the sources provide javadoc (at least with IJ) so I find that they just take up space.
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.
AFAIK, this can return -1, which will cause the next line to fail
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.
Yes, I had forgotten about that. However, if we go with the BAOS mechanism you mention below, then we won't need content-length and this bug goes away.
InputStream is the common denominator and contains enough information to construct the ThreadBuffer (and thus the Reader).
Those warnings in IJ hide potentially real bugs.
|
I switched to the BAOS as we discussed and (of course) all the tests pass. I'll update the GeoIP2-java PR in a second. |
|
Thanks! 👍 |
Add the missing cache files
There are circumstances under which one does not have access to a
Fileand it seems unnecessary to open anInputStreamonly to serialize it to aFilewhich is then subsequently read back into memory due to the constructorReader(File).Thus, this PR adds a constructor to
Readerthat accepts aURL.I briefly thought about going to the next logical conclusion and adding one for
InputStreambut I am not familiar enough with NIO to avoid building up aList<byte>since I would not know the length of the incoming stream.I will also submit a PR for
com.maxmind.geoip2.DatabaseReaderover in GeoIP2-java to expose the new functionality.