You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/03/24 05:07:24 UTC

[GitHub] [netbeans] mbien opened a new pull request #3844: Use constants defined in StandardCharsets instead of Charset name lookup.

mbien opened a new pull request #3844:
URL: https://github.com/apache/netbeans/pull/3844


   project wide refactoring using this [jackpot inspection](https://github.com/mbien/jackpot-inspections/blob/master/UseStandardCharsets.hint)
   
   `Charset`s defined in `StandardCharsets` are always supported by the runtime, which means:
    - less handling of the checked`UnsupportedEncodingException`
    - potentially slightly better performance in some cases since no lookup is needed
   
   static imports are only used in a handful of classes with many occurrences of the fields.
   
   Each commit contains at least one cluster so that reviewers don't have to review everything (please mention what you reviewed).
   
   going to squash everything before merge.


-- 
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: notifications-unsubscribe@netbeans.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lbownik commented on a change in pull request #3844: Use constants defined in StandardCharsets instead of Charset name lookup.

Posted by GitBox <gi...@apache.org>.
lbownik commented on a change in pull request #3844:
URL: https://github.com/apache/netbeans/pull/3844#discussion_r835545873



##########
File path: apisupport/apisupport.ant/src/org/netbeans/modules/apisupport/project/queries/FileEncodingQueryImpl.java
##########
@@ -37,7 +38,7 @@
     public FileEncodingQueryImpl() {}
 
     public Charset getEncoding(FileObject file) {
-        return Charset.forName("UTF-8");
+        return StandardCharsets.UTF_8;

Review comment:
       How about using static import?




-- 
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: notifications-unsubscribe@netbeans.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] lbownik commented on a change in pull request #3844: Use constants defined in StandardCharsets instead of Charset name lookup.

Posted by GitBox <gi...@apache.org>.
lbownik commented on a change in pull request #3844:
URL: https://github.com/apache/netbeans/pull/3844#discussion_r835560379



##########
File path: apisupport/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/wizard/common/CreatedModifiedFilesTest.java
##########
@@ -222,7 +223,7 @@ public void testAddLookupRegistration() throws Exception {
         assertNotNull(registry);
         InputStream is = registry.getInputStream();
         try {
-            BufferedReader r = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+            BufferedReader r = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));

Review comment:
       how about try-with-resources here?




-- 
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: notifications-unsubscribe@netbeans.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on pull request #3844: Use constants defined in StandardCharsets instead of Charset name lookup.

Posted by GitBox <gi...@apache.org>.
mbien commented on pull request #3844:
URL: https://github.com/apache/netbeans/pull/3844#issuecomment-1078721253


   > First impression: Nice. The changes I saw looked sane to me and should not affect compatibility.
   
   right. All it does is to replace charset lookups with the equivalent instance from `StandardCharsets.*`


-- 
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: notifications-unsubscribe@netbeans.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a change in pull request #3844: Use constants defined in StandardCharsets instead of Charset name lookup.

Posted by GitBox <gi...@apache.org>.
mbien commented on a change in pull request #3844:
URL: https://github.com/apache/netbeans/pull/3844#discussion_r835561606



##########
File path: apisupport/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/wizard/common/CreatedModifiedFilesTest.java
##########
@@ -222,7 +223,7 @@ public void testAddLookupRegistration() throws Exception {
         assertNotNull(registry);
         InputStream is = registry.getInputStream();
         try {
-            BufferedReader r = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+            BufferedReader r = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));

Review comment:
       this PR does only one inspection. It would be too much at once otherwise and would make review very tiresome.




-- 
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: notifications-unsubscribe@netbeans.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing commented on pull request #3844: Use constants defined in StandardCharsets instead of Charset name lookup.

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on pull request #3844:
URL: https://github.com/apache/netbeans/pull/3844#issuecomment-1077429459


   First impression: Nice. The changes I saw looked sane to me and should not affect compatibility.


-- 
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: notifications-unsubscribe@netbeans.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on pull request #3844: Use constants defined in StandardCharsets instead of Charset name lookup.

Posted by GitBox <gi...@apache.org>.
mbien commented on pull request #3844:
URL: https://github.com/apache/netbeans/pull/3844#issuecomment-1079516828


   all green again. merging.


-- 
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: notifications-unsubscribe@netbeans.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a change in pull request #3844: Use constants defined in StandardCharsets instead of Charset name lookup.

Posted by GitBox <gi...@apache.org>.
mbien commented on a change in pull request #3844:
URL: https://github.com/apache/netbeans/pull/3844#discussion_r835548724



##########
File path: apisupport/apisupport.ant/src/org/netbeans/modules/apisupport/project/queries/FileEncodingQueryImpl.java
##########
@@ -37,7 +38,7 @@
     public FileEncodingQueryImpl() {}
 
     public Charset getEncoding(FileObject file) {
-        return Charset.forName("UTF-8");
+        return StandardCharsets.UTF_8;

Review comment:
       static imports were used in a few cases where it made a difference. The typical case are 1-2 occurrences per file where it doesn't really matter.




-- 
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: notifications-unsubscribe@netbeans.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on pull request #3844: Use constants defined in StandardCharsets instead of Charset name lookup.

Posted by GitBox <gi...@apache.org>.
mbien commented on pull request #3844:
URL: https://github.com/apache/netbeans/pull/3844#issuecomment-1079369770


   everything green + got one approval so far + I looked through everything again and found no anomalies as last check.
   
   squashing the commits, planning to merge soon before we get conflicts.


-- 
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: notifications-unsubscribe@netbeans.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien merged pull request #3844: Use constants defined in StandardCharsets instead of Charset name lookup.

Posted by GitBox <gi...@apache.org>.
mbien merged pull request #3844:
URL: https://github.com/apache/netbeans/pull/3844


   


-- 
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: notifications-unsubscribe@netbeans.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists