You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2020/01/02 15:34:45 UTC

[GitHub] [incubator-dolphinscheduler] Jave-Chen opened a new pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause

Jave-Chen opened a new pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause
URL: https://github.com/apache/incubator-dolphinscheduler/pull/1689
 
 
   ## What is the purpose of the pull request
   #1688 
   Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause
   
   ## Brief change log
   1.  Reform import sequence (automatically  by  IDE);
   2.  Use try-with-resources with ResultSet ;
   3.  Fix some code smell .
   

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


With regards,
Apache Git Services

[GitHub] [incubator-dolphinscheduler] Technoboy- commented on a change in pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause

Posted by GitBox <gi...@apache.org>.
Technoboy- commented on a change in pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause
URL: https://github.com/apache/incubator-dolphinscheduler/pull/1689#discussion_r362782290
 
 

 ##########
 File path: dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/PostgrePerformance.java
 ##########
 @@ -50,26 +50,30 @@ public MonitorRecord getMonitorRecord(Connection conn) {
         Statement pstmt= null;
         try{
             pstmt = conn.createStatement();
-            ResultSet rs1 = pstmt.executeQuery("select count(*) from pg_stat_activity;");
-            while(rs1.next()){
-                monitorRecord.setThreadsConnections(rs1.getInt("count"));
-                break;
+            
+            try (ResultSet rs1 = pstmt.executeQuery("select count(*) from pg_stat_activity;")) {
+                while(rs1.next()){
+                    monitorRecord.setThreadsConnections(rs1.getInt("count"));
+                    break;
+                }
             }
 
-            ResultSet rs2 = pstmt.executeQuery("show max_connections");
-            while(rs2.next()){
-                monitorRecord.setMaxConnections( rs2.getInt("max_connections"));
-                break;
+            try (ResultSet rs2 = pstmt.executeQuery("show max_connections")) {
+                while(rs2.next()){
+                    monitorRecord.setMaxConnections( rs2.getInt("max_connections"));
+                    break;
+                }
             }
 
-            ResultSet rs3 = pstmt.executeQuery("select count(*) from pg_stat_activity pg where pg.state = 'active';");
-            while(rs3.next()){
-                monitorRecord.setThreadsRunningConnections(rs3.getInt("count"));
-                break;
+            try (ResultSet rs3 = pstmt.executeQuery("select count(*) from pg_stat_activity pg where pg.state = 'active';")) {
+                while(rs3.next()){
 
 Review comment:
   while --->  if

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


With regards,
Apache Git Services

[GitHub] [incubator-dolphinscheduler] Jave-Chen commented on issue #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause

Posted by GitBox <gi...@apache.org>.
Jave-Chen commented on issue #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause
URL: https://github.com/apache/incubator-dolphinscheduler/pull/1689#issuecomment-570248793
 
 
   QG Failed :
   Failed condition 0.0% 0.0% Coverage on New Code (is less than 80%)
   Failed condition 9.3% 9.3% Duplicated Lines on New Code (is greater than 3%)

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


With regards,
Apache Git Services

[GitHub] [incubator-dolphinscheduler] Jave-Chen commented on a change in pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause

Posted by GitBox <gi...@apache.org>.
Jave-Chen commented on a change in pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause
URL: https://github.com/apache/incubator-dolphinscheduler/pull/1689#discussion_r362795993
 
 

 ##########
 File path: dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/PostgrePerformance.java
 ##########
 @@ -50,26 +50,30 @@ public MonitorRecord getMonitorRecord(Connection conn) {
         Statement pstmt= null;
         try{
             pstmt = conn.createStatement();
-            ResultSet rs1 = pstmt.executeQuery("select count(*) from pg_stat_activity;");
-            while(rs1.next()){
-                monitorRecord.setThreadsConnections(rs1.getInt("count"));
-                break;
+            
+            try (ResultSet rs1 = pstmt.executeQuery("select count(*) from pg_stat_activity;")) {
+                while(rs1.next()){
+                    monitorRecord.setThreadsConnections(rs1.getInt("count"));
+                    break;
+                }
             }
 
-            ResultSet rs2 = pstmt.executeQuery("show max_connections");
-            while(rs2.next()){
-                monitorRecord.setMaxConnections( rs2.getInt("max_connections"));
-                break;
+            try (ResultSet rs2 = pstmt.executeQuery("show max_connections")) {
+                while(rs2.next()){
+                    monitorRecord.setMaxConnections( rs2.getInt("max_connections"));
+                    break;
+                }
             }
 
-            ResultSet rs3 = pstmt.executeQuery("select count(*) from pg_stat_activity pg where pg.state = 'active';");
-            while(rs3.next()){
-                monitorRecord.setThreadsRunningConnections(rs3.getInt("count"));
-                break;
+            try (ResultSet rs3 = pstmt.executeQuery("select count(*) from pg_stat_activity pg where pg.state = 'active';")) {
+                while(rs3.next()){
 
 Review comment:
   done

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


With regards,
Apache Git Services

[GitHub] [incubator-dolphinscheduler] Technoboy- merged pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause

Posted by GitBox <gi...@apache.org>.
Technoboy- merged pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause
URL: https://github.com/apache/incubator-dolphinscheduler/pull/1689
 
 
   

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


With regards,
Apache Git Services

[GitHub] [incubator-dolphinscheduler] codecov-io edited a comment on issue #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause
URL: https://github.com/apache/incubator-dolphinscheduler/pull/1689#issuecomment-570246069
 
 
   # [Codecov](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689?src=pr&el=h1) Report
   > Merging [#1689](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689?src=pr&el=desc) into [dev](https://codecov.io/gh/apache/incubator-dolphinscheduler/commit/216154dc068a6a5798860cfe32069f8ddf2097ab?src=pr&el=desc) will **decrease** coverage by `0.06%`.
   > The diff coverage is `0%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/graphs/tree.svg?width=650&token=bv9iXXRLi9&height=150&src=pr)](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##              dev    #1689      +/-   ##
   ==========================================
   - Coverage   17.21%   17.15%   -0.07%     
   ==========================================
     Files         284      285       +1     
     Lines       13853    13905      +52     
     Branches     2255     2272      +17     
   ==========================================
     Hits         2385     2385              
   - Misses      11193    11245      +52     
     Partials      275      275
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [...dolphinscheduler/dao/utils/PostgrePerformance.java](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/diff?src=pr&el=tree#diff-ZG9scGhpbnNjaGVkdWxlci1kYW8vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvZGFvL3V0aWxzL1Bvc3RncmVQZXJmb3JtYW5jZS5qYXZh) | `0% <0%> (ø)` | :arrow_up: |
   | [...e/dolphinscheduler/dao/utils/MysqlPerformance.java](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/diff?src=pr&el=tree#diff-ZG9scGhpbnNjaGVkdWxlci1kYW8vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvZGFvL3V0aWxzL015c3FsUGVyZm9ybWFuY2UuamF2YQ==) | `0% <0%> (ø)` | :arrow_up: |
   | [...pache/dolphinscheduler/common/utils/EnumUtils.java](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/diff?src=pr&el=tree#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL3V0aWxzL0VudW1VdGlscy5qYXZh) | `27.27% <0%> (-32.73%)` | :arrow_down: |
   | [...che/dolphinscheduler/common/utils/StringUtils.java](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/diff?src=pr&el=tree#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL3V0aWxzL1N0cmluZ1V0aWxzLmphdmE=) | `1.53% <0%> (-0.64%)` | :arrow_down: |
   | [...dolphinscheduler/common/queue/TaskQueueZkImpl.java](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/diff?src=pr&el=tree#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL3F1ZXVlL1Rhc2tRdWV1ZVprSW1wbC5qYXZh) | `0% <0%> (ø)` | :arrow_up: |
   | [...apache/dolphinscheduler/alert/utils/MailUtils.java](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/diff?src=pr&el=tree#diff-ZG9scGhpbnNjaGVkdWxlci1hbGVydC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZG9scGhpbnNjaGVkdWxlci9hbGVydC91dGlscy9NYWlsVXRpbHMuamF2YQ==) | `0% <0%> (ø)` | :arrow_up: |
   | [...heduler/server/master/runner/MasterExecThread.java](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/diff?src=pr&el=tree#diff-ZG9scGhpbnNjaGVkdWxlci1zZXJ2ZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvc2VydmVyL21hc3Rlci9ydW5uZXIvTWFzdGVyRXhlY1RocmVhZC5qYXZh) | `0% <0%> (ø)` | :arrow_up: |
   | [...lphinscheduler/server/worker/task/sql/SqlTask.java](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/diff?src=pr&el=tree#diff-ZG9scGhpbnNjaGVkdWxlci1zZXJ2ZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvc2VydmVyL3dvcmtlci90YXNrL3NxbC9TcWxUYXNrLmphdmE=) | `0% <0%> (ø)` | :arrow_up: |
   | [...cheduler/server/worker/runner/FetchTaskThread.java](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/diff?src=pr&el=tree#diff-ZG9scGhpbnNjaGVkdWxlci1zZXJ2ZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvc2VydmVyL3dvcmtlci9ydW5uZXIvRmV0Y2hUYXNrVGhyZWFkLmphdmE=) | `0% <0%> (ø)` | :arrow_up: |
   | [.../apache/dolphinscheduler/common/utils/IOUtils.java](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/diff?src=pr&el=tree#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL3V0aWxzL0lPVXRpbHMuamF2YQ==) | `0% <0%> (ø)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689?src=pr&el=footer). Last update [216154d...330d549](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   

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


With regards,
Apache Git Services

[GitHub] [incubator-dolphinscheduler] codecov-io commented on issue #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause

Posted by GitBox <gi...@apache.org>.
codecov-io commented on issue #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause
URL: https://github.com/apache/incubator-dolphinscheduler/pull/1689#issuecomment-570246069
 
 
   # [Codecov](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689?src=pr&el=h1) Report
   > Merging [#1689](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689?src=pr&el=desc) into [dev](https://codecov.io/gh/apache/incubator-dolphinscheduler/commit/26ed786c4d4cd1b8ae0e49a4a2ac7f2677a1948a?src=pr&el=desc) will **decrease** coverage by `<.01%`.
   > The diff coverage is `0%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/graphs/tree.svg?width=650&token=bv9iXXRLi9&height=150&src=pr)](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689?src=pr&el=tree)
   
   ```diff
   @@           Coverage Diff            @@
   ##             dev   #1689      +/-   ##
   ========================================
   - Coverage   16.3%   16.3%   -0.01%     
   ========================================
     Files        283     283              
     Lines      13864   13869       +5     
     Branches    2251    2258       +7     
   ========================================
     Hits        2261    2261              
   - Misses     11343   11348       +5     
     Partials     260     260
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [...dolphinscheduler/dao/utils/PostgrePerformance.java](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/diff?src=pr&el=tree#diff-ZG9scGhpbnNjaGVkdWxlci1kYW8vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvZGFvL3V0aWxzL1Bvc3RncmVQZXJmb3JtYW5jZS5qYXZh) | `0% <0%> (ø)` | :arrow_up: |
   | [...e/dolphinscheduler/dao/utils/MysqlPerformance.java](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/diff?src=pr&el=tree#diff-ZG9scGhpbnNjaGVkdWxlci1kYW8vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvZGFvL3V0aWxzL015c3FsUGVyZm9ybWFuY2UuamF2YQ==) | `0% <0%> (ø)` | :arrow_up: |
   | [...org/apache/dolphinscheduler/dao/TaskRecordDao.java](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689/diff?src=pr&el=tree#diff-ZG9scGhpbnNjaGVkdWxlci1kYW8vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvZGFvL1Rhc2tSZWNvcmREYW8uamF2YQ==) | `0% <0%> (ø)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689?src=pr&el=footer). Last update [26ed786...45c54b0](https://codecov.io/gh/apache/incubator-dolphinscheduler/pull/1689?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   

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


With regards,
Apache Git Services

[GitHub] [incubator-dolphinscheduler] Jave-Chen commented on a change in pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause

Posted by GitBox <gi...@apache.org>.
Jave-Chen commented on a change in pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause
URL: https://github.com/apache/incubator-dolphinscheduler/pull/1689#discussion_r362795969
 
 

 ##########
 File path: dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/PostgrePerformance.java
 ##########
 @@ -50,26 +50,30 @@ public MonitorRecord getMonitorRecord(Connection conn) {
         Statement pstmt= null;
         try{
             pstmt = conn.createStatement();
-            ResultSet rs1 = pstmt.executeQuery("select count(*) from pg_stat_activity;");
-            while(rs1.next()){
-                monitorRecord.setThreadsConnections(rs1.getInt("count"));
-                break;
+            
+            try (ResultSet rs1 = pstmt.executeQuery("select count(*) from pg_stat_activity;")) {
+                while(rs1.next()){
+                    monitorRecord.setThreadsConnections(rs1.getInt("count"));
+                    break;
+                }
             }
 
-            ResultSet rs2 = pstmt.executeQuery("show max_connections");
-            while(rs2.next()){
-                monitorRecord.setMaxConnections( rs2.getInt("max_connections"));
-                break;
+            try (ResultSet rs2 = pstmt.executeQuery("show max_connections")) {
+                while(rs2.next()){
 
 Review comment:
   done

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


With regards,
Apache Git Services

[GitHub] [incubator-dolphinscheduler] Technoboy- commented on a change in pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause

Posted by GitBox <gi...@apache.org>.
Technoboy- commented on a change in pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause
URL: https://github.com/apache/incubator-dolphinscheduler/pull/1689#discussion_r362782211
 
 

 ##########
 File path: dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/PostgrePerformance.java
 ##########
 @@ -50,26 +50,30 @@ public MonitorRecord getMonitorRecord(Connection conn) {
         Statement pstmt= null;
         try{
             pstmt = conn.createStatement();
-            ResultSet rs1 = pstmt.executeQuery("select count(*) from pg_stat_activity;");
-            while(rs1.next()){
-                monitorRecord.setThreadsConnections(rs1.getInt("count"));
-                break;
+            
+            try (ResultSet rs1 = pstmt.executeQuery("select count(*) from pg_stat_activity;")) {
+                while(rs1.next()){
 
 Review comment:
   while ---->  if 

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


With regards,
Apache Git Services

[GitHub] [incubator-dolphinscheduler] Technoboy- commented on a change in pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause

Posted by GitBox <gi...@apache.org>.
Technoboy- commented on a change in pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause
URL: https://github.com/apache/incubator-dolphinscheduler/pull/1689#discussion_r362782258
 
 

 ##########
 File path: dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/PostgrePerformance.java
 ##########
 @@ -50,26 +50,30 @@ public MonitorRecord getMonitorRecord(Connection conn) {
         Statement pstmt= null;
         try{
             pstmt = conn.createStatement();
-            ResultSet rs1 = pstmt.executeQuery("select count(*) from pg_stat_activity;");
-            while(rs1.next()){
-                monitorRecord.setThreadsConnections(rs1.getInt("count"));
-                break;
+            
+            try (ResultSet rs1 = pstmt.executeQuery("select count(*) from pg_stat_activity;")) {
+                while(rs1.next()){
+                    monitorRecord.setThreadsConnections(rs1.getInt("count"));
+                    break;
+                }
             }
 
-            ResultSet rs2 = pstmt.executeQuery("show max_connections");
-            while(rs2.next()){
-                monitorRecord.setMaxConnections( rs2.getInt("max_connections"));
-                break;
+            try (ResultSet rs2 = pstmt.executeQuery("show max_connections")) {
+                while(rs2.next()){
 
 Review comment:
   while --->  if

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


With regards,
Apache Git Services

[GitHub] [incubator-dolphinscheduler] Jave-Chen commented on a change in pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause

Posted by GitBox <gi...@apache.org>.
Jave-Chen commented on a change in pull request #1689: Fix bug : Use try-with-resources or close this "ResultSet" in a "finally" clause
URL: https://github.com/apache/incubator-dolphinscheduler/pull/1689#discussion_r362795935
 
 

 ##########
 File path: dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/PostgrePerformance.java
 ##########
 @@ -50,26 +50,30 @@ public MonitorRecord getMonitorRecord(Connection conn) {
         Statement pstmt= null;
         try{
             pstmt = conn.createStatement();
-            ResultSet rs1 = pstmt.executeQuery("select count(*) from pg_stat_activity;");
-            while(rs1.next()){
-                monitorRecord.setThreadsConnections(rs1.getInt("count"));
-                break;
+            
+            try (ResultSet rs1 = pstmt.executeQuery("select count(*) from pg_stat_activity;")) {
+                while(rs1.next()){
 
 Review comment:
   done

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


With regards,
Apache Git Services