Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use java 7 features #819

Closed
wants to merge 4 commits into from
Closed

use java 7 features #819

wants to merge 4 commits into from

Conversation

AlexElin
Copy link
Contributor

@AlexElin AlexElin commented Jan 31, 2018

Migrate code to using features of Java 7 like try-with-resources, Objects class and etc


This change is Reviewable

@codecov
Copy link

codecov bot commented Jan 31, 2018

Codecov Report

Merging #819 into master will increase coverage by 0.1%.
The diff coverage is 38.09%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #819     +/-   ##
===========================================
+ Coverage     74.54%   74.65%   +0.1%     
+ Complexity     3334     3323     -11     
===========================================
  Files           364      364             
  Lines         10354    10316     -38     
  Branches       1298     1294      -4     
===========================================
- Hits           7718     7701     -17     
+ Misses         2171     2150     -21     
  Partials        465      465
Impacted Files Coverage Δ Complexity Δ
.../src/main/java/org/spockframework/util/IoUtil.java 43.39% <ø> (+4.43%) 12 <0> (-2) ⬇️
.../main/java/org/spockframework/util/ObjectUtil.java 90.9% <ø> (-2.43%) 14 <0> (-7)
...ckframework/runtime/ConfigurationScriptLoader.java 82.69% <0%> (ø) 16 <0> (ø) ⬇️
...n/java/org/spockframework/util/CollectionUtil.java 74.22% <0%> (-0.78%) 23 <2> (-1)
...ava/org/spockframework/runtime/SpecRunHistory.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...org/spockframework/report/log/ReportLogClient.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...ckframework/spring/mock/DelegatingInterceptor.java 54.05% <0%> (-5.41%) 6 <0> (-1)
...java/org/spockframework/util/SpockReleaseInfo.java 47.61% <100%> (ø) 3 <0> (ø) ⬇️
...g/spockframework/report/HtmlReportGenerator.groovy 78.2% <100%> (ø) 21 <0> (ø) ⬇️
...rg/spockframework/report/log/ReportLogEmitter.java 98.29% <100%> (ø) 43 <0> (ø) ⬇️
... and 5 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 5b48fa8...4da71f6. Read the comment docs.

Copy link
Contributor

@oreissig oreissig left a comment

Choose a reason for hiding this comment

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

I like the changes. Would you mind to rebase and squash your commits?

Copy link
Contributor

@tburny tburny left a comment

Choose a reason for hiding this comment

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

In summary this looks quite good to me!
The code deleted in the tests corresponds to the deleted methods in the utility classes.
One minor thing might be the exception handling replaced by ReflectiveOperationException, but I think this is more a matter of taste.

@@ -51,7 +51,7 @@ public Object intercept(Object target, Method method, Object[] arguments, IRespo

try {
return method.invoke(delegate, arguments);
} catch (IllegalAccessException | InvocationTargetException e) {
} catch (ReflectiveOperationException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would favour the previous version of this, because using ReflectiveOperationException looks to me like Pokemon exception handling. Instead of catching only the specific exceptions that can be thrown, now all exceptions (even unexpected ones / error condition) are caught.

@@ -17,47 +17,27 @@ package org.spockframework.util
import spock.lang.Specification

class ObjectUtilSpec extends Specification {
def "null aware equals"() {
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Was also deleted from ObjectUtil


package org.spockframework.util

import spock.lang.*

class CollectionUtilSpec extends Specification {
def "copy an array"() {
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Was also deleted from CollectionUtil

@@ -134,7 +135,7 @@ class HtmlReportGenerator {
def target = new File(outputDirectory, resourcePath)
if (!target.exists()) {
target.parentFile.mkdirs()
IoUtil.copyStream(source, new FileOutputStream(target))
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Was also deleted from IoUtil

@leonard84
Copy link
Member

Thanks @AlexElin, FWIW the PR came at an time where Spock was majorly refactored and we didn't accept merge requests. The changes proposed here have also been made in other PRs so I'm closing it after 4 years 😅.

@leonard84 leonard84 closed this Sep 29, 2022
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