/*
 * Copyright 2013-2014 Urs Wolfer
 *
 * Licensed 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.
 */

package com.urswolfer.gerrit.client.rest;

import com.google.common.base.Throwables;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * You can get the Gerrit REST client library version with this class.
 *
 * @author Urs Wolfer
 */
public class Version {

    private static final String VERSION;

    static {
        try {
            InputStream inputStream = Version.class.getResourceAsStream("/version.properties");
            VERSION = getVersionProperties(inputStream);
        } catch (Exception e) {
            throw Throwables.propagate(e);
        }
    }

    private static String getVersionProperties(InputStream inputStream) throws IOException {
        Properties properties = new Properties();
        properties.load(inputStream);
        inputStream.close();
        return properties.getProperty("gerrit-rest-java-client.version");
    }

    public static String get() {
        return VERSION;
    }

}

@@ -21,9 +21,9 @@
 -201
-4
+5
  Urs
@@ -962,104 +962,8 @@
 y %7B%0A
-            InputStream inputStream = Version.class.getResourceAsStream(%22/version.properties%22);%0A
     
@@ -982,32 +982,36 @@
 ION = getVersion
+From
 Properties(input
@@ -1005,27 +1005,16 @@
 perties(
-inputStream
 );%0A     
@@ -1136,16 +1136,20 @@
 tVersion
+From
 Properti
@@ -1155,31 +1155,8 @@
 ies(
-InputStream inputStream
 ) th
@@ -1174,16 +1174,126 @@
 ption %7B%0A
+        InputStream inputStream = Version.class.getResourceAsStream(%22/version.properties%22);%0A        try %7B%0A    
         
@@ -1342,16 +1342,20 @@
         
+    
 properti
@@ -1384,33 +1384,8 @@
     
-    inputStream.close();%0A
     
@@ -1450,24 +1450,87 @@
 .version%22);%0A
+        %7D finally %7B%0A            inputStream.close();%0A        %7D%0A
     %7D%0A%0A    p

improve input stream handling