Skip to content

Fix bug: Use try-with-resources or close this "Statement" in a "finally" clause.#1702

Merged
davidzollo merged 3 commits intoapache:devfrom
Jave-Chen:bcai-dev-fix-bug-20200103-1701
Feb 6, 2020
Merged

Fix bug: Use try-with-resources or close this "Statement" in a "finally" clause.#1702
davidzollo merged 3 commits intoapache:devfrom
Jave-Chen:bcai-dev-fix-bug-20200103-1701

Conversation

@Jave-Chen
Copy link
Copy Markdown
Contributor

What is the purpose of the pull request

#1701 Resources should be closed

Brief change log

  1. Use try-with-resources with Statement and ResultSetk.
  2. Fix some code smell.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Jan 3, 2020

Codecov Report

Merging #1702 into dev will increase coverage by 6.5%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##              dev    #1702     +/-   ##
=========================================
+ Coverage   17.15%   23.66%   +6.5%     
=========================================
  Files         285      299     +14     
  Lines       13900    14405    +505     
  Branches     2267     2374    +107     
=========================================
+ Hits         2385     3409   +1024     
+ Misses      11240    10605    -635     
- Partials      275      391    +116
Impacted Files Coverage Δ
...he/dolphinscheduler/common/utils/ScriptRunner.java 0% <0%> (ø) ⬆️
...phinscheduler/common/enums/HttpCheckCondition.java 0% <0%> (-100%) ⬇️
...ache/dolphinscheduler/common/enums/HttpMethod.java 0% <0%> (-100%) ⬇️
...che/dolphinscheduler/common/enums/ProgramType.java 0% <0%> (-100%) ⬇️
...hinscheduler/common/utils/TaskParametersUtils.java 0% <0%> (-93.75%) ⬇️
...apache/dolphinscheduler/common/enums/TaskType.java 0% <0%> (-84.62%) ⬇️
...che/dolphinscheduler/common/utils/SchemaUtils.java 0% <0%> (-71.43%) ⬇️
...phinscheduler/common/task/http/HttpParameters.java 0% <0%> (-50%) ⬇️
...pache/dolphinscheduler/common/utils/FileUtils.java 3.26% <0%> (-38.05%) ⬇️
...pache/dolphinscheduler/common/utils/EnumUtils.java 0% <0%> (-27.28%) ⬇️
... and 141 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0a39541...c2a8371. Read the comment docs.

@Jave-Chen
Copy link
Copy Markdown
Contributor Author

Quality Gate failed

Failed condition B Maintainability Rating on New Code (is worse than A)
Failed condition 0.0% 0.0% Coverage on New Code (is less than 80%)
Failed condition 47.4% 47.4% Duplicated Lines on New Code (is greater than 3%)

String value = rs.getString(i);
logger.info("{} \t", value);
}
logger.info("");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line

}
}
} catch (SQLException e) {
logger.error(e.getMessage(),e);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.error("SQLException", e);

logger.error("Error executing: {}", sql);
throw e;
} catch (IOException e) {
e.fillInStackTrace();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

logger.error("Error executing: {}", command);
throw e;
} catch (IOException e) {
e.fillInStackTrace();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

while (rs.next()) {
for (int i = 0; i < cols; i++) {
String value = rs.getString(i);
logger.info("{} \t", value);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add more info

}
}
} catch (SQLException e) {
logger.error(e.getMessage(),e);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.error("SQLException", e);

@Jave-Chen
Copy link
Copy Markdown
Contributor Author

Roger

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Feb 6, 2020

SonarCloud Quality Gate failed.

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell B 4 Code Smells

0.0% 0.0% Coverage
48.6% 48.6% Duplication

@davidzollo davidzollo requested a review from Technoboy- February 6, 2020 11:17
Copy link
Copy Markdown
Contributor

@davidzollo davidzollo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@davidzollo davidzollo merged commit b3b075d into apache:dev Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants