From 57a276302d008c0ed98b29530860b35f2dd7576d Mon Sep 17 00:00:00 2001 From: dan-du-car Date: Thu, 9 May 2024 14:32:37 -0400 Subject: [PATCH] address null --- src/cc/ws/CtrlTiles.java | 9 ++++++--- src/cc/ws/TcmReqServlet.java | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cc/ws/CtrlTiles.java b/src/cc/ws/CtrlTiles.java index 55b4b826..423d7b14 100644 --- a/src/cc/ws/CtrlTiles.java +++ b/src/cc/ws/CtrlTiles.java @@ -158,7 +158,8 @@ public void init(ServletConfig oConfig) protected void doGet(HttpServletRequest oRequest, HttpServletResponse oResponse) throws ServletException, IOException { - TimeSource timeSrc = (TimeSource) this.getServletContext().getAttribute(TimeSource.class.getName()); + Object timeObj = this.getServletContext().getAttribute(TimeSource.class.getName()); + TimeSource timeSrc = timeObj != null? (TimeSource) timeObj: new TimeSource(false); long lNow = timeSrc.currentTimeMillis(); String[] sUriParts = oRequest.getRequestURI().split("/"); int nZ = Integer.parseInt(sUriParts[sUriParts.length - 3]); @@ -450,7 +451,8 @@ private void addControl(HttpServletRequest oReq, HttpServletResponse oRes) { try { - TimeSource timeSrc = (TimeSource) this.getServletContext().getAttribute(TimeSource.class.getName()); + Object timeObj = this.getServletContext().getAttribute(TimeSource.class.getName()); + TimeSource timeSrc = timeObj != null? (TimeSource) timeObj: new TimeSource(false); long lNow = timeSrc.currentTimeMillis(); int nType = Integer.parseInt(oReq.getParameter("type")); String[] sVtypes = oReq.getParameterValues("vtypes[]"); @@ -563,7 +565,8 @@ private void saveEdit(HttpServletRequest oReq, HttpServletResponse oRes) { try { - TimeSource timeSrc = (TimeSource) this.getServletContext().getAttribute(TimeSource.class.getName()); + Object timeObj = this.getServletContext().getAttribute(TimeSource.class.getName()); + TimeSource timeSrc = timeObj != null? (TimeSource) timeObj: new TimeSource(false); long lNow = timeSrc.currentTimeMillis(); int nType = Integer.parseInt(oReq.getParameter("type")); String[] sVtypes = oReq.getParameterValues("vtypes[]"); diff --git a/src/cc/ws/TcmReqServlet.java b/src/cc/ws/TcmReqServlet.java index 074cc59e..9e692ab3 100644 --- a/src/cc/ws/TcmReqServlet.java +++ b/src/cc/ws/TcmReqServlet.java @@ -109,7 +109,8 @@ public void run() { try { - TimeSource timeSrc = (TimeSource) this.getServletContext().getAttribute(TimeSource.class.getName()); + Object timeObj = this.getServletContext().getAttribute(TimeSource.class.getName()); + TimeSource timeSrc = timeObj != null? (TimeSource) timeObj: new TimeSource(false); long lNow = timeSrc.currentTimeMillis(); String sReq = Thread.currentThread().getName(); int nPos = sReq.indexOf('<');