Skip to content

Make Java Connection implement AutoCloseable (since JRE 1.7)#491

Merged
djungelorm merged 1 commit into
krpc:masterfrom
Genhis:java1
Sep 26, 2018
Merged

Make Java Connection implement AutoCloseable (since JRE 1.7)#491
djungelorm merged 1 commit into
krpc:masterfrom
Genhis:java1

Conversation

@Genhis

@Genhis Genhis commented Aug 26, 2018

Copy link
Copy Markdown
Contributor

Benefits:

  • Connection is closed when exception is thrown

  • Simpler usage:

    (before)

    try {
        Connection connection = Connection.newInstance("Launch into orbit");
         //your code
         connection.close();
     }
    

    (after)

    try(Connection connection = Connection.newInstance("Launch into orbit")) {
        //your code
    }
    

@djungelorm

Copy link
Copy Markdown
Member

Looks good thanks! I've also updated the code examples in the docs to use this feature.

@djungelorm djungelorm added this to the 0.4.8 milestone Sep 26, 2018
@djungelorm
djungelorm merged commit 8264f70 into krpc:master Sep 26, 2018
@Genhis
Genhis deleted the java1 branch June 11, 2019 09:52
Genhis added a commit to Genhis/KRPC.MechJeb that referenced this pull request Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants