You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/09/14 17:30:55 UTC

[GitHub] [trafficcontrol] zrhoffman opened a new pull request #6210: Update Traffic Router Java version to 11

zrhoffman opened a new pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210


   <!--
   Thank you for contributing! Please be sure to read our contribution guidelines: https://github.com/apache/trafficcontrol/blob/master/CONTRIBUTING.md
   If this closes or relates to an existing issue, please reference it using one of the following:
   
   Closes: #ISSUE
   Related: #ISSUE
   
   If this PR fixes a security vulnerability, DO NOT submit! Instead, contact
   the Apache Traffic Control Security Team at security@trafficcontrol.apache.org and follow the
   guidelines at https://apache.org/security regarding vulnerability disclosure.
   -->
   Closes: #3196
   
   This PR makes Traffic Router use Java 11 by default for compilation, testing, and running.
   
   Big thanks to @ARMmaster17 for getting Traffic Router itself to work using Java 11. Besides changing Java versions around the project, this PR mainly just updates PMD to a version that supports targeting Java 11, which involved fixing new PMD "failures" that PMD 6.29.0 (up from PMD 5.3.5 in `maven-pmd-plugin` version 3.6) finds.
   <!-- **^ Add meaningful description above** --><hr>
   
   ## Which Traffic Control components are affected by this PR?
   <!-- Please delete all components from this list that are NOT affected by this PR.
   Feel free to add the name of a tool or script that is affected but not on the list.
   -->
   - Documentation
   - Traffic Router
   - Automation (GitHub Actions, Ansible Roles)
   
   ## What is the best way to verify this PR?
   <!-- Please include here ALL the steps necessary to test your PR.
   If your PR has tests (and most should), provide the steps needed to run the tests.
   If not, please provide step-by-step instructions to test the PR manually and explain why your PR does not need tests. -->
   - Run tests using Java 11
       ```shell
       docker-compose -f traffic_router/tests/docker-compose.yml up --build unit_router
       ```
   - Compile Traffic Router using Java 11:
       ```shell
       ./pkg -bv traffic_router_build
       ```
   - Verify that Traffic Router, including the resource watchers, work as expected by running the TR external and integration tests
   
   ## PR submission checklist
   - [x] This PR has tests <!-- If not, please delete this text and explain why this PR does not need tests. -->
   - [x] This PR has documentation <!-- If not, please delete this text and explain why this PR does not need documentation. -->
   - [x] This PR has a CHANGELOG.md entry <!-- A fix for a bug from an ATC release, an improvement, or a new feature should have a changelog entry. -->
   - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://apache.org/security) for details)
   
   <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
   -->


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

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



[GitHub] [trafficcontrol] zrhoffman commented on pull request #6210: Update Traffic Router Java version to 11

Posted by GitBox <gi...@apache.org>.
zrhoffman commented on pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210#issuecomment-944615744


   Rebased to fix a merge conflict from #6278


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

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



[GitHub] [trafficcontrol] zrhoffman commented on a change in pull request #6210: Update Traffic Router Java version to 11

Posted by GitBox <gi...@apache.org>.
zrhoffman commented on a change in pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210#discussion_r709521523



