X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fadsal%2Fweb%2Froot%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fweb%2FDaylightWeb.java;h=090efec31e956dc0e8aad6a15a265d3259a90dc5;hb=ea980e87f8ac521022dfd776c5186819a8a38fd2;hp=ca37f4b7c19658ca14facf9af29d6d83d2cd07cb;hpb=42c32160bfd41de57189bb246fec5ffb48ed8e9e;p=controller.git diff --git a/opendaylight/adsal/web/root/src/main/java/org/opendaylight/controller/web/DaylightWeb.java b/opendaylight/adsal/web/root/src/main/java/org/opendaylight/controller/web/DaylightWeb.java index ca37f4b7c1..090efec31e 100644 --- a/opendaylight/adsal/web/root/src/main/java/org/opendaylight/controller/web/DaylightWeb.java +++ b/opendaylight/adsal/web/root/src/main/java/org/opendaylight/controller/web/DaylightWeb.java @@ -1,5 +1,5 @@ /* - * 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, @@ -9,6 +9,7 @@ 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; @@ -18,6 +19,7 @@ import javax.servlet.http.HttpServletRequest; 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; @@ -65,11 +67,17 @@ public class DaylightWeb { @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")