<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>clustering.services</artifactId>
javax.servlet.resources,
javax.xml.parsers,
javax.xml.transform,
+ org.apache.commons.io,
org.apache.commons.logging,
org.apache.taglibs.standard.functions,
org.apache.taglibs.standard.resources,
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013, 2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.controller.web;
import java.io.FileInputStream;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import org.apache.commons.io.IOUtils;
import org.opendaylight.controller.configuration.IConfigurationContainerService;
import org.opendaylight.controller.configuration.IConfigurationService;
import org.opendaylight.controller.containermanager.IContainerAuthorization;
@ResponseBody
public String getVersion(HttpServletRequest request, @PathVariable("property") String property) {
Properties prop = new Properties();
+ FileInputStream propertiesFile = null;
try {
- prop.load(new FileInputStream("version.properties"));
+ propertiesFile = new FileInputStream("version.properties");
+ prop.load(propertiesFile);
return prop.getProperty(property+".version");
- } catch (Exception e) {
+ } catch (IOException e) {
+ // TODO: We should be logging the exception here
+ // "Failed to open version.properties."
return null;
+ } finally {
+ IOUtils.closeQuietly(propertiesFile);
}
}
@RequestMapping(value = "web.json")