[vlma-devel] commit: RrdGraphServlet: Don't use the buffer size as a magic number. ( Adrien Grand )

git version control git at videolan.org
Sun Apr 13 02:48:58 CEST 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Sun Apr 13 02:48:12 2008 +0200| [1b5a868238eee39b5a19582bc0181b13e7e9ff1b]

RrdGraphServlet: Don't use the buffer size as a magic number.

> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=1b5a868238eee39b5a19582bc0181b13e7e9ff1b
---

 .../videolan/vlma/web/servlet/RrdGraphServlet.java |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/web/src/main/java/org/videolan/vlma/web/servlet/RrdGraphServlet.java b/web/src/main/java/org/videolan/vlma/web/servlet/RrdGraphServlet.java
index 77a83cb..4092868 100644
--- a/web/src/main/java/org/videolan/vlma/web/servlet/RrdGraphServlet.java
+++ b/web/src/main/java/org/videolan/vlma/web/servlet/RrdGraphServlet.java
@@ -44,6 +44,8 @@ import org.videolan.vlma.common.exceptions.InvalidServerNameException;
  */
 public class RrdGraphServlet extends HttpServlet {
 
+    private final static int bufsize = 4096;
+
     @Override
     protected void doGet(HttpServletRequest request,
             HttpServletResponse response) throws ServletException, IOException {
@@ -53,9 +55,10 @@ public class RrdGraphServlet extends HttpServlet {
         IVlData data = (IVlData) webApplicationContext.getBean("dataImporter");
 
         String serverName = request.getParameter("server");
-        if (serverName.contains(File.separator))
+        if (serverName.contains(File.separator)) {
             throw new InvalidServerNameException("Server name musn't contain '"
                     + File.separator + "'.");
+        }
 
         String what = request.getParameter("what");
         Assert.isTrue("vlc".equals(what) || "cpu_load".equals(what)
@@ -69,7 +72,7 @@ public class RrdGraphServlet extends HttpServlet {
 
         response.setContentType("image/png");
         ServletOutputStream out = response.getOutputStream();
-        byte[] image = new byte[4096];
+        byte[] image = new byte[bufsize];
         in.read(image);
         in.close();
         out.write(image);



More information about the vlma-devel mailing list