##########
File path: traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/DNSAccessEventBuilder.java
##########
@@ -122,12 +122,12 @@ public static String create(final DNSAccessRecord dnsAccessRecord, final WirePar
                 .append(" rdtl=-")
                 .append(" rerr=\"")
                 .append(rerr)
-                .append("\"")
+                .append('\"')

Review comment:
       Unescaped in 8ca61dd2bb

##########
File path: traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/DNSAccessEventBuilder.java
##########
@@ -122,12 +122,12 @@ public static String create(final DNSAccessRecord dnsAccessRecord, final WirePar
                 .append(" rdtl=-")
                 .append(" rerr=\"")
                 .append(rerr)
-                .append("\"")
+                .append('\"')
                 .append(" ttl=\"-\"")
                 .append(" ans=\"-\"")
                 .append(" svc=\"")
                 .append(dsID)
-                .append("\"")
+                .append('\"')

Review comment:
       Unescaped in 8ca61dd2bb

##########
File path: traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/DNSAccessEventBuilder.java
##########
@@ -145,12 +145,12 @@ public static String create(final DNSAccessRecord dnsAccessRecord, final Excepti
                 .append(" rdtl=-")
                 .append(" rerr=\"")
                 .append(rerr)
-                .append("\"")
+                .append('\"')

Review comment:
       Unescaped in 8ca61dd2bb

##########
File path: traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/DNSAccessEventBuilder.java
##########
@@ -145,12 +145,12 @@ public static String create(final DNSAccessRecord dnsAccessRecord, final Excepti
                 .append(" rdtl=-")
                 .append(" rerr=\"")
                 .append(rerr)
-                .append("\"")
+                .append('\"')
                 .append(" ttl=\"-\"")
                 .append(" ans=\"-\"")
                 .append(" svc=\"")
                 .append(dsID)
-                .append("\"").toString();
+                .append('\"').toString();

Review comment:
       Unescaped in 8ca61dd2bb




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

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



[GitHub] [trafficcontrol] zrhoffman commented on a change in pull request #6210: Update Traffic Router Java version to 11

Posted by GitBox <gi...@apache.org>.
zrhoffman commented on a change in pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210#discussion_r709609227



##########
File path: traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/protocol/TCP.java
##########
@@ -46,9 +46,9 @@ public ServerSocket getServerSocket() {
     @Override
     public void run() {
         while (!isShutdownRequested()) {
-            try {
-                final Socket socket = getServerSocket().accept();
-                final TCPSocketHandler handler = new TCPSocketHandler(socket);
+            final TCPSocketHandler handler;
+            try (Socket socket = getServerSocket().accept()) {

Review comment:
       Right you are, it will. Not prematurely closing the socket in 4a9cdd96a6.




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

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



[GitHub] [trafficcontrol] zrhoffman commented on a change in pull request #6210: Update Traffic Router Java version to 11

Posted by GitBox <gi...@apache.org>.
zrhoffman commented on a change in pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210#discussion_r709540937



##########
File path: .github/actions/build-rpms/build-rpms.sh
##########
@@ -28,9 +28,12 @@ if [[ "$GITHUB_REF" == refs/pull/*/merge ]]; then
 	pr_number="$(<<<"$GITHUB_REF" grep -o '[0-9]\+')"
 	files_changed="$(curl "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/pulls/${pr_number}/files" | jq -r .[].filename)"
 else
-	files_changed="$(git diff-tree --no-commit-id --name-only -r "$GITHUB_SHA")"
+	files_changed="$(git diff --name-only HEAD~4.. --)"

Review comment:
       > Is this only diffing the last 4 commits
   
   Diffing the last 5 commits to show the files changed in the last 4 commits. Commented and unabbreviated in 10204ef161.




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

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



[GitHub] [trafficcontrol] zrhoffman commented on a change in pull request #6210: Update Traffic Router Java version to 11

Posted by GitBox <gi...@apache.org>.
zrhoffman commented on a change in pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210#discussion_r709553312



##########
File path: traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/ds/LetsEncryptDnsChallengeWatcher.java
##########
@@ -128,6 +128,7 @@ public String getWatcherConfigPrefix() {
         return "dnschallengemapping";
     }
 
+    @SuppressWarnings("PMD.CloseResource")

Review comment:
       You're right, these ones can be closed . Closing in afd429dd13




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

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



[GitHub] [trafficcontrol] rawlinp merged pull request #6210: Update Traffic Router Java version to 11

Posted by GitBox <gi...@apache.org>.
rawlinp merged pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210


   


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

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



[GitHub] [trafficcontrol] zrhoffman commented on pull request #6210: Update Traffic Router Java version to 11

Posted by GitBox <gi...@apache.org>.
zrhoffman commented on pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210#issuecomment-969312454


   Rebased to fix a merge conflict from #6303


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

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



[GitHub] [trafficcontrol] zrhoffman commented on pull request #6210: Update Traffic Router Java version to 11

Posted by GitBox <gi...@apache.org>.
zrhoffman commented on pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210#issuecomment-983677185


   > So, this PR appears to decrease performance by 25% in terms of req/s handled compared to `master` on Java 8. If we just upgrade to java 11 on the server, we get a performance increase of 9%.
   
   There was a NullPointerException due to trying to get the socket from `socketWrapper` when it was null, which decreased performance significantly. Fixed in 35bd577cc7, performance is back up for me


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

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #6210: Update Traffic Router Java version to 11

Posted by GitBox <gi...@apache.org>.
rawlinp commented on a change in pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210#discussion_r762131729



##########
File path: traffic_router/connector/src/main/java/org/apache/traffic_control/traffic_router/protocol/RouterNioEndpoint.java
##########
@@ -151,8 +151,9 @@ public RouterSocketProcessor(final SocketWrapperBase<NioChannel> socketWrapper,
 		*/
 		@Override
 		protected void doRun(){
-			final SocketWrapperBase<NioChannel> localWrapper = socketWrapper;
-			final NioChannel socket = localWrapper.getSocket();
+			@SuppressWarnings("PMD.CloseResource")
+			// The socket must be stored before calling super.doRun() because it sets socketWrapper to null
+			final NioChannel socket = socketWrapper.getSocket();

Review comment:
       Yeah, I believe this entire `RouterSocketProcessor` class and overridden `createSocketProcessor` method are no longer necessary. In shadow testing, TR seemed fine either way and even seemed like it performed slightly better in terms of requests/sec without this.




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

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



[GitHub] [trafficcontrol] zrhoffman commented on pull request #6210: Update Traffic Router Java version to 11

Posted by GitBox <gi...@apache.org>.
zrhoffman commented on pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210#issuecomment-940064719


   Rebased to resolve merge conflicts
   ```git
           both modified:   CHANGELOG.md
           deleted by us:   docs/source/admin/traffic_router/migrationto2-3.rst
   ```


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

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #6210: Update Traffic Router Java version to 11

Posted by GitBox <gi...@apache.org>.
rawlinp commented on a change in pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210#discussion_r709366413



##########
File path: traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/DNSAccessEventBuilder.java
##########
@@ -145,12 +145,12 @@ public static String create(final DNSAccessRecord dnsAccessRecord, final Excepti
                 .append(" rdtl=-")
                 .append(" rerr=\"")
                 .append(rerr)
-                .append("\"")
+                .append('\"')
                 .append(" ttl=\"-\"")
                 .append(" ans=\"-\"")
                 .append(" svc=\"")
                 .append(dsID)
-                .append("\"").toString();
+                .append('\"').toString();

Review comment:
       Does this need escaped since it's now a char instead of a string?

##########
File path: traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/ds/DeliveryService.java
##########
@@ -118,6 +118,7 @@
 		ALWAYS
 	}
 
+	@SuppressWarnings("PMD.NPathComplexity")

Review comment:
       Just for my own edification, does suppressing warnings at the class level just suppress it for all methods in the class?

##########
File path: traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/protocol/TCP.java
##########
@@ -46,9 +46,9 @@ public ServerSocket getServerSocket() {
     @Override
     public void run() {
         while (!isShutdownRequested()) {
-            try {
-                final Socket socket = getServerSocket().accept();
-                final TCPSocketHandler handler = new TCPSocketHandler(socket);
+            final TCPSocketHandler handler;
+            try (Socket socket = getServerSocket().accept()) {

Review comment:
       Won't this prematurely close the socket before it's even handled?

##########
File path: .github/actions/build-rpms/build-rpms.sh
##########
@@ -28,9 +28,12 @@ if [[ "$GITHUB_REF" == refs/pull/*/merge ]]; then
 	pr_number="$(<<<"$GITHUB_REF" grep -o '[0-9]\+')"
 	files_changed="$(curl "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/pulls/${pr_number}/files" | jq -r .[].filename)"
 else
-	files_changed="$(git diff-tree --no-commit-id --name-only -r "$GITHUB_SHA")"
+	files_changed="$(git diff --name-only HEAD~4.. --)"

Review comment:
       Just for my own edification -- what does this change do? Is this only diffing the last 4 commits?

##########
File path: traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/DNSAccessEventBuilder.java
##########
@@ -122,12 +122,12 @@ public static String create(final DNSAccessRecord dnsAccessRecord, final WirePar
                 .append(" rdtl=-")
                 .append(" rerr=\"")
                 .append(rerr)
-                .append("\"")
+                .append('\"')
                 .append(" ttl=\"-\"")
                 .append(" ans=\"-\"")
                 .append(" svc=\"")
                 .append(dsID)
-                .append("\"")
+                .append('\"')

Review comment:
       Does this need escaped since it's now a char instead of a string?

##########
File path: traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/DNSAccessEventBuilder.java
##########
@@ -122,12 +122,12 @@ public static String create(final DNSAccessRecord dnsAccessRecord, final WirePar
                 .append(" rdtl=-")
                 .append(" rerr=\"")
                 .append(rerr)
-                .append("\"")
+                .append('\"')

Review comment:
       Does this need escaped since it's now a char instead of a string?

##########
File path: traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/ds/LetsEncryptDnsChallengeWatcher.java
##########
@@ -128,6 +128,7 @@ public String getWatcherConfigPrefix() {
         return "dnschallengemapping";
     }
 
+    @SuppressWarnings("PMD.CloseResource")

Review comment:
       Why suppress here but not others?

##########
File path: traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/DNSAccessEventBuilder.java
##########
@@ -145,12 +145,12 @@ public static String create(final DNSAccessRecord dnsAccessRecord, final Excepti
                 .append(" rdtl=-")
                 .append(" rerr=\"")
                 .append(rerr)
-                .append("\"")
+                .append('\"')

Review comment:
       Does this need escaped since it's now a char instead of a string?




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

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



[GitHub] [trafficcontrol] zrhoffman commented on a change in pull request #6210: Update Traffic Router Java version to 11

Posted by GitBox <gi...@apache.org>.
zrhoffman commented on a change in pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210#discussion_r709518081



##########
File path: traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/ds/DeliveryService.java
##########
@@ -118,6 +118,7 @@
 		ALWAYS
 	}
 
+	@SuppressWarnings("PMD.NPathComplexity")

Review comment:
       Yes. Unsuppressed `PMD.NPathComplexity` in f0636de438




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

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



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #6210: Update Traffic Router Java version to 11

Posted by GitBox <gi...@apache.org>.
rawlinp commented on a change in pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210#discussion_r760345161



##########
File path: traffic_router/connector/src/main/java/org/apache/traffic_control/traffic_router/protocol/RouterNioEndpoint.java
##########
@@ -151,8 +151,9 @@ public RouterSocketProcessor(final SocketWrapperBase<NioChannel> socketWrapper,
 		*/
 		@Override
 		protected void doRun(){
-			final SocketWrapperBase<NioChannel> localWrapper = socketWrapper;
-			final NioChannel socket = localWrapper.getSocket();
+			@SuppressWarnings("PMD.CloseResource")
+			// The socket must be stored before calling super.doRun() because it sets socketWrapper to null
+			final NioChannel socket = socketWrapper.getSocket();

Review comment:
       I wonder if the issue mentioned in the comment above has been corrected yet. I think that was added to fix a version at least a couple major versions ago, so there's definitely been some time since then. The issue was basically breaking https requests, so it should be fairly straightforward to verify. I'll see if I can reproduce after removing this `RouterSocketProcessor` class.




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

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



[GitHub] [trafficcontrol] zrhoffman commented on a change in pull request #6210: Update Traffic Router Java version to 11

Posted by GitBox <gi...@apache.org>.
zrhoffman commented on a change in pull request #6210:
URL: https://github.com/apache/trafficcontrol/pull/6210#discussion_r762135707



##########
File path: traffic_router/connector/src/main/java/org/apache/traffic_control/traffic_router/protocol/RouterNioEndpoint.java
##########
@@ -151,8 +151,9 @@ public RouterSocketProcessor(final SocketWrapperBase<NioChannel> socketWrapper,
 		*/
 		@Override
 		protected void doRun(){
-			final SocketWrapperBase<NioChannel> localWrapper = socketWrapper;
-			final NioChannel socket = localWrapper.getSocket();
+			@SuppressWarnings("PMD.CloseResource")
+			// The socket must be stored before calling super.doRun() because it sets socketWrapper to null
+			final NioChannel socket = socketWrapper.getSocket();

Review comment:
       Neat, removed in 0d2cc14ee5.




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

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