You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2021/03/17 15:35:01 UTC

[GitHub] [solr] asalamon74 opened a new pull request #24: SOLR-15111 Use JDK8 Base64 instead of own implementation

asalamon74 opened a new pull request #24:
URL: https://github.com/apache/solr/pull/24


   <!--
   _(If you are a project committer then you may remove some/all of the following template.)_
   
   Before creating a pull request, please file an issue in the ASF Jira system for Solr:
   
   * https://issues.apache.org/jira/projects/SOLR
   
   You will need to create an account in Jira in order to create an issue.
   
   The title of the PR should reference the Jira issue number in the form:
   
   * SOLR-####: <short description of problem or changes>
   
   SOLR must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
   
   Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
   
   Original lucene-solr pull request: https://github.com/apache/lucene-solr/pull/2252 I removed the lucene part of it.
   
   # Description
   
   JDK8 has a builtin Base64 encoder and decoder, there is no need to use own implementation for this.
   
   # Solution
   
   Eliminate own implementation.
   
   # Tests
   
   Unit tests
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [x] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability.
   - [x] I have created a Jira issue and added the issue ID to my pull request title.
   - [x] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
   - [x] I have developed this patch against the `main` branch.
   - [x] I have run `./gradlew check`.
   - [ ] I have added tests for my changes.
   - [ ] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [solr] asalamon74 commented on pull request #24: SOLR-15111 Use JDK8 Base64 instead of own implementation

Posted by GitBox <gi...@apache.org>.
asalamon74 commented on pull request #24:
URL: https://github.com/apache/solr/pull/24#issuecomment-906361683


   Rebased on top of the current main. @janhoy can you please take a look at it.


-- 
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-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] janhoy merged pull request #24: SOLR-15111 Use JDK8 Base64 instead of own implementation

Posted by GitBox <gi...@apache.org>.
janhoy merged pull request #24:
URL: https://github.com/apache/solr/pull/24


   


-- 
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-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] janhoy commented on pull request #24: SOLR-15111 Use JDK8 Base64 instead of own implementation

Posted by GitBox <gi...@apache.org>.
janhoy commented on pull request #24:
URL: https://github.com/apache/solr/pull/24#issuecomment-906638332


   Please add a CHANGES.txt entry for version 8.10, and I’ll commit.
   
   Have you run the entire test suite?


-- 
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-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] janhoy merged pull request #24: SOLR-15111 Use JDK8 Base64 instead of own implementation

Posted by GitBox <gi...@apache.org>.
janhoy merged pull request #24:
URL: https://github.com/apache/solr/pull/24


   


-- 
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-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] janhoy commented on a change in pull request #24: SOLR-15111 Use JDK8 Base64 instead of own implementation

Posted by GitBox <gi...@apache.org>.
janhoy commented on a change in pull request #24:
URL: https://github.com/apache/solr/pull/24#discussion_r696871532



##########
File path: solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
##########
@@ -298,7 +300,7 @@ private static String getFieldFlags( SchemaField f )
 
       BytesRef bytes = field.binaryValue();
       if (bytes != null) {
-        f.add( "binary", Base64.byteArrayToBase64(bytes.bytes, bytes.offset, bytes.length));
+        f.add( "binary", new String(Base64.getEncoder().encode(ByteBuffer.wrap(bytes.bytes, bytes.offset, bytes.length)).array(), StandardCharsets.ISO_8859_1));

Review comment:
       Ok




-- 
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-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] asalamon74 commented on a change in pull request #24: SOLR-15111 Use JDK8 Base64 instead of own implementation

Posted by GitBox <gi...@apache.org>.
asalamon74 commented on a change in pull request #24:
URL: https://github.com/apache/solr/pull/24#discussion_r600478496



##########
File path: solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
##########
@@ -298,7 +300,7 @@ private static String getFieldFlags( SchemaField f )
 
       BytesRef bytes = field.binaryValue();
       if (bytes != null) {
-        f.add( "binary", Base64.byteArrayToBase64(bytes.bytes, bytes.offset, bytes.length));
+        f.add( "binary", new String(Base64.getEncoder().encode(ByteBuffer.wrap(bytes.bytes, bytes.offset, bytes.length)).array(), StandardCharsets.ISO_8859_1));

Review comment:
       I'm afraid that's not exactly the same. ByteBuffer's `array()` method returns the full array and ignores the offset and the length. 




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [solr] janhoy commented on a change in pull request #24: SOLR-15111 Use JDK8 Base64 instead of own implementation

Posted by GitBox <gi...@apache.org>.
janhoy commented on a change in pull request #24:
URL: https://github.com/apache/solr/pull/24#discussion_r600261414



##########
File path: solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
##########
@@ -298,7 +300,7 @@ private static String getFieldFlags( SchemaField f )
 
       BytesRef bytes = field.binaryValue();
       if (bytes != null) {
-        f.add( "binary", Base64.byteArrayToBase64(bytes.bytes, bytes.offset, bytes.length));
+        f.add( "binary", new String(Base64.getEncoder().encode(ByteBuffer.wrap(bytes.bytes, bytes.offset, bytes.length)).array(), StandardCharsets.ISO_8859_1));

Review comment:
       Can be simplified to `Base64.getEncoder().encodeToString(ByteBuffer.wrap(bytes.bytes, bytes.offset, bytes.length).array())`




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [solr] janhoy merged pull request #24: SOLR-15111 Use JDK8 Base64 instead of own implementation

Posted by GitBox <gi...@apache.org>.
janhoy merged pull request #24:
URL: https://github.com/apache/solr/pull/24


   


-- 
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-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] asalamon74 commented on pull request #24: SOLR-15111 Use JDK8 Base64 instead of own implementation

Posted by GitBox <gi...@apache.org>.
asalamon74 commented on pull request #24:
URL: https://github.com/apache/solr/pull/24#issuecomment-908188338


   @janhoy Added the CHANGES.txt entry. I executed `./gradlew check` as far as I know it executes the tests.


-- 
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-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org